Skip to content

Conversation

@htdat
Copy link
Member

@htdat htdat commented Aug 21, 2019

Changes proposed in this Pull Request:

Similar to #13166, current_user_can only accepts object IDs as the optional second param; passing anything else (like an instance of Jetpack_Post like we did) will cause issues.

However, #13166 did not fix all wrong implementations so the same issue happens in 2184839-zen, then it was reported in 4206-gh-jpop-issues.

This PR is to correct all wrong implementations. In fact, only changes in sal/class.json-api-post-base.php is enough to fix this fatal error. However, I've tried my best, then found out other wrong implementations in json-endpoints/class.wpcom-json-api-post-endpoint.php.

Testing instructions:

  • Connect your test site to WordPress.com.
  • Install the Polylang plugin (it's OK to use the free version for replicate this issue)
  • Add at least two languages
  • Create the "Privacy" page in WP Admin -> Settings -> Privacy.
  • Create a translation of the "Privacy" page
  • Visit https://wordpress.com/pages/site.com
  • Check PHP error log, make sure you do not see this fatal error:
PHP Catchable fatal error: Object of class Jetpack_Post could not be converted to string in /wp-content/plugins/polylang-pro/include/filters.php on line 305 

Proposed changelog entry for your changes:

  • WordPress.com API: avoid Fatal Errors, which are caused by current_user_can(), when fetching posts from the mobile apps

@htdat htdat added [Type] Bug When a feature is broken and / or not performing as intended [Feature] WPCOM API [Status] Needs Review This PR is ready for review. labels Aug 21, 2019
@htdat htdat requested a review from a team August 21, 2019 13:39
@matticbot matticbot added Customer Report [LEGACY] Issues or PRs that were reported via Happiness. aka "Happiness Request", or "User Report" Touches WP.com Files labels Aug 21, 2019
@matticbot
Copy link
Contributor

Caution: This PR has changes that must be merged to WordPress.com
Hello htdat! These changes need to be synced to WordPress.com - If you 're an a11n, please commandeer, review, and approve D31773-code before merging this PR. Thank you!

@jetpackbot
Copy link
Collaborator

Thank you for the great PR description!

When this PR is ready for review, please apply the [Status] Needs Review label. If you are an a11n, please have someone from your team review the code if possible. The Jetpack team will also review this PR and merge it to be included in the next Jetpack release.

Scheduled Jetpack release: September 3, 2019.
Scheduled code freeze: August 27, 2019

Generated by 🚫 dangerJS against aa126c2

@jeherve jeherve added this to the 7.7 milestone Aug 21, 2019
@jeherve jeherve added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review This PR is ready for review. labels Aug 21, 2019
Copy link
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.

Thanks for taking care of this! 👍

@jeherve jeherve merged commit f45fad2 into master Aug 21, 2019
@jeherve jeherve deleted the fix/fatal-current-user-can branch August 21, 2019 14:00
@matticbot matticbot added [Status] Needs Changelog and removed [Status] Ready to Merge Go ahead, you can push that green button! labels Aug 21, 2019
jeherve added a commit that referenced this pull request Aug 23, 2019
jeherve added a commit that referenced this pull request Aug 27, 2019
* 7.7 changelog: initial set of changes

* Changelog: add #13154

* Changelog: add #13134

* Changelog: add #12699 and many others

* Changelog: add #13127

* Changelog: add #13167

* Changelog: add #13225

* Changelog: add #13179

* Changelog: add #13173

* Changelog: add #13232

* Changelog: add #13137

* Changelog: add #13172

* Changelog: add #13182

* Changelog: add #13200

* Changelog: add #13244

* Changelog: add #13267

* Changelog: add #13204

* changelog: add #13205

* Changelog: add #13183

* Changelog: add #13278

* Changelog: add #13162

* Changelog: add #13268

* Changelog: add #13286

* Changelog: add #13273

* Changelog: add #12474

* Changelog: add #13085

* Changelog: add #13266

* Changelog: add #13306

* Changelog: add #13311

* Changelog: add #13302

* Changelog: add #13196

* Changelog: add #12733

* Changelog: add #13261

* Changelog: add #13322

* Changelog: add #13333

* Changelog: add #13335
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Customer Report [LEGACY] Issues or PRs that were reported via Happiness. aka "Happiness Request", or "User Report" [Feature] WPCOM API Touches WP.com Files [Type] Bug When a feature is broken and / or not performing as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants