Skip to content

Conversation

@tbradsha
Copy link
Contributor

@tbradsha tbradsha commented Nov 12, 2025

Closes MONOREP-221

This addresses PhanPossiblyUndeclaredVariable violations, skipping the following:

  • packages/block-delimiter
  • plugins/crm
  • plugins/super-cache
  • icalendar-reader and markdown libs

Fixes include:

  • Suppressions due to false positives (Phan sometimes gets confused when a var is defined under a specific condition, and later on is used under a different block gated by the same condition)
  • Declaring vars in an broader scope
  • Using null coalescence
  • Rearranging logic (projects/packages/backup/src/class-jetpack-backup.php and projects/plugins/jetpack/modules/subscriptions/views.php)
  • Adding fallback values with an else or default case

Edge cases aside, there was one actual bug in projects/plugins/vaultpress/vaultpress.php that may have prevented the Jetpack logo from showing.

Proposed changes:

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

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

Testing instructions:

The goal was to keep things as close to the original functionality as possible. CI should be happy.

@tbradsha tbradsha requested a review from a team November 12, 2025 21:58
@tbradsha tbradsha self-assigned this Nov 12, 2025
@tbradsha tbradsha added [Status] Needs Review This PR is ready for review. [Type] Janitorial labels Nov 12, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 12, 2025

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 or WordPress.com Site Helper), and enable the fix/phan/PhanPossiblyUndeclaredVariable branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack fix/phan/PhanPossiblyUndeclaredVariable
bin/jetpack-downloader test jetpack-mu-wpcom-plugin fix/phan/PhanPossiblyUndeclaredVariable

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 [Block] Story [Feature] Extra Sidebar Widgets [Feature] Photon aka "Image CDN". Feature developed in the Image CDN package and shipped in multiple plugins [Feature] Publicize Now Jetpack Social, auto-sharing [Feature] Shortcodes / Embeds [Feature] Subscriptions All subscription-related things such as paid and unpaid, user management, and newsletter settings. [Feature] WPCOM API [Package] Analyzer [Package] Backup [Package] Connection [Package] Image CDN [Package] Publicize [Package] Search Contains core Search functionality for Jetpack and Search plugins [Package] Sync [Package] VideoPress [Plugin] Boost A feature to speed up the site and improve performance. [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] VaultPress [Plugin] Wpcomsh [Tests] Includes Tests labels Nov 12, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 12, 2025

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 a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ 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: December 2, 2025

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


Vaultpress plugin:

No scheduled milestone found for this plugin.

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


Boost plugin:

  • Next scheduled release: November 26, 2025

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


Wpcomsh plugin:

  • Next scheduled release: Atomic deploys happen twice daily on weekdays (p9o2xV-2EN-p2)

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

@jp-launch-control
Copy link

jp-launch-control bot commented Nov 13, 2025

Code Coverage Summary

Coverage changed in 14 files. Only the first 5 are listed here.

File Coverage Δ% Δ Uncovered
projects/plugins/boost/app/lib/minify/class-concatenate-js.php 0/166 (0.00%) 0.00% 2 ❤️‍🩹
projects/plugins/jetpack/modules/widgets/flickr.php 0/107 (0.00%) 0.00% 2 ❤️‍🩹
projects/plugins/vaultpress/class.vaultpress-database.php 0/264 (0.00%) 0.00% 2 ❤️‍🩹
projects/packages/sync/src/modules/class-full-sync.php 0/239 (0.00%) 0.00% 1 ❤️‍🩹
projects/plugins/jetpack/class.jetpack.php 736/2266 (32.48%) -0.01% 1 ❤️‍🩹

Full summary · PHP report · JS report

if ( $site_id > -1 ) {
$author['site_ID'] = (int) $site_id;
$author['site_visible'] = $site_visible;
$author['site_visible'] = $site_visible ?? false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Any particular reason not to do this to preserve the current behavior?

Suggested change
$author['site_visible'] = $site_visible ?? false;
$author['site_visible'] = $site_visible ?? null;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This value seems to be a bool in normal cases, so I figured I'd match that in edge cases.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like before it was always null unless IS_WPCOM && ! $is_jetpack && $site_id > -1. 🤷

// Find which endpoint to serve.
$found = false;
$found = false;
$path_pieces = array();
Copy link
Contributor

Choose a reason for hiding this comment

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

You could probably leave this out. The suppression you're adding on line 591 for $endpoint should cover $path_pieces too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's true the suppression would cover it, but there are scenarios where it isn't defined (e.g. if the outer or inner for loop doesn't run through).

Copy link
Contributor

Choose a reason for hiding this comment

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

But in that case $endpoint won't be defined either. So why set one but not the other?

@tbradsha tbradsha requested a review from anomiex November 14, 2025 21:32
}

if ( ! $display_filters && empty( $instance['search_box_enabled'] ) && empty( $instance['user_sort_enabled'] ) ) {
if ( empty( $filters ) && empty( $instance['search_box_enabled'] ) && empty( $instance['user_sort_enabled'] ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

$filters will always exist, so you could just do like

Suggested change
if ( empty( $filters ) && empty( $instance['search_box_enabled'] ) && empty( $instance['user_sort_enabled'] ) ) {
if ( ! $filters && empty( $instance['search_box_enabled'] ) && empty( $instance['user_sort_enabled'] ) ) {

endif;

if ( $display_filters ) {
if ( ! empty( $filters ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same

Suggested change
if ( ! empty( $filters ) ) {
if ( $filters ) {

Template_Tags::render_widget_search_form( array(), '', '' );

if ( $display_filters ) {
if ( ! empty( $filters ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same

Suggested change
if ( ! empty( $filters ) ) {
if ( $filters ) {

if ( $site_id > -1 ) {
$author['site_ID'] = (int) $site_id;
$author['site_visible'] = $site_visible;
$author['site_visible'] = $site_visible ?? false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like before it was always null unless IS_WPCOM && ! $is_jetpack && $site_id > -1. 🤷

// Find which endpoint to serve.
$found = false;
$found = false;
$path_pieces = array();
Copy link
Contributor

Choose a reason for hiding this comment

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

But in that case $endpoint won't be defined either. So why set one but not the other?

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

Labels

[Block] Story [Feature] Extra Sidebar Widgets [Feature] Photon aka "Image CDN". Feature developed in the Image CDN package and shipped in multiple plugins [Feature] Publicize Now Jetpack Social, auto-sharing [Feature] Shortcodes / Embeds [Feature] Subscriptions All subscription-related things such as paid and unpaid, user management, and newsletter settings. [Feature] WPCOM API [Package] Analyzer [Package] Backup [Package] Connection [Package] Image CDN [Package] Publicize [Package] Search Contains core Search functionality for Jetpack and Search plugins [Package] Sync [Package] VideoPress [Plugin] Boost A feature to speed up the site and improve performance. [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] VaultPress [Plugin] Wpcomsh [Status] Needs Review This PR is ready for review. [Tests] Includes Tests [Type] Janitorial

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants