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

Avoid getting the theme if we have it already #14894

Merged
merged 2 commits into from Mar 30, 2023

Conversation

NoResponseMate
Copy link
Contributor

Q A
Branch? 1.13
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Related tickets replaces #11755
License MIT

Just finishing it up.

Kudos to @jacquesbh for catching and fixing this huge waste of resources 🍻

@NoResponseMate NoResponseMate added Enhancement Minor issues and PRs improving the current solutions (optimizations, typo fixes, etc.). DX Issues and PRs aimed at improving Developer eXperience. labels Mar 27, 2023
@NoResponseMate NoResponseMate requested a review from a team as a code owner March 27, 2023 14:37
@jacquesbh
Copy link
Member

Nice! Finally!

@@ -22,26 +22,31 @@

final class ChannelBasedThemeContext implements ThemeContextInterface
{
private null|false|ThemeInterface $theme = false;
Copy link
Contributor

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.

Copy link
Member

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.

Copy link
Contributor

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 😄

Copy link
Contributor

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.

Copy link
Member

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 😂

@GSadee GSadee merged commit b4ee5ae into Sylius:1.13 Mar 30, 2023
22 checks passed
@GSadee
Copy link
Member

GSadee commented Mar 30, 2023

Thank you, Jan and Jacques! 🥇

@NoResponseMate NoResponseMate deleted the dx/reduce-fetching-theme branch September 22, 2023 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DX Issues and PRs aimed at improving Developer eXperience. Enhancement Minor issues and PRs improving the current solutions (optimizations, typo fixes, etc.).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants