Skip to content

Subscriptions: Prevent warning when $post global is malformed#48074

Merged
tbradsha merged 2 commits intotrunkfrom
fix/subscriptions/address_warnings_in_the_wild
Apr 13, 2026
Merged

Subscriptions: Prevent warning when $post global is malformed#48074
tbradsha merged 2 commits intotrunkfrom
fix/subscriptions/address_warnings_in_the_wild

Conversation

@tbradsha
Copy link
Copy Markdown
Contributor

Proposed changes

We're getting some of these:

PHP Warning: Attempt to read property "ID" on array in /wordpress/plugins/jetpack/15.7/modules/subscriptions/subscribe-modal/class-jetpack-subscribe-modal.php on line 239

Because $post is a global, third-party code can and does sometimes modify it. This PR ensures it's a WP_Post before trying to use it.

Related product discussion/links

Does this pull request change what data or activity we track or use?

Testing instructions

Looking at the code is probably the easiest option.

@tbradsha tbradsha requested review from a team April 13, 2026 18:14
@tbradsha tbradsha self-assigned this Apr 13, 2026
@tbradsha tbradsha added the [Status] Needs Review This PR is ready for review. label Apr 13, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 13, 2026

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the fix/subscriptions/address_warnings_in_the_wild branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack fix/subscriptions/address_warnings_in_the_wild

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions github-actions Bot added [Feature] Subscriptions All subscription-related things such as paid and unpaid, user management, and newsletter settings. [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ labels Apr 13, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 13, 2026

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: May 5, 2026
    • Code freeze: May 4, 2026

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

Copy link
Copy Markdown
Contributor

@anomiex anomiex left a comment

Choose a reason for hiding this comment

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

Seems reasonable to me. I don't know if there's a more reliable way to get the post than the $post global.

@jp-launch-control
Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/plugins/jetpack/modules/subscriptions/subscribe-modal/class-jetpack-subscribe-modal.php 0/87 (0.00%) 0.00% 2 ❤️‍🩹

Full summary · PHP report · JS report

@tbradsha tbradsha merged commit 1c81fb6 into trunk Apr 13, 2026
76 checks passed
@tbradsha tbradsha deleted the fix/subscriptions/address_warnings_in_the_wild branch April 13, 2026 20:04
@github-actions github-actions Bot added this to the jetpack/15.8 milestone Apr 13, 2026
@github-actions github-actions Bot removed the [Status] Needs Review This PR is ready for review. label Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Subscriptions All subscription-related things such as paid and unpaid, user management, and newsletter settings. [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants