-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add wakeup call in CompileInjector #111
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Address the type contradiction and logic of the null check on
this->functions
.The addition of a null check on
this->functions
suggests that it can benull
. However, the type declaration ofthis->functions
as an array of callables implies it should never benull
. This contradiction might indicate an issue with either the type declaration or the logic of the null check. Consider revising the type declaration ifnull
is a valid state or adjusting the logic to handle this scenario differently.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.
@coderabbitai I agree, but there are cases where
__wakeup
is not called when serialising or unserialising this class, and this is a countermeasure to that.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.
@koriym, thank you for clarifying the situation with the
__wakeup
method not being called automatically in certain serialization or deserialization scenarios. This indeed sounds like a practical safeguard.Given this context, it might be beneficial to ensure that the serialization and deserialization processes are aligned with PHP's expected behaviors, where
__wakeup
should ideally be invoked automatically. If this issue is recurring or if there are specific conditions under which__wakeup
fails to be called, it could be valuable to document these cases or consider a review of the overall design to address potential inconsistencies.If you think it would be helpful, we could look into documenting these scenarios more formally or even revisiting the design to ensure robustness without needing manual interventions. Let me know how you would like to proceed!
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.
@coderabbitai See koriym/BEAR.SpikeProject#1
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.
@koriym, thank you for sharing the link to the GitHub issue. It provides valuable insights into the problem you're facing with serialization and deserialization in the context of the
CompileInjector
.Issue Summary:
The issue describes a scenario where the injector cache fails to verify, leading to a PHP warning. This seems to occur when using the
bear.compile
command with theMyVendor\MyProject
in a production environment. The warning points to a failure in verifying the injector cache, similar to another issue reported in the BEAR.Package repository.Key Points from the Issue:
__wakeup
method is not being called as expected during the unserialization process. This is crucial because, as noted in the issue, PHP'sunserialize()
function treats the result as a creation of a 'new' object, and thus__wakeup
is only called if the object is directly created as a result of unserialization.__wakeup
externally fromResourceStorage
(a temporary fix).CompileInjector
to ensure that the absence of these method calls does not affect functionality.Suggested Actions:
Given the complexity and the recurring nature of this issue, it might be beneficial to consider a more robust solution that either ensures
__wakeup
is reliably called or redesigns the system to not rely on it. Here are a couple of suggestions:If you need further analysis or assistance in implementing these suggestions, feel free to let me know!
Analysis chain
Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 1835
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.
@koriym, thank you for sharing the link to the GitHub issue. It provides valuable insights into the problem you're facing with the serialization and deserialization process in the
CompileInjector
class.Issue Summary:
The issue titled "PHP Warning: Failed to verify the injector cache" describes a scenario where the injector cache fails to verify, leading to a PHP warning. This occurs when attempting to compile with the command
./vendor/bin/bear.compile 'MyVendor\\MyProject' prod-app ./
. The warning points to a failure in verifying the injector cache, which is linked to the__wakeup
method not being called as expected during the unserialization process.Key Points from the Issue:
__wakeup
method is not being called automatically when expected, particularly when objects are nested within serialized data. This is because PHP'sunserialize()
function does not automatically trigger__wakeup
for already unserialized objects nested within the data.__wakeup
externally fromResourceStorage
(a workaround approach).__wakeup
inCompileInjector
(a more permanent solution).Given this context, it seems prudent to consider these approaches to ensure robustness in the serialization and deserialization processes. If you would like, I can assist in drafting more detailed documentation on this behavior or help explore a redesign that minimizes reliance on PHP's magic methods, which seems aligned with your initial intent to avoid such dependencies.
Please let me know how you would like to proceed or if there's any other way I can assist!
Analysis chain
Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 1835