Skip to content
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

Phan: Fix errant extra params in function calls #41263

Merged
merged 19 commits into from
Jan 31, 2025
Merged

Conversation

tbradsha
Copy link
Contributor

@tbradsha tbradsha commented Jan 22, 2025

This cleans up PhanParamTooMany errors.

Proposed changes:

After cleaning up the single instance of PhanParamTooFewInternal in #41247, I decided to have a look at the inverse issue, PhanParamTooMany.

Issues fixed include:

  • extra param on remove_filter/remove_action
  • extra param from rest_ensure_response
  • stray args left over from refactors
  • errant get_avatar_url calls
  • errant use of arrayHasKey instead of assertArrayHasKey
  • misplaced parentheses
  • loose types
  • a missing sprintf
  • periodic Phan confusion

This PR addresses all but the following three instances of the error:

  1. projects/plugins/crm/api/companies.php:70: separate PR forthcoming
  2. projects/plugins/jetpack/extensions/blocks/cookie-consent/cookie-consent.php:48: handled in Fix cookie consent registration call #41257
  3. projects/plugins/boost/wp-js-data-sync.php: the fix for this looks simple (remove the param), but it seems like it should be doing something more and I'd like some more eyes on it

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:

Is the CI content?

@tbradsha tbradsha added [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. [Type] Janitorial labels Jan 22, 2025
@tbradsha tbradsha requested a review from a team January 22, 2025 20:36
@tbradsha tbradsha self-assigned this Jan 22, 2025
@tbradsha tbradsha requested a review from a team as a code owner January 22, 2025 20:36
Copy link
Contributor

github-actions bot commented Jan 22, 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 WordPress.com Simple 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, and enable the fix/phan/PhanParamTooMany branch.

    • For jetpack-mu-wpcom changes, also add define( 'JETPACK_MU_WPCOM_LOAD_VIA_BETA_PLUGIN', true ); to your wp-config.php file.
  • To test on Simple, run the following command on your sandbox:

    bin/jetpack-downloader test jetpack fix/phan/PhanParamTooMany
    
    bin/jetpack-downloader test jetpack-mu-wpcom-plugin fix/phan/PhanParamTooMany
    

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

That function doesn't allow a status code to be passed. Presumably we could override the WP_REST_Response status and force 200, but passing it through has worked so far, so keeping it that way.
In most cases, these appear to be due to refactors.
We're using `WP_Option`, which allows an extra param in its `get()`.
@tbradsha tbradsha force-pushed the fix/phan/PhanParamTooMany branch from 9e85fc4 to a584a6a Compare January 31, 2025 16:36
Copy link
Contributor

github-actions bot commented Jan 31, 2025

Code Coverage Summary

This PR did not change code coverage!

That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷

Full summary · PHP report · JS report

@github-actions github-actions bot added [Feature] Masterbar WordPress.com Toolbar and Dashboard customizations [Feature] Publicize Now Jetpack Social, auto-sharing [Package] Masterbar [Package] Publicize [Package] Stats Admin labels Jan 31, 2025
Copy link
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.

LGTM

@tbradsha tbradsha merged commit 4b2a4a9 into trunk Jan 31, 2025
80 checks passed
@tbradsha tbradsha deleted the fix/phan/PhanParamTooMany branch January 31, 2025 18:59
@github-actions github-actions bot removed the [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. label Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Admin Page React-powered dashboard under the Jetpack menu [CRM] WooSync Module [Feature] Contact Form [Feature] Extra Sidebar Widgets [Feature] Infinite Scroll [Feature] Markdown [Feature] Masterbar WordPress.com Toolbar and Dashboard customizations [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] Theme Tools [Feature] WPCOM API [Focus] Compatibility Ensuring our products play well with third-parties [mu wpcom Feature] Verbum Comments Verbum, a better comment experience, app developed in the mu-wpcom plugin [Package] Boost Core [Package] Connection [Package] Forms [Package] Image CDN [Package] Jetpack mu wpcom WordPress.com Features [Package] Masterbar [Package] My Jetpack [Package] Protect Status [Package] Publicize [Package] Schema [Package] Stats Admin [Package] Stats Data [Package] Status [Package] Sync [Package] VideoPress [Package] WAF [Plugin] Boost A feature to speed up the site and improve performance. [Plugin] CRM Issues about the Jetpack CRM plugin [Plugin] Debug Helper Debug Tools plugin [Plugin] Inspect [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Protect A plugin with features to protect a site: brute force protection, security scanning, and a WAF. [Plugin] VaultPress [Tests] Includes Tests [Type] Janitorial
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants