Fix Cp helper class for frankendphp worker mode #16848
Merged
brandonkelly merged 1 commit intocraftcms:5.7from Mar 7, 2025
Merged
Fix Cp helper class for frankendphp worker mode #16848brandonkelly merged 1 commit intocraftcms:5.7from
brandonkelly merged 1 commit intocraftcms:5.7from
Conversation
Member
|
Thanks! Renamed to |
Member
|
Craft 5.7.0 is out with that change. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
I was testing frankenphp worker mode with Craft CMS and I found a problem that I don't think has a solution without some changes to Craft.
Basically the
craft\helpers\Cpclass has a static property of the requested site and it's only set once. If it's already set the property is returned. This is causing the sites dropdown to basically not work without restarting the worker.The property It's also private and not nullable, so I can't do much from outside.
The changes:
• Static properties cannot be unset, so I updated the type hint of the
$_requestedSiteto be nullable. The functionrequestedSite()returns a nullable anyway, so maybe, it might even make sense.• Then I updated the if in the
requestedSite()function to set the variable only when it's null instead of uninitialized.• I added a public function to clear the requested site, setting it to null. In this way I can call the function from outside at the start of each request to be sure that the correct site will be used.
Thanks.