Skip to content

Conversation

@westonruter
Copy link
Member

@westonruter westonruter commented Nov 10, 2025

This avoids a deprecation warning in PHP 8.5:

Using null as an array offset is deprecated, use an empty string instead

/var/www/src/wp-includes/class-wp-date-query.php:516
/var/www/src/wp-includes/class-wp-date-query.php:170
/var/www/src/wp-includes/class-wp-query.php:2138
/var/www/src/wp-includes/class-wp-query.php:3958
/var/www/src/wp-includes/class-wp.php:704
/var/www/src/wp-includes/class-wp.php:824
/var/www/tests/phpunit/includes/abstract-testcase.php:1346
/var/www/tests/phpunit/includes/testcase-canonical.php:303
/var/www/tests/phpunit/tests/canonical.php:68
/var/www/vendor/bin/phpunit:122

Specifically, the issue is that $wpdb->blogs is null when not on a single-site install. So this ensures that the $wpdb->blogs column is only added to the $known_columns array when on multisite.

It also updates the $valid_columns array to only include multisite-related columns when on multisite, namely registered and last_updated.

Note

Some multisite columns appear to not have been accounted for: wp_blog_versions.last_updated, wp_registration_log.date_registered, and wp_signups.activated.

Lastly, the phpdoc @var tags for $wpdb->blogs, $wpdb->blogmeta, and the other multisite-specific tables have been updated to indicate they may be null.

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.

@github-actions
Copy link

github-actions bot commented Nov 10, 2025

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props westonruter, desrosj.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@westonruter westonruter requested a review from desrosj November 10, 2025 20:00
Copy link
Member

@desrosj desrosj left a 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() ) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if ( is_multisite() ) {
if ( is_multisite() ) {

),
$wpdb->blogs => array(
);
if ( is_multisite() ) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if ( is_multisite() ) {
if ( is_multisite() ) {

@westonruter
Copy link
Member Author

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.

Cool. I'll apply when committing.

@desrosj
Copy link
Member

desrosj commented Nov 10, 2025

I changed the PR description to point to Core-63957 since that's the more specific issue being addressed here.

@github-actions
Copy link

Test using WordPress Playground

The 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

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

pento pushed a commit that referenced this pull request Nov 10, 2025
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
@github-actions
Copy link

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 61191
GitHub commit: e504c71

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions bot closed this Nov 10, 2025
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Nov 10, 2025
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
github-actions bot pushed a commit to gilzow/wordpress-performance that referenced this pull request Nov 10, 2025
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
xxsimoxx pushed a commit to xxsimoxx/ClassicPress that referenced this pull request Nov 13, 2025
…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.
mattyrob pushed a commit to ClassicPress/ClassicPress that referenced this pull request Nov 15, 2025
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants