-
-
Notifications
You must be signed in to change notification settings - Fork 188
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
BUGFIX: #3303 Flush reflection cache for removed php classes #3383
base: 9.0
Are you sure you want to change the base?
BUGFIX: #3303 Flush reflection cache for removed php classes #3383
Conversation
There are a few layers to this bugfix. 1. Previously we ignored deleted files (see `file_exists`) and did not flush the `Flow_Reflection_Status` cache accordingly as we are not able to read the namespace from a deleted php file. Now we do a best effort reverse lookup by going through all psr-4 autoload configurations and calculate a namespace under which composer would have found this file. 2. We introduce a state `removedReflectionDataClasses` like `updatedReflectionData` which will be used to check if we have to update the `ReflectionData` cache.
continue; | ||
} | ||
$classNameWithUnderscores = str_replace('\\', '_', $className); | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
technically we can discuss if we always want to use the psr-4 reverse lookup instead of parsing the file via PhpAnalyzer
... but for that we would need to know how stable this logic is... for example regarding symlinks
I am quite opposed to adding more places where we lookup package classes/class loading to do magic stuff, I think we need to get rid of that concept. |
@@ -1833,6 +1837,8 @@ protected function forgetClass($className): void | |||
|
|||
unset($this->classReflectionData[$className]); | |||
unset($this->classesCurrentlyBeingForgotten[$className]); | |||
|
|||
$this->removedReflectionDataClasses[$className] = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo check if forgetClass
is also called in other occasions and if this flag makes sense in that case.
@@ -2092,7 +2098,7 @@ protected function saveProductionData(): void | |||
*/ | |||
protected function updateReflectionData(): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$this->removedReflectionDataClasses
should be reset to []
in here, right?
resolves #3303
There are a few layers to this bugfix.
Previously we ignored deleted files (see
file_exists
) and did not flush theFlow_Reflection_Status
cache accordingly as we are not able to read the namespace from a deleted php file. Now we do a best effort reverse lookup by going through all psr-4 autoload configurations and calculate a namespace under which composer would have found this file.We introduce a state
removedReflectionDataClasses
likeupdatedReflectionData
which will be used to check if we have to update theReflectionData
cache.Upgrade instructions
Review instructions
How to test
We want to test
getAllImplementationClassNamesForInterface
as by the bugreport. And we can do this simply because we use it at a few places.ReferencePropertyOperation
(which is not used on the homepage)Without this fix there will be an error thrown:
How the fix works
With the fix applied we get the information that
"/Users/neos/Packages/Neos/Neos.ContentRepository.NodeAccess/Classes/FlowQueryOperations/ReferencePropertyOperation.php"
was removed. Then we can resolve that it belongs to the packageNeos.ContentRepository.NodeAccess
and reverse calculate its namespace/cache identifier (with underscores):Neos_ContentRepository_NodeAccess_FlowQueryOperations_ReferencePropertyOperation
. Then we can flush the cache accordingly.Todo
Checklist
FEATURE|TASK|BUGFIX
!!!
and have upgrade-instructions