Skip to content

Commit 7167d9b

Browse files
author
Stanislav Idolov
authored
ENGCOM-1993: [Forwardport] Disabling sorting in glob and scandir functions for better performance #16128
2 parents e37269e + f2c71a9 commit 7167d9b

File tree

8 files changed

+8
-8
lines changed

8 files changed

+8
-8
lines changed

dev/tests/static/framework/Magento/TestFramework/Utility/ChangedFiles.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static function getPhpFiles($changedFilesList, $fileTypes = 0)
3232
$fileUtilities = Files::init();
3333
if (isset($_ENV['INCREMENTAL_BUILD'])) {
3434
$phpFiles = [];
35-
foreach (glob($changedFilesList) as $listFile) {
35+
foreach (glob($changedFilesList, GLOB_NOSORT) as $listFile) {
3636
$phpFiles = array_merge($phpFiles, file($listFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES));
3737
}
3838
array_walk(

lib/internal/Magento/Framework/App/Utility/Files.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ public function getMainConfigFiles($asDataSet = true)
392392
$configXmlPaths = array_merge($globPaths, $configXmlPaths);
393393
$files = [];
394394
foreach ($configXmlPaths as $xmlPath) {
395-
$files = array_merge($files, glob($xmlPath));
395+
$files = array_merge($files, glob($xmlPath, GLOB_NOSORT));
396396
}
397397
self::$_cache[$cacheKey] = $files;
398398
}

lib/internal/Magento/Framework/Archive/Tar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ protected function _createTar($skipRoot = false, $finalize = false)
252252
$file = $this->_getCurrentFile();
253253

254254
if (is_dir($file)) {
255-
$dirFiles = scandir($file);
255+
$dirFiles = scandir($file, SCANDIR_SORT_NONE);
256256

257257
if (false === $dirFiles) {
258258
throw new \Magento\Framework\Exception\LocalizedException(

lib/internal/Magento/Framework/Backup/Test/Unit/_files/app_dirs_rollback.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
}
1616
}
1717

18-
$files = glob(TESTS_TEMP_DIR . '/Magento/Backup/data/*');
18+
$files = glob(TESTS_TEMP_DIR . '/Magento/Backup/data/*', GLOB_NOSORT);
1919
foreach ($files as $file) {
2020
unlink($file);
2121
}

lib/internal/Magento/Framework/Data/Collection/Filesystem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ protected function _collectRecursive($dir)
243243
$dir = [$dir];
244244
}
245245
foreach ($dir as $folder) {
246-
if ($nodes = glob($folder . '/*')) {
246+
if ($nodes = glob($folder . '/*', GLOB_NOSORT)) {
247247
foreach ($nodes as $node) {
248248
$collectedResult[] = $node;
249249
}

lib/internal/Magento/Framework/Filesystem/Io/File.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ protected static function _recursiveCallback($dir, array $fileCallback, array $d
366366
$dirCallback = $fileCallback;
367367
}
368368
if (is_dir($dir)) {
369-
foreach (scandir($dir) as $item) {
369+
foreach (scandir($dir, SCANDIR_SORT_NONE) as $item) {
370370
if (!strcmp($item, '.') || !strcmp($item, '..')) {
371371
continue;
372372
}

lib/internal/Magento/Framework/Validator/Test/Unit/ConfigTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function testConstructException()
5151
protected function _initConfig(array $files = null)
5252
{
5353
if (null === $files) {
54-
$files = glob(__DIR__ . '/_files/validation/positive/*/validation.xml');
54+
$files = glob(__DIR__ . '/_files/validation/positive/*/validation.xml', GLOB_NOSORT);
5555
}
5656
$configFiles = [];
5757
foreach ($files as $path) {

setup/src/Magento/Setup/Fixtures/FixtureModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function reindex(OutputInterface $output)
105105
*/
106106
public function loadFixtures()
107107
{
108-
$files = glob(__DIR__ . DIRECTORY_SEPARATOR . self::FIXTURE_PATTERN);
108+
$files = glob(__DIR__ . DIRECTORY_SEPARATOR . self::FIXTURE_PATTERN, GLOB_NOSORT);
109109

110110
foreach ($files as $file) {
111111
$file = basename($file, '.php');

0 commit comments

Comments
 (0)