Skip to content

Hoist the numeric term check out of the is_object_in_term() loop - #13595

Open
mukeshpanchal27 wants to merge 1 commit into
WordPress:trunkfrom
mukeshpanchal27:fix/hoist-numeric-term-check
Open

mukeshpanchal27 wants to merge 1 commit into
WordPress:trunkfrom
mukeshpanchal27:fix/hoist-numeric-term-check

Conversation

@mukeshpanchal27

@mukeshpanchal27 mukeshpanchal27 commented Sep 18, 2026

Copy link
Copy Markdown
Member

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

is_object_in_term() rebuilt $numeric_strs on every iteration of the $object_terms loop, calling array_filter() and array_map() once per term even though $strs never changes inside the loop. For an object with several terms in a taxonomy, that is N redundant passes over the same input.

Use of AI Tools

N/A


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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No unresolved issues were identified, and existing behavior is preserved.

Pull request overview

This pull request optimizes is_object_in_term() by moving numeric term preprocessing outside the object-term loop.

Changes:

  • Computes $numeric_strs once before iteration.
  • Preserves existing term-matching behavior.
File summaries
File Description
src/wp-includes/taxonomy.php Hoists numeric string normalization outside the loop.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@mukeshpanchal27
mukeshpanchal27 marked this pull request as ready for review September 18, 2026 06:09
@github-actions

Copy link
Copy Markdown

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.

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

Props mukesh27.

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

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.

2 participants