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

Fix reusable block endless loop #3882

Merged
merged 2 commits into from Dec 11, 2017

Conversation

Projects
None yet
3 participants
@jaswrks
Contributor

jaswrks commented Dec 8, 2017

Resolves: #3880

When $attributes['ref'] is empty, get_post() returns
the current post by default; i.e., the post you're editing,
which is obviously not a wp_block post type. That results in
an unanticipated scenario, such as an endless loop.

Corrected by making sure $attributes['ref'] is not empty,
and that get_post() does indeed return a wp_block post type.

Jason Caldwell
Fix reusable block endless loop
Resolves: #3880

When `$attributes['ref']` is empty, `get_post()` returns
the *current* post by default; i.e., the post you're editing,
which is obviously not a `wp_block` post type. That results in
a completely unanticipated scenario, such as an endless loop.

Corrected by making sure `$attributes['ref']` is not empty,
and that `get_post()` does indeed return a `wp_block` post type.

@noisysocks noisysocks self-requested a review Dec 10, 2017

@noisysocks

noisysocks requested changes Dec 11, 2017 edited

Nice work! The extra sanity checking here should come in useful.

Note that #3879 fixes the root cause of this bug.

Show outdated Hide outdated blocks/library/block/index.php
Show outdated Hide outdated blocks/library/block/index.php

@noisysocks noisysocks merged commit 80d04f8 into WordPress:master Dec 11, 2017

2 checks passed

codecov/project 38.21% (+0.01%) compared to a655f57
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@aduth

This comment has been minimized.

Show comment
Hide comment
@aduth

aduth Dec 11, 2017

Member

Should we have tests for each of these two added conditions?

Member

aduth commented Dec 11, 2017

Should we have tests for each of these two added conditions?

jaswrks pushed a commit to jaswrks/gutenberg that referenced this pull request Jan 19, 2018

Jason Caldwell

@jaswrks jaswrks referenced this pull request Jan 19, 2018

Merged

Add reusable block render tests #4608

3 of 3 tasks complete
@jaswrks

This comment has been minimized.

Show comment
Hide comment
@jaswrks

jaswrks Jan 19, 2018

Contributor

@aduth Sorry, I missed your comment somehow:

Should we have tests for each of these two added conditions?

Tests added in #4608

Contributor

jaswrks commented Jan 19, 2018

@aduth Sorry, I missed your comment somehow:

Should we have tests for each of these two added conditions?

Tests added in #4608

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment