Skip to content

Related Posts: Only attempt to grab related posts for Published posts.#9495

Merged
dereksmart merged 1 commit intomasterfrom
fix/9494
May 14, 2018
Merged

Related Posts: Only attempt to grab related posts for Published posts.#9495
dereksmart merged 1 commit intomasterfrom
fix/9494

Conversation

@kraftbj
Copy link
Copy Markdown
Contributor

@kraftbj kraftbj commented May 6, 2018

Fixes #9494

Attempting to grab Related Posts for an unpublished post doesn't really make sense for our use case as we could cache the result for a post that changes drastically before publishing.

Changelog entry

Related Posts: Made it not try to fetch related posts for an unpublished post.

@kraftbj kraftbj added Bug When a feature is broken and / or not performing as intended [Feature] Related Posts [Status] Needs Review This PR is ready for review. labels May 6, 2018
@kraftbj kraftbj requested a review from a team as a code owner May 6, 2018 03:23
Copy link
Copy Markdown
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

Looking good, just some minor nitpicking on my part.

}

if ( ! $options['enabled'] || 0 == (int)$post_id || empty( $options['size'] ) )
if ( ! $options['enabled'] || 0 == (int)$post_id || empty( $options['size'] ) || get_post_status( $post_id) !== 'publish' ) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You may want to use a Yoda condition here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I didn't think we needed a Yoda since we're not dealing with a variable?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That works for me. I would personally use a Yoda for consistency, but it's really nitpicking. Marking as ready to merge. 👍

@jeherve jeherve added [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. and removed [Status] Needs Review This PR is ready for review. labels May 8, 2018
@oskosk oskosk added this to the 6.2 milestone May 8, 2018
@jeherve jeherve added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels May 9, 2018
Copy link
Copy Markdown
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

Good to merge!

@matticbot
Copy link
Copy Markdown
Contributor

Created a new revision for this PR: D13102-code

@dereksmart dereksmart merged commit 40771ff into master May 14, 2018
@dereksmart dereksmart deleted the fix/9494 branch May 14, 2018 18:38
@ghost ghost removed the [Status] Ready to Merge Go ahead, you can push that green button! label May 14, 2018
@matticbot
Copy link
Copy Markdown
Contributor

Created a new revision for this PR: D13259-code

@matticbot matticbot added [Status] Needs Changelog Bug When a feature is broken and / or not performing as intended [Feature] Related Posts Touches WP.com Files labels May 28, 2018
oskosk added a commit that referenced this pull request May 28, 2018
kraftbj added a commit that referenced this pull request Mar 13, 2019
The regressed the fix added in #9495 and breaks the jetpack_relatedposts_filter_options filter's use of "enabled".

This reverts commit 237c30f.
kraftbj added a commit that referenced this pull request Mar 26, 2019
* Revert "Removing enabled and published checks"

The regressed the fix added in #9495 and breaks the jetpack_relatedposts_filter_options filter's use of "enabled".

This reverts commit 237c30f.

* Add strict check

* Increase readability and PHPCS for the changed function

* Remove check for published posts to allow previews to render RPs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug When a feature is broken and / or not performing as intended [Feature] Related Posts Touches WP.com Files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants