Bug: PHP notice when an image with lightbox is deleted#55370
Bug: PHP notice when an image with lightbox is deleted#55370michalczaplinski merged 2 commits intoWordPress:trunkfrom
Conversation
| if ( ! empty( $img_metadata ) && is_array( $img_metadata ) ) { | ||
| $img_width = $img_metadata['width']; | ||
| $img_height = $img_metadata['height']; | ||
| } |
There was a problem hiding this comment.
This could cause an error. Since img_width and img_height won't be set, $img_metadata won't pass the conditions.
Undefined variable $img_width in /var/www/html/wp-content/plugins/gutenberg/build/block-library/blocks/image.php on line 216 Warning: Undefined variable $img_height in /var/www/html/wp-content/plugins/gutenberg/build/block-library/blocks/image.php on line 217
Maybe we could provide a default value like the below else statement.
| if ( ! empty( $img_metadata ) && is_array( $img_metadata ) ) { | |
| $img_width = $img_metadata['width']; | |
| $img_height = $img_metadata['height']; | |
| } | |
| $img_width = $img_metadata['width'] ?? 'none'; | |
| $img_height = $img_metadata['height'] ?? 'none'; |
There was a problem hiding this comment.
Hey @ramonjd, Thanks for the feedback. I already moved $img_width = 'none'; and $img_height = 'none'; out side of if statement. So, It won't throw error. I already checked the condition you mentioned with updated code.
Let me know, If I still need to make changes.
There was a problem hiding this comment.
By the way, Liked your short and optimal solution. I have updated the PR.
Thanks @ramonjd
There was a problem hiding this comment.
Thank you for working on this!
Looks good to me, but maybe @artemiomorales should run an eye past it just to be sure.
michalczaplinski
left a comment
There was a problem hiding this comment.
LGTM! 👍
Thank you @kishanjasani
|
@mikachan I think the same change should be done for the |
* Fix PHP notice when an image with lightbox is deleted * Fix PHP notice when an image with lightbox is deleted
|
I just cherry-picked this PR to the 6.4-rc1-2 branch to get it included in the next release: ab7369e |
* Add selector as id to layout style overrides. (#55291) * Fix flickering when focusing on global style variations (#55267) * ProgressBar: use text color to ensure enough contrast against background (#55285) * Use text color at different opacities for track and indicator * Add high contrast mode styles * CHANGELOG # Conflicts: # packages/components/CHANGELOG.md * Remove empty attrs. (#54496) * Remove empty attrs. * Fix linter errors --------- Co-authored-by: Sarah Norris <sarah@sekai.co.uk> * Add IS_GUTENBERG_PLUGIN flag to LastRevision (#55253) * useBlockPreview: Try outputting EditorStyles to ensure local style overrides are rendered (#55288) * useBlockPreview: Try alternative fix for displaying local style overrides * Avoid duplicate styles, fix rendering issues in Safari * Add more explanatory comments * Remove additional check for styles within the block preview, as it is not needed since EditorStyles handles its own style overrides retrieval * Bug: PHP notice when an image with lightbox is deleted (#55370) * Fix PHP notice when an image with lightbox is deleted * Fix PHP notice when an image with lightbox is deleted --------- Co-authored-by: tellthemachines <tellthemachines@users.noreply.github.com> Co-authored-by: Aki Hamano <54422211+t-hamano@users.noreply.github.com> Co-authored-by: Marco Ciampini <marco.ciampo@gmail.com> Co-authored-by: Jonny Harris <spacedmonkey@users.noreply.github.com> Co-authored-by: Andrew Serong <14988353+andrewserong@users.noreply.github.com> Co-authored-by: Kishan Jasani <kishanjasani007@yahoo.in>
wp_get_attachment_metadatareturn false if it has no metadata related to attachment, So, I added a condition to check before extrtacting the value from array. it help fixes: #55347Testing Instructions
Expand on Click:true.