Skip to content

Commit 62ae6fe

Browse files
authored
Merge pull request #196 from rhoerr/claude/generalize-product-metadata-YIO0T
Generalize product metapackage detection for alternate metapackages
2 parents 813496e + ee15f57 commit 62ae6fe

File tree

7 files changed

+66
-21
lines changed

7 files changed

+66
-21
lines changed

app/etc/di.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1880,6 +1880,10 @@
18801880
<item name="MySQL-5.7" xsi:type="string">^5\.7\.</item>
18811881
<item name="MariaDB-(10.2-10.6)" xsi:type="string">^10\.[2-6]\.</item>
18821882
<item name="MariaDB-11.4" xsi:type="string">^11\.4\.</item>
1883+
<!-- Mage-OS wider compatibility rules to match reessolutions/db-override -->
1884+
<item name="MySQL-(8.0-8.4)" xsi:type="string">^8\.[0-4]\.</item>
1885+
<item name="MariaDB-(10.2-10.11)" xsi:type="string">^10\.([2-9]|10|11)\.</item>
1886+
<item name="MariaDB-11.x" xsi:type="string">^11\.</item>
18831887
</argument>
18841888
</arguments>
18851889
</type>

lib/internal/Magento/Framework/App/Test/Unit/ProductMetadataTest.php

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,20 +77,27 @@ public function testGetVersionCached()
7777
public static function testGetVersionGitInstallationDataProvider()
7878
{
7979
return [
80-
[
80+
'community edition package' => [
8181
[
82-
0 => [
83-
'name' => 'magento/product-community-edition',
84-
'version' => '123.456.789'
85-
],
86-
1 => [
87-
'name' => 'magento/product-other-edition',
88-
'version' => '987.654.321'
82+
'mage-os/product-community-edition' => [
83+
'name' => 'mage-os/product-community-edition',
84+
'version' => '1.0.0',
85+
'magento_version' => '123.456.789'
8986
],
9087
],
9188
'123.456.789'
9289
],
93-
[
90+
'minimal product package' => [
91+
[
92+
'mage-os/product-minimal' => [
93+
'name' => 'mage-os/product-minimal',
94+
'version' => '2.0.0',
95+
'magento_version' => '234.567.890'
96+
],
97+
],
98+
'234.567.890'
99+
],
100+
'empty packages' => [
94101
[],
95102
'UNKNOWN'
96103
]

lib/internal/Magento/Framework/Composer/ComposerInformation.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,12 @@ public function getRequiredPhpVersion()
116116
foreach ($packages as $package) {
117117
if ($package instanceof CompletePackageInterface) {
118118
$packageName = $package->getPrettyName();
119-
if ($packageName === 'mage-os/product-community-edition') {
119+
if ($this->isSystemPackage($packageName)) {
120120
$phpRequirementLink = $package->getRequires()['php'];
121121
if ($phpRequirementLink instanceof Link) {
122122
$requiredPhpVersion = $phpRequirementLink->getPrettyConstraint();
123123
}
124+
break;
124125
}
125126
}
126127
}
@@ -262,7 +263,7 @@ public function getSystemPackages()
262263
*/
263264
public function isSystemPackage($packageName = '')
264265
{
265-
if (preg_match('/mage-os\/product-.*?-edition/', $packageName) == 1) {
266+
if (preg_match('/^mage-os\/product-.+/', $packageName) == 1) {
266267
return true;
267268
}
268269
return false;

lib/internal/Magento/Framework/Composer/Test/Unit/ComposerInformationTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,31 @@ public static function isMagentoRootDataProvider()
119119
['namespace/package', false],
120120
];
121121
}
122+
123+
/**
124+
* @param string $packageName
125+
* @param boolean $expected
126+
* @dataProvider isSystemPackageDataProvider
127+
*/
128+
public function testIsSystemPackage($packageName, $expected)
129+
{
130+
$this->assertEquals($expected, $this->composerInformation->isSystemPackage($packageName));
131+
}
132+
133+
/**
134+
* @return array
135+
*/
136+
public static function isSystemPackageDataProvider()
137+
{
138+
return [
139+
['mage-os/product-community-edition', true],
140+
['mage-os/product-enterprise-edition', true],
141+
['mage-os/product-minimal', true],
142+
['mage-os/product-custom-build', true],
143+
['magento/product-community-edition', false],
144+
['mage-os/module-something', false],
145+
['namespace/package', false],
146+
['mage-os/product-', false],
147+
];
148+
}
122149
}

lib/internal/Magento/Framework/Interception/PluginList/PluginList.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,10 @@ protected function _loadScopedData()
217217
}
218218
$this->_scopePriorityScheme[] = $scope;
219219

220-
$cacheId = implode('|', $this->_scopePriorityScheme) . "|" . $this->_cacheId;
220+
// Normalize cache ID by sorting scopes - ensures consistent ID regardless of processing order
221+
$sortedScheme = array_values($this->_scopePriorityScheme);
222+
sort($sortedScheme);
223+
$cacheId = implode('|', $sortedScheme) . "|" . $this->_cacheId;
221224
$configData = $this->configLoader->load($cacheId);
222225

223226
if ($configData) {

lib/internal/Magento/Framework/Interception/PluginListGenerator.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,17 @@ public function write(array $scopes): void
150150
foreach ($scopes as $scope) {
151151
$this->scopeConfig->setCurrentScope($scope);
152152
if (false === isset($this->loadedScopes[$scope])) {
153-
if (false === in_array($scope, $this->scopePriorityScheme, true)) {
154-
$this->scopePriorityScheme[] = $scope;
153+
// Match PluginList::_loadScopedData() behavior - move scope to end
154+
// This ensures cache IDs match between compile-time and runtime
155+
$index = array_search($scope, $this->scopePriorityScheme, true);
156+
if ($index !== false) {
157+
unset($this->scopePriorityScheme[$index]);
155158
}
156-
$cacheId = implode('|', $this->scopePriorityScheme) . "|" . $this->cacheId;
159+
$this->scopePriorityScheme[] = $scope;
160+
// Normalize cache ID by sorting scopes - ensures consistent ID regardless of processing order
161+
$sortedScheme = array_values($this->scopePriorityScheme);
162+
sort($sortedScheme);
163+
$cacheId = implode('|', $sortedScheme) . "|" . $this->cacheId;
157164
[
158165
$virtualTypes,
159166
$this->scopePriorityScheme,

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,8 @@ public function __construct(
4444
public function doOperation()
4545
{
4646
$scopes = $this->scopeConfig->getAllScopes();
47-
// remove primary scope for production mode as it is only called in developer mode
48-
$scopes = array_diff($scopes, ['primary']);
49-
50-
// sort configuration to have it in the same order on every build
51-
ksort($scopes);
52-
47+
// Cache IDs are now normalized (sorted) in PluginListGenerator::write()
48+
// so processing order no longer affects cache ID generation
5349
$this->configWriter->write($scopes);
5450
}
5551

0 commit comments

Comments
 (0)