[wp-trac] [WordPress Trac] #37530: is_front_page() is based on wrong data -> gives wrong results

WordPress Trac noreply at wordpress.org
Mon Jun 23 23:41:26 UTC 2025


#37530: is_front_page() is based on wrong data -> gives wrong results
-------------------------------------------------+-------------------------
 Reporter:  TheInfinity                          |       Owner:  (none)
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  Future
                                                 |  Release
Component:  Query                                |     Version:  4.5.3
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch needs-testing needs-unit-  |     Focuses:
  tests needs-test-info reporter-feedback        |
-------------------------------------------------+-------------------------
Changes (by SirLouen):

 * keywords:  has-patch needs-testing needs-unit-tests =>
     has-patch needs-testing needs-unit-tests needs-test-info reporter-
     feedback


Comment:

 == Combined Reproduction and Patch Test Report
 === Description
 ❌ This report can't validate that the patch is working as expected

 === Environment
 - WordPress: 6.9-alpha-60093-src
 - PHP: 8.2.28
 - Server: nginx/1.27.5
 - Database: mysqli (Server: 8.4.5 / Client: mysqlnd 8.2.28)
 - Browser: Chrome 137.0.0.0
 - OS: Windows 10/11
 - Theme: Twenty Twenty 2.9
 - MU Plugins: None activated
 - Plugins:
   * Front Page Query Checker 1.0.0
   * Test Reports 1.2.0

 === Reproduction Steps
 1. Get the code in artifacts, add it to a plugin, functions.php or
 wherever it can be executed
 2. Add a Page
 3. Set that page as Front Page in Settings Reading
 4. Go to the homepage
 5. Check the server error log
 6. 🐞 No error pops in the log, so theoretically the conditions are not
 being targeted according to the reporter.

 === Expected Results
 - With the given code, theoretically, an error should appear in log as the
 condition is being fulfilled?

 === Actual Results with the Patch
 1.  ❌ Error is still not popping in the log.
 This is what  I'm getting on debug for that condition introduced. Two out
 of 3 conditions are going to fail:
 [[Image(https://i.imgur.com/dz59Ivg.png)]]

 === Additional Notes
 - I'm not 100% convinced if I'm looking at the right, place, this is why
 I'm providing precise steps, so either `reporter-feedback`for reporter
 @TheInfinity is required, or `needs-test-info`for the patch creator @dots
 could confirm, or tell me where I'm wrong.

 - Not 100% sure but I think what needs some revisiting could be
 `WP_Query::is_page`

 - I think this is mostly what other people have been suggesting with "unit
 tests". Asking for unit tests has been historically the elegant way of
 asking for a [https://make.wordpress.org/test/2025/05/15/building-the-
 testing-use-case/#comment-3314 Testing Use Case]

 === Supplemental Artifacts
 Test Code
 {{{
 function front_page_query_modifier($query) {
     if ($query->is_main_query() && $query->is_front_page() ) {
         error_log('Front page is being targeted');
     }
     return $query;
 }
 add_action('pre_get_posts', 'front_page_query_modifier');
 }}}

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


More information about the wp-trac mailing list