Skip to content

Commit ab31d9d

Browse files
author
Stanislav Idolov
authored
ENGCOM-1992: [Backport] Disabling sorting in glob and scandir functions for better performance #16130
2 parents e7a953b + 5e12f47 commit ab31d9d

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
@@ -31,7 +31,7 @@ public static function getPhpFiles($changedFilesList, $fileTypes = 0)
3131
$fileUtilities = Files::init();
3232
if (isset($_ENV['INCREMENTAL_BUILD'])) {
3333
$phpFiles = [];
34-
foreach (glob($changedFilesList) as $listFile) {
34+
foreach (glob($changedFilesList, GLOB_NOSORT) as $listFile) {
3535
$phpFiles = array_merge($phpFiles, file($listFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES));
3636
}
3737
array_walk(

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ public function getMainConfigFiles($asDataSet = true)
382382
$configXmlPaths = array_merge($globPaths, $configXmlPaths);
383383
$files = [];
384384
foreach ($configXmlPaths as $xmlPath) {
385-
$files = array_merge($files, glob($xmlPath));
385+
$files = array_merge($files, glob($xmlPath, GLOB_NOSORT));
386386
}
387387
self::$_cache[$cacheKey] = $files;
388388
}

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
@@ -241,7 +241,7 @@ protected function _collectRecursive($dir)
241241
$dir = [$dir];
242242
}
243243
foreach ($dir as $folder) {
244-
if ($nodes = glob($folder . '/*')) {
244+
if ($nodes = glob($folder . '/*', GLOB_NOSORT)) {
245245
foreach ($nodes as $node) {
246246
$collectedResult[] = $node;
247247
}

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

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function testConstructException()
4848
protected function _initConfig(array $files = null)
4949
{
5050
if (null === $files) {
51-
$files = glob(__DIR__ . '/_files/validation/positive/*/validation.xml');
51+
$files = glob(__DIR__ . '/_files/validation/positive/*/validation.xml', GLOB_NOSORT);
5252
}
5353
$configFiles = [];
5454
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
@@ -104,7 +104,7 @@ public function reindex(OutputInterface $output)
104104
*/
105105
public function loadFixtures()
106106
{
107-
$files = glob(__DIR__ . DIRECTORY_SEPARATOR . self::FIXTURE_PATTERN);
107+
$files = glob(__DIR__ . DIRECTORY_SEPARATOR . self::FIXTURE_PATTERN, GLOB_NOSORT);
108108

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

0 commit comments

Comments
 (0)