-
Notifications
You must be signed in to change notification settings - Fork 382
Make parameters to Gutenberg filter callbacks more robust #5866
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
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #5866 +/- ##
==========================================
Coverage 75.15% 75.15%
- Complexity 5657 5663 +6
==========================================
Files 210 210
Lines 16987 17015 +28
==========================================
+ Hits 12766 12788 +22
- Misses 4221 4227 +6
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Plugin builds for 0a58352 are ready 🛎️!
|
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.
LGTM, but I defer to @delawski for final review.
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.
@pierlon This looks good to me. I left a couple of very minor and optional comments.
assets/src/block-editor/components/with-media-library-notice.js
Outdated
Show resolved
Hide resolved
assets/src/common/components/higher-order/with-featured-image-notice.js
Outdated
Show resolved
Hide resolved
@@ -266,6 +275,10 @@ export const getLayoutOptions = ( block ) => { | |||
* @return {Function} Edit function. | |||
*/ | |||
export const filterBlocksEdit = ( BlockEdit ) => { | |||
if ( ! isObject( BlockEdit ) ) { |
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.
In light of the latest updates, should this also be changed to isFunction()
? It looks that the BlockEdit
is always a function.
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.
Yes good catch. Done in 0a58352.
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.
Looks good to me 👍
@pierlon This doesn't cherry-pick cleanly into |
@westonruter Should I open a PR specifically for |
I don't think anyone is reporting this as a problem in 2.0.x so it may not be needed. @jamesozzie or @milindmore22 may be able to indicate otherwise. |
I have trouble figuring out how to specifically trigger this issue for QA testing, as I don't know what combination of Gutenberg and AMP Plugin versions were initially conflicting. @pierlon Do you remember more details? |
@schlessera I wasn't able to determine what Gutenberg/AMP plugin combo caused the bug, unfortunately. The quickest way I can think of to replicate the error could be something like: let _element;
addFilter( 'blocks.getSaveElement', 'hijack/invalid', ( element ) => {
_element = element;
return null;
}, 9 );
addFilter( 'blocks.getSaveElement', 'hijack/valid', () => _element, 11 ); |
Summary
Fixes a reported issue on the support forums, where depending on the Gutenberg version editing a post could produce an error like:
Checklist