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

Check if object exists before accessing its properties. #52870

Merged
merged 3 commits into from
Jul 25, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/block-library/src/footnotes/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,12 @@ static function( $post ) {

if ( $_gutenberg_revision_id ) {
$revision = get_post( $_gutenberg_revision_id );
Copy link
Member

@ramonjd ramonjd Jul 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it's not part of this fix, but we could use wp_get_post_revision for its extra checks (there's no difference in functionality aside from that). Might be more explicit too.

Mentioned in Core patch here: WordPress/wordpress-develop#4892 (review)

$post_id = $revision->post_parent;

if ( ! $revision ) {
return;
}

$post_id = $revision->post_parent;

// Just making sure we're updating the right revision.
if ( $post->ID === $post_id ) {
Expand Down