Skip to content

64250 redirect guess 404 permalink#10975

Open
jonnynews wants to merge 18 commits intoWordPress:trunkfrom
spacedmonkey:64250-redirect-guess-404-permalink-v2
Open

64250 redirect guess 404 permalink#10975
jonnynews wants to merge 18 commits intoWordPress:trunkfrom
spacedmonkey:64250-redirect-guess-404-permalink-v2

Conversation

@jonnynews
Copy link
Copy Markdown

Trac ticket: https://core.trac.wordpress.org/ticket/64250

Use of AI Tools


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.

anandrajaram21 and others added 17 commits November 19, 2025 21:46
… control

This commit introduces the `search_position` parameter to the `WP_Query` class, allowing developers to specify search behavior for posts: finding terms at the start, end, or anywhere within fields. Corresponding functionality in `canonical.php` has also been updated, and comprehensive unit tests were added to ensure reliability of the new behavior.
* @type int $day Day of the month. Default empty. Accepts numbers 1-31.
* @type bool $exact Whether to search by exact keyword. Default false.
* Cannot be used together with `$search_position`.
* @type bool $search_position Whether to search start, ends or is anywhere within keyword. Default anywhere.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
* @type bool $search_position Whether to search start, ends or is anywhere within keyword. Default anywhere.
* @type string $search_position Whether to search start, ends or is anywhere within keyword. May be 'start', 'end', or the default 'anywhere'.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 18, 2026

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.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @jonnynews.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

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

Props altf4falt, spacedmonkey, westonruter.

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

@github-actions
Copy link
Copy Markdown

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

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

Copy link
Copy Markdown
Contributor

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

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

I've added a few notes inline.

$query_vars = &$this->query_vars;
$this->query_vars_changed = true;

if ( ! empty( $query_vars['exact'] ) && ! empty( $query_vars['search_position'] ) ) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  1. Let's allow a dev to pass both exact => true, search_position => anywhere without throwing a notice, as it's the documented default.
  2. Add search_position => '' to fill_query_vars() method.

*
* @ticket 64250
*
* @dataProvider data_search_position_values
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Per unit testing docs for providers used for a single test

Suggested change
* @dataProvider data_search_position_values
* @dataProvider data_search_position_with_different_values

*
* @return array
*/
public function data_search_position_values() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As above.

Suggested change
public function data_search_position_values() {
public function test_search_position_with_different_values() {

array(
'post_status' => 'publish',
'post_title' => 'alpha beta gamma',
'post_content' => 'delta epsilon zeta',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you add the content to the shared fixture and remove the need for creating the post here? If so, it would speed up the tests slightly.

*
* @ticket 64250
*/
public function test_search_position_with_invalid_value() {
Copy link
Copy Markdown
Contributor

@peterwilsoncc peterwilsoncc Feb 18, 2026

Choose a reason for hiding this comment

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

A data provider with a variety of types would be helpful to ensure nothing errors:

You'll need to fix the coding standareds for alignment

array(
			'null'     => array( null ),
			'true'     => array( true ),
			'false'    => array( false ),
			'int'      => array( 123 ),
			'float'    => array( 123.456 ),
			'string'   => array( 'test' ),
			'empty'    => array( '' ),
			'zero'     => array( 0 ),
			'negative' => array( -1 ),
			'array' => array( array( 'test' ) ),
			'empty array' => array( array() ),
		);

* @since 5.3.0 Introduced the `$meta_type_key` parameter.
* @since 6.1.0 Introduced the `$update_menu_item_cache` parameter.
* @since 6.2.0 Introduced the `$search_columns` parameter.
* @since 7.0.0 Introduced the `$starts_with` parameter.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
* @since 7.0.0 Introduced the `$starts_with` parameter.
* @since 7.0.0 Introduced the `$search_position` parameter.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In this file there are a few tests to ensure the default colums are used for empty/invalid search_columns values. Add assertions to ensure that the slug is not included in those tests.

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.

6 participants