Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ResultCacheManager: fix meta key difference for projectConfig #3887

Open
wants to merge 1 commit into
base: 2.1.x
Choose a base branch
from
Open
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
25 changes: 19 additions & 6 deletions src/Analyser/ResultCache/ResultCacheManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,18 +312,27 @@ public function restore(array $allAnalysedFiles, bool $debug, bool $onlyFiles, ?
}

/**
* @param mixed[] $cachedMeta
* @param mixed[] $currentMeta
* @param mixed[]|null $projectConfig
*/
private function isMetaDifferent(array $cachedMeta, array $currentMeta): bool
private function normalizeMetaProjectConfig(?array $projectConfig): ?string
{
$projectConfig = $currentMeta['projectConfig'];
if ($projectConfig !== null) {
ksort($currentMeta['projectConfig']);
ksort($projectConfig);

$currentMeta['projectConfig'] = Neon::encode($currentMeta['projectConfig']);
return Neon::encode($projectConfig);
}

return null;
}

/**
* @param mixed[] $cachedMeta
* @param mixed[] $currentMeta
*/
private function isMetaDifferent(array $cachedMeta, array $currentMeta): bool
{
$currentMeta['projectConfig'] = $this->normalizeMetaProjectConfig($currentMeta['projectConfig']);

return $cachedMeta !== $currentMeta;
}

Expand All @@ -337,6 +346,10 @@ private function getMetaKeyDifferences(array $cachedMeta, array $currentMeta): a
{
$diffs = [];
foreach ($cachedMeta as $key => $value) {
if ($key === 'projectConfig') {
$value = $this->normalizeMetaProjectConfig($value);
}

if (!array_key_exists($key, $currentMeta)) {
$diffs[] = $key;
continue;
Expand Down
Loading