-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Bug: PHP notice when an image with lightbox is deleted #55370
Bug: PHP notice when an image with lightbox is deleted #55370
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, Liked your short and optimal solution. I have updated the PR.
Thanks @ramonjd
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.
Thank you for working on this!
Looks good to me, but maybe @artemiomorales should run an eye past it just to be sure.
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! 👍
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 <[email protected]> * 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 <[email protected]> Co-authored-by: Aki Hamano <[email protected]> Co-authored-by: Marco Ciampini <[email protected]> Co-authored-by: Jonny Harris <[email protected]> Co-authored-by: Andrew Serong <[email protected]> Co-authored-by: Kishan Jasani <[email protected]>
wp_get_attachment_metadata
return 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
.