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

User Queries: update parameters to take into account changes in WP 5.9 #22559

Merged
merged 5 commits into from
Feb 3, 2022

Conversation

jeherve
Copy link
Member

@jeherve jeherve commented Jan 31, 2022

Fixes #22558

Changes proposed in this Pull Request:

In this core ticket, WP_User_Query was updated to accept a new parameter, capability, to look for specific users.
In turn, the who parameter (in use in Jetpack) was deprecated.

Let's support both parameters for now, with a note to get rid of the backwards compatible code once WordPress 5.9 is required to use Jetpack.

After auditing the codebase, those changes apply to 3 different areas of Jetpack:

Jetpack product discussion

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

  • No

Testing instructions:

  • Start with a site with a non-block theme, e.g. the Twenty Twenty theme.
  • Add multiple users to your site, with different roles, and publish posts with each user. A quick way to go about it could be to use a plugin like FakerPress to create multiple users and multiple posts at once.
  • Edit the name of the users that were created for you, under the Users menu in wp-admin. I would recommend giving subscriber roles a name you remember, for example, "sub", this way you can spot them easily later in the user lists.

Widget Visibility

  1. Go to Jetpack > Settings and ensure that the Widget Visibility feature is active.
  2. Go to Appearance > Widgets, add a paragraph block.
  3. In the block's right sidebar, open the Advanced panel.
  4. Add a visibility rule targetting authors
  5. Make sure only authors are listed there; subscribers and contributors should not be listed.

Authors Widget

  1. Go to Jetpack > Settings and ensure that the Extra sidebar widgets module is active
  2. Go to Appearance > Widgets and add an Authors widget to the site.
  3. Ensure the options work well.

WPCOM API

  1. Go to https://developer.wordpress.com/docs/api/console/
  2. In the search field search for "users". You should then be able to build a query for your test site. In the query parameters, ensure the Authors only option is set.

Screenshot 2022-01-31 at 10 09 17

  1. Ensure the results are correct.

Once you've done all that, you should not see any PHP notices when checking the site's error log.

Fixes #22558

In https://core.trac.wordpress.org/ticket/16841 , WP_User_Query was updated to accept a new parameter, capability, to look for specific users. In turn, the "who" parameter (in use in Jetpack) was deprecated. Let's support both parameters for now.
@matticbot
Copy link
Contributor

Caution: This PR has changes that must be merged to WordPress.com
Hello jeherve! These changes need to be synced to WordPress.com - If you 're an a11n, please commandeer and confirm D74041-code works as expected before merging this PR. Once this PR is merged, please commit the changes to WP.com. Thank you!
This revision will be updated with each commit to this PR

@github-actions github-actions bot added the [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ label Jan 31, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Jan 31, 2022

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.
  • ✅ All commits were linted before commit.
  • ✅ Add a "[Status]" label (In Progress, Needs Team 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 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped.
Then, add the "[Status] Needs Team review" label and ask someone from your team review the code.
Once you’ve done so, switch to the "[Status] Needs Review" label; someone from Jetpack Crew will then review this PR and merge it to be included in the next Jetpack release.


Jetpack plugin:

  • Next scheduled release: March 1, 2022.
  • Scheduled code freeze: February 22, 2022.

@jeherve jeherve mentioned this pull request Jan 31, 2022
12 tasks
@jeherve jeherve added [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. and removed [Status] In Progress labels Jan 31, 2022
@samiff samiff self-requested a review February 2, 2022 18:20
Copy link
Contributor

@samiff samiff left a comment

Choose a reason for hiding this comment

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

All three scenarios tested well for me, great testing instructions 👍

@jeherve Is there a specific way you manage/remember the "todo" tasks like this?

@samiff samiff added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. labels Feb 2, 2022
@jeherve
Copy link
Member Author

jeherve commented Feb 3, 2022

Is there a specific way you manage/remember the "todo" tasks like this?

I don't know that I have great tips about this. When the time comes to look at updating WordPress requirements for Jetpack, I look for all instances of "WordPress x.x", "x.x", in the codebase, see what comes up. So I guess the most important to me is to add an inline comment mentioning the WordPress version, so it's easier to find afterwards.

@jeherve jeherve merged commit fdecb31 into master Feb 3, 2022
@jeherve jeherve deleted the fix/widget-visibility-deprecation branch February 3, 2022 08:14
@github-actions github-actions bot removed the [Status] Ready to Merge Go ahead, you can push that green button! label Feb 3, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2022

Great news! One last step: head over to your WordPress.com diff, D74041-code, and commit it.
Once you've done so, come back to this PR and add a comment with your changeset ID.

Thank you!

@jeherve
Copy link
Member Author

jeherve commented Feb 3, 2022

r239482-wpcom

jeherve added a commit that referenced this pull request May 3, 2022
…s WP 5.9 (#24086)

* General: remove backwards compatibility code for user queries

See #22559

* Update PHPUnit setup to remove WP < 5.9 oddities

See #21175, #21157

Primary issue: #24082

* Update docs/examples/bootstrap.php

Co-authored-by: Brad Jorsch <[email protected]>

* Remove speed trap listener loder

* Update doc to remove mention of temporary PHPUnit situation

* Remove temporary line break workaround

See #15595

* Remove custom function in favor of the one that ships with core

* Remove old workaround for the Jetpack sidebar plugin icon

See #14327

* Remove PHP 5.2 workaround

See 99fffd8

* Add back necessary _wp_specialchars wrapping

Co-authored-by: Brad Jorsch <[email protected]>
Co-authored-by: Brandon Kraft <[email protected]>
jeherve added a commit that referenced this pull request May 19, 2022
…Jetpack requires WP 5.9 (#24086)

* General: remove backwards compatibility code for user queries

See #22559

* Update PHPUnit setup to remove WP < 5.9 oddities

See #21175, #21157

Primary issue: #24082

* Update docs/examples/bootstrap.php

Co-authored-by: Brad Jorsch <[email protected]>

* Remove speed trap listener loder

* Update doc to remove mention of temporary PHPUnit situation

* Remove temporary line break workaround

See #15595

* Remove custom function in favor of the one that ships with core

* Remove old workaround for the Jetpack sidebar plugin icon

See #14327

* Remove PHP 5.2 workaround

See 99fffd8

* Add back necessary _wp_specialchars wrapping

Co-authored-by: Brad Jorsch <[email protected]>
Co-authored-by: Brandon Kraft <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Extra Sidebar Widgets [Feature] Widget Visibility [Feature] WPCOM API [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Pri] Normal 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.

Widget Visibility: WP_User_Query deprecation notice
3 participants