-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Avoid getting the theme if we have it already #14894
Conversation
Nice! Finally! |
@@ -22,26 +22,31 @@ | |||
|
|||
final class ChannelBasedThemeContext implements ThemeContextInterface | |||
{ | |||
private null|false|ThemeInterface $theme = false; |
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.
A separate property for boolean would be better IMO eg. $alreadyCalled
.
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.
I disagree. false
means "no theme", null
means not set, and the ThemeInterface
means we have one.
All 3 values are logical.
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.
Hmmm I see the difference between the 3 of them but no theme
also means nothing has been set yet, and not set
means there is no theme
so it's tricky at first glance – at least for me 😄
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.
Defaulting it to false is the closest thing PHP has to an is_initialized($this->prop);
type of check. If it's false, the property hasn't been initialized yet and whatever code needs to seed it needs to run. Once it's null or an object, it's initialized.
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.
I'm ok with the current implementation if anybody asks me 😂
Thank you, Jan and Jacques! 🥇 |
Just finishing it up.
Kudos to @jacquesbh for catching and fixing this huge waste of resources 🍻