Skip to content

Commit 6cf5ee9

Browse files
committed
Make builds repeatable
Sort all configs in generated/metadata before writing to file
1 parent 46679e7 commit 6cf5ee9

File tree

5 files changed

+18
-14
lines changed

5 files changed

+18
-14
lines changed

lib/internal/Magento/Framework/Interception/Config/CacheManager.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ public function save(string $key, array $data)
8888
*/
8989
public function saveCompiled(string $key, array $data)
9090
{
91+
// sort configuration to have it in the same order on every build
92+
ksort($data);
93+
9194
$this->configWriter->write($key, $data);
9295
}
9396

setup/src/Magento/Setup/Module/Di/App/Task/Operation/AppActionListGenerator.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class AppActionListGenerator implements OperationInterface
2020
private $moduleReader;
2121

2222
/**
23-
* @var \Magento\Framework\App\ObjectManager\ConfigWriterInterface
23+
* @var ConfigWriterInterface
2424
*/
2525
private $configWriter;
2626

@@ -42,10 +42,11 @@ public function __construct(
4242
public function doOperation()
4343
{
4444
$actionList = $this->moduleReader->getActionFiles();
45-
$this->configWriter->write(
46-
'app_action_list',
47-
$actionList
48-
);
45+
46+
// sort configuration to have it in the same order on every build
47+
ksort($actionList);
48+
49+
$this->configWriter->write('app_action_list', $actionList);
4950
}
5051

5152
/**

setup/src/Magento/Setup/Module/Di/App/Task/Operation/Area.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,12 @@ public function doOperation()
9595
$config = $this->configReader->generateCachePerScope($definitionsCollection, $areaCode);
9696
$config = $this->modificationChain->modify($config);
9797

98-
$this->configWriter->write(
99-
$areaCode,
100-
$config
101-
);
98+
// sort configuration to have it in the same order on every build
99+
ksort($config['arguments']);
100+
ksort($config['preferences']);
101+
ksort($config['instanceTypes']);
102+
103+
$this->configWriter->write($areaCode, $config);
102104
}
103105
}
104106

setup/src/Magento/Setup/Module/Di/App/Task/Operation/PluginListGenerator.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ public function doOperation()
4747
// remove primary scope for production mode as it is only called in developer mode
4848
$scopes = array_diff($scopes, ['primary']);
4949

50+
// sort configuration to have it in the same order on every build
51+
ksort($scopes);
52+
5053
$this->configWriter->write($scopes);
5154
}
5255

setup/src/Magento/Setup/Module/Di/Compiler/Config/Reader.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,6 @@ public function generateCachePerScope(
100100
$config['instanceTypes'][$virtualType] = $areaConfig->getInstanceType($virtualType);
101101
}
102102

103-
// sort configuration to have it in the same order on every build
104-
ksort($config['arguments']);
105-
ksort($config['preferences']);
106-
ksort($config['instanceTypes']);
107-
108103
return $config;
109104
}
110105

0 commit comments

Comments
 (0)