Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,26 @@
class PluginListGeneratorTest extends TestCase
{
/**
* Generated plugin list config for frontend scope
* Generated plugin list config for frontend scope (scopes sorted alphabetically in PluginListGenerator)
*/
const CACHE_ID_FRONTEND = 'primary|global|frontend|plugin-list';
private const CACHE_ID_FRONTEND = 'frontend|global|primary|plugin-list';

/**
* Generated plugin list config for dummy scope
* Generated plugin list config for dummy scope (scopes sorted alphabetically in PluginListGenerator)
*/
const CACHE_ID_DUMMY = 'primary|global|dummy|plugin-list';
private const CACHE_ID_DUMMY = 'dummy|global|primary|plugin-list';

private $cacheIds = [self::CACHE_ID_FRONTEND, self::CACHE_ID_DUMMY];
/**
* Generated plugin list config for global scope (used in tearDown for cleanup)
*/
private const CACHE_ID_GLOBAL = 'global|primary|plugin-list';

/**
* Cache IDs to clean up in tearDown
*
* @var array<int, string>
*/
private $cacheIds = [self::CACHE_ID_GLOBAL, self::CACHE_ID_FRONTEND, self::CACHE_ID_DUMMY];

/**
* @var PluginListGenerator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,10 @@ protected function _loadScopedData()
}
$this->_scopePriorityScheme[] = $scope;

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

if ($configData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,17 @@ public function write(array $scopes): void
foreach ($scopes as $scope) {
$this->scopeConfig->setCurrentScope($scope);
if (false === isset($this->loadedScopes[$scope])) {
if (false === in_array($scope, $this->scopePriorityScheme, true)) {
$this->scopePriorityScheme[] = $scope;
// Match PluginList::_loadScopedData() behavior - move scope to end
// This ensures cache IDs match between compile-time and runtime
$index = array_search($scope, $this->scopePriorityScheme, true);
if ($index !== false) {
unset($this->scopePriorityScheme[$index]);
}
$cacheId = implode('|', $this->scopePriorityScheme) . "|" . $this->cacheId;
$this->scopePriorityScheme[] = $scope;
// Normalize cache ID by sorting scopes - ensures consistent ID regardless of processing order
$sortedScheme = array_values($this->scopePriorityScheme);
sort($sortedScheme);
$cacheId = implode('|', $sortedScheme) . "|" . $this->cacheId;
[
$virtualTypes,
$this->scopePriorityScheme,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,8 @@ public function __construct(
public function doOperation()
{
$scopes = $this->scopeConfig->getAllScopes();
// remove primary scope for production mode as it is only called in developer mode
$scopes = array_diff($scopes, ['primary']);

// sort configuration to have it in the same order on every build
ksort($scopes);

// Cache IDs are now normalized (sorted) in PluginListGenerator::write()
// so processing order no longer affects cache ID generation
$this->configWriter->write($scopes);
}

Expand Down