Skip to content

Commit 92d154c

Browse files
committed
Changelog excerpt: - Fixed a bottleneck in the scan process caused by the readFileBlocks method.
1 parent 8c7b742 commit 92d154c

File tree

3 files changed

+33
-30
lines changed

3 files changed

+33
-30
lines changed

Changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,7 @@ __*Why "v3.0.0" instead of "v1.0.0?"*__ Prior to phpMussel v3, the "phpMussel Co
7373
[2022.02.01; Bug-fix; Maikuolan]: Failed to correctly determine the client's IP address under certain circumstances (e.g., multiple choices available via HTTP_X_FORWARDED_FOR); Fixed.
7474

7575
[2022.02.14; Maikuolan]: Maintenance release.
76+
77+
### v3.2.3
78+
79+
[2022.03.24; Bug-fix; Maikuolan]: Fixed a bottleneck in the scan process caused by the readFileBlocks method (phpMussel/phpMussel#231).

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
},
1313
"require": {
1414
"php": ">=7.2.0",
15-
"maikuolan/common": "^2.8",
16-
"phpmussel/core": "^3.3.1",
15+
"phpmussel/core": "^3.3.2",
1716
"ext-pcre": "*"
1817
},
1918
"autoload": {

src/FrontEnd.php

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* License: GNU/GPLv2
99
* @see LICENSE.txt
1010
*
11-
* This file: Front-end handler (last modified: 2022.03.22).
11+
* This file: Front-end handler (last modified: 2022.03.24).
1212
*/
1313

1414
namespace phpMussel\FrontEnd;
@@ -247,7 +247,7 @@ public function view(string $Page = ''): void
247247
),
248248

249249
/** Main front-end HTML template file. */
250-
'Template' => $this->Loader->readFileBlocks($this->getAssetPath('frontend.html')),
250+
'Template' => $this->Loader->readFileContent($this->getAssetPath('frontend.html')),
251251

252252
/** Populated by front-end JavaScript data as per needed. */
253253
'JS' => '',
@@ -345,7 +345,7 @@ public function view(string $Page = ''): void
345345

346346
/** Fetch pips data. */
347347
$PipsPath = $this->getAssetPath('pips.yml');
348-
$PipsData = $this->Loader->readFileBlocks($PipsPath);
348+
$PipsData = $this->Loader->readFileContent($PipsPath);
349349
$Pips = [];
350350
if ($PipsData) {
351351
$this->Loader->YAML->process($PipsData, $Pips);
@@ -417,7 +417,7 @@ public function view(string $Page = ''): void
417417
header('Last-Modified: ' . gmdate(DATE_RFC1123, filemtime($ThisAsset)));
418418
}
419419
/** Send asset data. */
420-
echo $this->Loader->readFileBlocks($ThisAsset);
420+
echo $this->Loader->readFileContent($ThisAsset);
421421
}
422422
}
423423
return;
@@ -428,7 +428,7 @@ public function view(string $Page = ''): void
428428
header('Content-Type: text/css');
429429
echo $this->Loader->parse($FE, $this->Loader->parse(
430430
$this->Loader->L10N->Data,
431-
$this->Loader->readFileBlocks($this->getAssetPath('frontend.css'))
431+
$this->Loader->readFileContent($this->getAssetPath('frontend.css'))
432432
));
433433
return;
434434
}
@@ -615,13 +615,13 @@ public function view(string $Page = ''): void
615615
/** If the user has complete access. */
616616
$FE['nav'] = $this->Loader->parse(
617617
$this->Loader->L10N->Data,
618-
$this->Loader->parse($FE, $this->Loader->readFileBlocks($this->getAssetPath('_nav_complete_access.html')))
618+
$this->Loader->parse($FE, $this->Loader->readFileContent($this->getAssetPath('_nav_complete_access.html')))
619619
);
620620
} elseif ($this->Permissions === 2) {
621621
/** If the user has logs access only. */
622622
$FE['nav'] = $this->Loader->parse(
623623
$this->Loader->L10N->Data,
624-
$this->Loader->parse($FE, $this->Loader->readFileBlocks($this->getAssetPath('_nav_logs_access_only.html')))
624+
$this->Loader->parse($FE, $this->Loader->readFileContent($this->getAssetPath('_nav_logs_access_only.html')))
625625
);
626626
} else {
627627
/** No valid navigation state. */
@@ -644,7 +644,7 @@ public function view(string $Page = ''): void
644644
/** Show them the two-factor authentication page. */
645645
$FE['FE_Content'] = $this->Loader->parse(
646646
$this->Loader->L10N->Data,
647-
$this->Loader->parse($FE, $this->Loader->readFileBlocks($this->getAssetPath('_2fa.html')))
647+
$this->Loader->parse($FE, $this->Loader->readFileContent($this->getAssetPath('_2fa.html')))
648648
);
649649
} else {
650650
/** Omit the log out and home links. */
@@ -658,7 +658,7 @@ public function view(string $Page = ''): void
658658
/** Show them the login page. */
659659
$FE['FE_Content'] = $this->Loader->parse(
660660
$this->Loader->L10N->Data,
661-
$this->Loader->parse($FE, $this->Loader->readFileBlocks($this->getAssetPath('_login.html')))
661+
$this->Loader->parse($FE, $this->Loader->readFileContent($this->getAssetPath('_login.html')))
662662
);
663663
}
664664
/** Send output. */
@@ -844,7 +844,7 @@ public function view(string $Page = ''): void
844844
/** Parse output. */
845845
$FE['FE_Content'] = $this->Loader->parse(
846846
$this->Loader->L10N->Data,
847-
$this->Loader->parse($FE, $this->Loader->readFileBlocks($this->getAssetPath('_home.html')))
847+
$this->Loader->parse($FE, $this->Loader->readFileContent($this->getAssetPath('_home.html')))
848848
) . $MenuToggle;
849849

850850
/** Send output. */
@@ -940,7 +940,7 @@ public function view(string $Page = ''): void
940940
"w('stateMsg',"
941941
);
942942

943-
$AccountsRow = $this->Loader->readFileBlocks($this->getAssetPath('_accounts_row.html'));
943+
$AccountsRow = $this->Loader->readFileContent($this->getAssetPath('_accounts_row.html'));
944944
$FE['Accounts'] = '';
945945
$NewLineOffSet = 0;
946946

@@ -999,7 +999,7 @@ public function view(string $Page = ''): void
999999
/** Parse output. */
10001000
$FE['FE_Content'] = $this->Loader->parse(
10011001
$this->Loader->L10N->Data,
1002-
$this->Loader->parse($FE, $this->Loader->readFileBlocks($this->getAssetPath('_accounts.html')))
1002+
$this->Loader->parse($FE, $this->Loader->readFileContent($this->getAssetPath('_accounts.html')))
10031003
);
10041004

10051005
/** Send output. */
@@ -1017,7 +1017,7 @@ public function view(string $Page = ''): void
10171017
$FE['JS'] .= $this->numberJS() . "\n";
10181018

10191019
/** Directive template. */
1020-
$ConfigurationRow = $this->Loader->readFileBlocks($this->getAssetPath('_config_row.html'));
1020+
$ConfigurationRow = $this->Loader->readFileContent($this->getAssetPath('_config_row.html'));
10211021

10221022
/** Flag for modified configuration. */
10231023
$ConfigurationModified = false;
@@ -1473,7 +1473,7 @@ public function view(string $Page = ''): void
14731473
/** Parse output. */
14741474
$FE['FE_Content'] = $this->Loader->parse(
14751475
$this->Loader->L10N->Data,
1476-
$this->Loader->parse($FE, $this->Loader->readFileBlocks($this->getAssetPath('_config.html')))
1476+
$this->Loader->parse($FE, $this->Loader->readFileContent($this->getAssetPath('_config.html')))
14771477
) . $MenuToggle;
14781478

14791479
/** Send output. */
@@ -1542,7 +1542,7 @@ public function view(string $Page = ''): void
15421542
/** Parse output. */
15431543
$FE['FE_Content'] = $this->Loader->parse(
15441544
$this->Loader->L10N->Data,
1545-
$this->Loader->parse($FE, $this->Loader->readFileBlocks($this->getAssetPath('_cache.html')))
1545+
$this->Loader->parse($FE, $this->Loader->readFileContent($this->getAssetPath('_cache.html')))
15461546
) . $MenuToggle;
15471547

15481548
/** Send output. */
@@ -1571,7 +1571,7 @@ public function view(string $Page = ''): void
15711571
/** Parse output. */
15721572
$FE['FE_Content'] = $this->Loader->parse(
15731573
$this->Loader->L10N->Data,
1574-
$this->Loader->parse($FE, $this->Loader->readFileBlocks($this->getAssetPath('_upload_test.html')))
1574+
$this->Loader->parse($FE, $this->Loader->readFileContent($this->getAssetPath('_upload_test.html')))
15751575
);
15761576

15771577
/** Send output. */
@@ -1652,7 +1652,7 @@ public function view(string $Page = ''): void
16521652
}
16531653

16541654
/** Template for quarantine files row. */
1655-
$QuarantineRow = $this->Loader->readFileBlocks($this->getAssetPath('_quarantine_row.html'));
1655+
$QuarantineRow = $this->Loader->readFileContent($this->getAssetPath('_quarantine_row.html'));
16561656

16571657
/** Fetch quarantine data array. */
16581658
$FilesInQuarantine = $this->quarantineRecursiveList();
@@ -1683,7 +1683,7 @@ public function view(string $Page = ''): void
16831683
/** Parse output. */
16841684
$FE['FE_Content'] = $this->Loader->parse(
16851685
$this->Loader->L10N->Data,
1686-
$this->Loader->parse($FE, $this->Loader->readFileBlocks($this->getAssetPath('_quarantine.html')))
1686+
$this->Loader->parse($FE, $this->Loader->readFileContent($this->getAssetPath('_quarantine.html')))
16871687
);
16881688

16891689
/** Send output. */
@@ -1715,7 +1715,7 @@ public function view(string $Page = ''): void
17151715
/** Parse output. */
17161716
$FE['FE_Content'] = $this->Loader->parse(
17171717
$this->Loader->L10N->Data,
1718-
$this->Loader->parse($FE, $this->Loader->readFileBlocks($this->getAssetPath('_siginfo.html')))
1718+
$this->Loader->parse($FE, $this->Loader->readFileContent($this->getAssetPath('_siginfo.html')))
17191719
);
17201720

17211721
/** Send output. */
@@ -1789,7 +1789,7 @@ public function view(string $Page = ''): void
17891789
/** Parse output. */
17901790
$FE['FE_Content'] = $this->Loader->parse(
17911791
$this->Loader->L10N->Data,
1792-
$this->Loader->parse($FE, $this->Loader->readFileBlocks($this->getAssetPath('_statistics.html')))
1792+
$this->Loader->parse($FE, $this->Loader->readFileContent($this->getAssetPath('_statistics.html')))
17931793
);
17941794

17951795
/** Send output. */
@@ -1808,7 +1808,7 @@ public function view(string $Page = ''): void
18081808
/** Parse output. */
18091809
$FE['FE_Content'] = $this->Loader->parse(
18101810
$this->Loader->L10N->Data,
1811-
$this->Loader->parse($FE, $this->Loader->readFileBlocks($this->getAssetPath('_logs.html')))
1811+
$this->Loader->parse($FE, $this->Loader->readFileContent($this->getAssetPath('_logs.html')))
18121812
);
18131813

18141814
/** Initialise array for fetching logs data. */
@@ -1834,9 +1834,9 @@ public function view(string $Page = ''): void
18341834
} else {
18351835
$FE['TextModeSwitchLink'] .= '?phpmussel-page=logs&logfile=' . $this->QueryVariables['logfile'] . '&text-mode=';
18361836
if (strtolower(substr($this->QueryVariables['logfile'], -3)) === '.gz') {
1837-
$FE['logfileData'] = $this->Loader->readFileBlocksGZ($this->QueryVariables['logfile']);
1837+
$FE['logfileData'] = $this->Loader->readFileContentGZ($this->QueryVariables['logfile']);
18381838
} else {
1839-
$FE['logfileData'] = $this->Loader->readFileBlocks($this->QueryVariables['logfile']);
1839+
$FE['logfileData'] = $this->Loader->readFileContent($this->QueryVariables['logfile']);
18401840
}
18411841
$FE['logfileData'] = $TextMode ? str_replace(
18421842
['<', '>', "\r", "\n"],
@@ -2079,7 +2079,7 @@ private function quarantineRecursiveList(): array
20792079
'QFU-Size' => filesize($Item)
20802080
];
20812081
$this->formatFilesize($Arr[$Key]['QFU-Size']);
2082-
$Head = $this->Loader->readFileBlocks($Item, 256);
2082+
$Head = $this->Loader->readFileContent($Item);
20832083

20842084
/** Upload date/time. */
20852085
$Arr[$Key]['Upload-Date'] = (
@@ -2136,7 +2136,7 @@ private function quarantineRestore(string $File, string $Key): string
21362136
}
21372137

21382138
/** Fetch data. */
2139-
$Data = $this->Loader->readFileBlocks($File);
2139+
$Data = $this->Loader->readFileContent($File);
21402140

21412141
/** Fetch headers. */
21422142
if (($HeadPos = strpos($Data, "\xA1phpMussel\x21")) === false || (substr($Data, $HeadPos + 31, 1) !== "\1")) {
@@ -2209,7 +2209,7 @@ private function signatureInformationHandler(string &$InfoRows, string &$SigInfo
22092209
}));
22102210

22112211
/** Template for range rows. */
2212-
$InfoRow = $this->Loader->readFileBlocks($this->getAssetPath('_siginfo_row.html'));
2212+
$InfoRow = $this->Loader->readFileContent($this->getAssetPath('_siginfo_row.html'));
22132213

22142214
/** Get list of vendor search patterns and metadata search pattern partials. */
22152215
$Arr = [
@@ -2257,7 +2257,7 @@ private function signatureInformationHandler(string &$InfoRows, string &$SigInfo
22572257
/** Iterate through active signature files and append totals. */
22582258
foreach ($Active as $File) {
22592259
$File = (strpos($File, ':') === false) ? $File : substr($File, strpos($File, ':') + 1);
2260-
$Data = $File && is_readable($this->Loader->SignaturesPath . $File) ? $this->Loader->readFileBlocks($this->Loader->SignaturesPath . $File) : '';
2260+
$Data = $this->Loader->readFileContent($this->Loader->SignaturesPath . $File);
22612261
if (substr($Data, 0, 9) !== 'phpMussel') {
22622262
continue;
22632263
}
@@ -2352,7 +2352,7 @@ private function initialPrepwork(array &$FE, string $Title = '', string $Tips =
23522352
$FE['FE_Tip'] = $this->Loader->parse(['username' => $Username], $Tips);
23532353

23542354
/** Load main front-end JavaScript data. */
2355-
$FE['JS'] = $JS ? $this->Loader->readFileBlocks($this->getAssetPath('scripts.js')) : '';
2355+
$FE['JS'] = $JS ? $this->Loader->readFileContent($this->getAssetPath('scripts.js')) : '';
23562356
}
23572357

23582358
/**

0 commit comments

Comments
 (0)