-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Account for non-multisite installs in WP_Date_Query::validate_column() to fix PHP 8.5 deprecation notice
#10498
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
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
desrosj
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @westonruter! I think this looks good provided the tests pass.
Added a few small nits. I don't think it's in the coding standards, but I prefer to have an empty line before a control structures.
| 'comment_date_gmt', // Part of $wpdb->comments. | ||
| 'user_registered', // Part of $wpdb->users. | ||
| ); | ||
| if ( is_multisite() ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if ( is_multisite() ) { | |
| if ( is_multisite() ) { |
| ), | ||
| $wpdb->blogs => array( | ||
| ); | ||
| if ( is_multisite() ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if ( is_multisite() ) { | |
| if ( is_multisite() ) { |
Cool. I'll apply when committing. |
|
I changed the PR description to point to Core-63957 since that's the more specific issue being addressed here. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
This avoids using multisite-specific tables and columns in `WP_Date_Query::validate_column()` when on a non-multisite install. Attempting to use `$wpdb->blogs` as an array index when `null` on a non-multisite install causes a deprecation notice in PHP 8.5. This also updates the multisite table alias in `wpdb` to make it clear they could be `null`. Developed in #10498 Follow-up to [60904], [60809], [37477]. Props westonruter, desrosj. See #63061. Fixes #63957. git-svn-id: https://develop.svn.wordpress.org/trunk@61191 602fd350-edb4-49c9-b593-d223f7449a82
This avoids using multisite-specific tables and columns in `WP_Date_Query::validate_column()` when on a non-multisite install. Attempting to use `$wpdb->blogs` as an array index when `null` on a non-multisite install causes a deprecation notice in PHP 8.5. This also updates the multisite table alias in `wpdb` to make it clear they could be `null`. Developed in WordPress/wordpress-develop#10498 Follow-up to [60904], [60809], [37477]. Props westonruter, desrosj. See #63061. Fixes #63957. Built from https://develop.svn.wordpress.org/trunk@61191 git-svn-id: http://core.svn.wordpress.org/trunk@60527 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This avoids using multisite-specific tables and columns in `WP_Date_Query::validate_column()` when on a non-multisite install. Attempting to use `$wpdb->blogs` as an array index when `null` on a non-multisite install causes a deprecation notice in PHP 8.5. This also updates the multisite table alias in `wpdb` to make it clear they could be `null`. Developed in WordPress/wordpress-develop#10498 Follow-up to [60904], [60809], [37477]. Props westonruter, desrosj. See #63061. Fixes #63957. Built from https://develop.svn.wordpress.org/trunk@61191 git-svn-id: https://core.svn.wordpress.org/trunk@60527 1a063a9b-81f0-0310-95a4-ce76da25c4cd
…ray offset. This avoids using multisite-specific tables and columns in `WP_Date_Query::validate_column()` when on a non-multisite install. Attempting to use `$wpdb->blogs` as an array index when `null` on a non-multisite install causes a deprecation notice in PHP 8.5. This also updates the multisite table alias in `wpdb` to make it clear they could be `null`. Developed in WordPress/wordpress-develop#10498 Follow-up to https://core.trac.wordpress.org/changeset/60904, https://core.trac.wordpress.org/changeset/60809, https://core.trac.wordpress.org/changeset/37477. WP:Props westonruter, desrosj. See https://core.trac.wordpress.org/ticket/63061. Fixes https://core.trac.wordpress.org/ticket/63957. --- Merges https://core.trac.wordpress.org/changeset/61191 / WordPress/wordpress-develop@e504c715ae to ClassicPress.
* WP-r61191: Code Modernization: Fix instances of using `null` as an array offset. This avoids using multisite-specific tables and columns in `WP_Date_Query::validate_column()` when on a non-multisite install. Attempting to use `$wpdb->blogs` as an array index when `null` on a non-multisite install causes a deprecation notice in PHP 8.5. This also updates the multisite table alias in `wpdb` to make it clear they could be `null`. Developed in WordPress/wordpress-develop#10498 Follow-up to https://core.trac.wordpress.org/changeset/60904, https://core.trac.wordpress.org/changeset/60809, https://core.trac.wordpress.org/changeset/37477. WP:Props westonruter, desrosj. See https://core.trac.wordpress.org/ticket/63061. Fixes https://core.trac.wordpress.org/ticket/63957. --- Merges https://core.trac.wordpress.org/changeset/61191 / WordPress/wordpress-develop@e504c715ae to ClassicPress. * Fix coding standards --------- Co-authored-by: Weston Ruter <westonruter@git.wordpress.org> Co-authored-by: xxsimoxx <simone@gieffeedizioni.it> CP:Props xxsimoxx, mattyrob
This avoids a deprecation warning in PHP 8.5:
Specifically, the issue is that
$wpdb->blogsisnullwhen not on a single-site install. So this ensures that the$wpdb->blogscolumn is only added to the$known_columnsarray when on multisite.It also updates the
$valid_columnsarray to only include multisite-related columns when on multisite, namelyregisteredandlast_updated.Note
Some multisite columns appear to not have been accounted for:
wp_blog_versions.last_updated,wp_registration_log.date_registered, andwp_signups.activated.Lastly, the phpdoc
@vartags for$wpdb->blogs,$wpdb->blogmeta, and the other multisite-specific tables have been updated to indicate they may benull.Trac ticket: https://core.trac.wordpress.org/ticket/63957
This issue was introduced in r37477 (3819309) for WordPress 4.6.0.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.