[wp-trac] [WordPress Trac] #65400: WP_Query::get_queried_object() documented return values are incorrect

WordPress Trac noreply at wordpress.org
Wed Jun 3 14:26:41 UTC 2026


#65400: WP_Query::get_queried_object() documented return values are incorrect
-------------------------------------------------+-------------------------
 Reporter:  tommusrhodus                         |       Owner:  (none)
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  Awaiting
                                                 |  Review
Component:  Comments                             |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-unit-tests has-test-   |     Focuses:
  info                                           |
-------------------------------------------------+-------------------------
Changes (by tusharbharti):

 * keywords:  has-patch has-unit-tests => has-patch has-unit-tests has-test-
     info


Comment:

 == Reproduction Report
 === Description
 This report validates whether the issue can be reproduced.

 === Environment
 - WordPress: 7.1-alpha-62284
 - PHP: 8.3.31
 - Server: Apache/2.4.67 (Debian)
 - Database: mysqli (Server: 11.8.6-MariaDB-ubu2404 / Client: mysqlnd
 8.3.31)
 - Browser: Chrome 148.0.0.0
 - OS: macOS
 - Theme: Twenty Twenty 3.0
 - MU Plugins:
 - Plugins:
   * Gutenberg 23.3.0-rc.2
   * Test Reports 1.2.1

 === Actual Results
 1.  ✅ Error condition occurs (reproduced).

 === Additional Notes
 - Wrote test cases that can reproduce the condition mentioned by the
 author.

 {{{#!php
 <?php
         /**
          * @ticket 65400
          */
         public function
 test_get_queried_object_should_return_null_when_author_id_is_non_existent()
 {
                 add_action(
                         'parse_query',
                         static function ( $query ) {
                                 $query->is_author = true;
                                 $query->set( 'author', 999999 );
                         }
                 );

                 $this->go_to( home_url( '/' ) );

                 $this->assertNull( get_queried_object() );
         }

         /**
          * @ticket 65400
          */
         public function
 test_get_queried_object_should_return_null_when_author_is_unset() {
                 // Trigger is_author without a valid author query var.
                 add_action(
                         'parse_query',
                         static function ( $query ) {
                                 $query->is_author = true;
                         }
                 );

                 $this->go_to( home_url( '/' ) );

                 $this->assertNull( get_queried_object() );
         }
 }}}


 === Supplemental Artifacts
 [[Image(https://i.ibb.co/4gsVVJcM/image.png)]]

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/65400#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list