Make WordPress Core

Opened 9 years ago

Last modified 8 weeks ago

#40521 new defect (bug)

Using a custom query var on a static front page results in wrong $post

Reported by: mechter's profile mechter Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 4.7.4
Component: Query Keywords: needs-patch has-test-info
Focuses: Cc:

Description

Steps to reproduce:

  • Create a page and make it the static front page
  • Add a new query var via filter in theme's functions.php: add_filter( 'query_vars', function( $vars ) { array_push( $vars, 'buggy' ); return $vars; } );
  • Open the front page setting the newly added query var (e.g. "https://example.com/?buggy=yep")

Result: displays the latest blog post
Expected result: displays front page

Change History (4)

#1 follow-up: @joyously
9 years ago

I was able to reproduce this using a child theme with TwentyFifteen as the parent. TwentyFifteen does not have a front-page.php file. Also on TwentySixteen, which does not have a front-page.php either.

Last edited 9 years ago by joyously (previous) (diff)

#2 in reply to: ↑ 1 @bhargavbhandari90
9 years ago

I am also replicating this.
Replying to joyously:

I was able to reproduce this using a child theme with TwentyFifteen as the parent. TwentyFifteen does not have a front-page.php file. Also on TwentySixteen, which does not have a front-page.php either.

This ticket was mentioned in Slack in #core by sirlouen. View the logs.


8 weeks ago

#4 @SirLouen
8 weeks ago

  • Component changed from Posts, Post Types to Query
  • Keywords needs-patch has-test-info added
  • Milestone changed from Awaiting Review to Future Release

Reproduction Report

Description

✅ This report validates that the issue can be reproduced.

Environment

  • WordPress: 6.9-alpha-60093-src
  • PHP: 8.2.29
  • Server: nginx/1.29.1
  • Database: mysqli (Server: 8.4.6 / Client: mysqlnd 8.2.29)
  • Browser: Chrome 139.0.0.0
  • OS: Windows 10/11
  • Theme: Twenty Twenty-Five 1.3
  • MU Plugins: None activated
  • Plugins:
    • BBB Testing Dolly
    • Test Reports 1.2.0

Instructions

  1. The ones provided by OP.

Actual Results

  1. ✅ Error condition occurs (reproduced).

Additional Notes

  • There is something weird around this line

https://github.com/wordpress/wordpress-develop/blob/9ca38ce47b7a8a9c9e916e6aff39ec772ccbba55/src/wp-includes/class-wp-query.php#L1057
That array_diff is not correctly formulated, as the result unexpectedly is this buggy query var. I'm assuming that the idea is, that if any of those query vars existed, not to show the front page, but the corresponding search page. A patch is needed.

Note: See TracTickets for help on using tickets.