-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Use instanceOf over property_exists. #54835
Conversation
This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress. If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core Github repository soon after this pull request is merged. If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack. Thank you! ❤️ View changed files❔ lib/block-supports/border.php ❔ lib/block-supports/colors.php ❔ lib/block-supports/typography.php ❔ lib/class-wp-duotone-gutenberg.php |
I’d be also great to verify whether charges from WordPress/wordpress-develop@e77aaf1 got backported, too. |
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.
Changes LGTM 👍
One thing that I did notice was the difference in files between this PR and the core patch.
Looking closer at the class-wp-duotone-gutenberg.php
file it seems to differ from core.
Was there something that should have been backported from core to Gutenberg?
One thing that is different, is that in Gutenberg we use the null coalescing operator in many places. In Core this has not been accepted yet, so where
|
This needs to be backported. But that is out of scope this this ticket. |
Thanks for the extra info @spacedmonkey & @aristath 👍 For the record, what caught my eye was that we had to update the duotone class here in Gutenberg but not in core as the |
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.
Looking through this it seems all the changes to files under block-supports/
dir are backported.
Looks like this was done in WordPress/wordpress-develop#5308.
However there is a mismatch between the class-wp-duotone-*
files in Gutenberg and Core.
I'm unsure as to why this is and whether anything is outstanding in terms of backports. I'd be grateful for your input here @spacedmonkey @aaronrobertshaw.
if ( property_exists( $block_type, 'supports' ) ) { | ||
if ( $block_type instanceof WP_Block_Type ) { |
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 line doesn't seem to appear at all in WP Core
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.
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.
So is there a missing backport on this PR. Should we consider it done. It's very unfortunate that the code between core and Gutenberg for block supports have diverged this much.
We should either do:
- Have the exact same code and use a package (like the block-library) sync
- Remove the block supports from Gutenberg (consider that they're now maintained on Core)
It's probably something to do post release though.
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.
So to confirm, no further action on this and it can be marked as backported?
Should we consider it done.
Can I check whether you intended to write We should consider it done
?
if ( $block_type && property_exists( $block_type, 'supports' ) ) { | ||
if ( $block_type && $block_type instanceof WP_Block_Type ) { |
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.
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.
As with the previous code difference, I think the core version needed to be backported to Gutenberg. @spacedmonkey might have further context on why it wasn't.
✅ I updated this PR with the There was some uncertainty around the block supports element but that appears to be a wider issue relating to how Gutenberg and Core have become out of sync around these files. |
What?
Trac ticket: https://core.trac.wordpress.org/ticket/59453#ticket
instanceOf
is better performance thanproperty_exists
Why?
How?
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast