Make WordPress Core

Opened 9 years ago

Last modified 3 months ago

#40521 new defect (bug)

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

Reported by: mechter Owned by:
Priority: normal Milestone: Future Release
Component: Query Version: 4.7.4
Severity: normal Keywords: has-test-info has-patch has-unit-tests
Cc: Focuses:

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 (5)

#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.

Version 0, edited 9 years ago by joyously (next)

#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.


11 months ago

#4 @SirLouen
11 months ago

  • Component Posts, Post TypesQuery
  • Keywords needs-patch has-test-info added
  • Milestone Awaiting ReviewFuture 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.

This ticket was mentioned in PR #11747 on WordPress/wordpress-develop by @sukhendu2002.


3 months ago
#5

  • Keywords has-patch has-unit-tests added; needs-patch removed
Note: See TracTickets for help on using tickets.