[wp-trac] [WordPress Trac] #63256: Unnecessary array_map() call in get_terms() when object_ids is not set
WordPress Trac
noreply at wordpress.org
Tue May 26 09:38:23 UTC 2026
#63256: Unnecessary array_map() call in get_terms() when object_ids is not set
-------------------------------------------------+-------------------------
Reporter: dilipbheda | Owner: audrasjb
Type: defect (bug) | Status: reviewing
Priority: lowest | Milestone: 7.1
Component: Taxonomy | Version: 4.7
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests needs- | Focuses:
testing |
-------------------------------------------------+-------------------------
Comment (by ozgursar):
== Test Report
Patch tested: https://github.com/WordPress/wordpress-develop/pull/11534
=== Environment
- WordPress: 7.1-alpha-62161-src
- Subdirectory: No
- PHP: 8.2.29
- Server: nginx/1.29.4
- Database: mysqli (Server: 8.4.7 / Client: mysqlnd 8.2.29)
- Browser: Chrome 148.0.0.0
- OS: macOS
- Theme: Twenty Twenty-Five 1.5
- MU Plugins: None activated
- Plugins:
* Code Snippets 3.9.6
* Test Reports 1.3.0
=== Steps taken
1. Add the following snippet to your active theme's `functions.php` or via
Code Snippets plugin to see the results in Admin Notification section of
the dashboard.
{{{
add_action( 'admin_notices', function () {
if ( ! current_user_can( 'manage_options' ) ) return;
$file = file_get_contents( ABSPATH . 'wp-includes/class-wp-
term-query.php' );
$is_patched = $file && str_contains( $file, "null ===
\$args['object_ids']" );
$cases = [ null, '', 0, false, 1 ];
echo '<div class="notice notice-info">';
echo '<p><strong>Trac #63256 — array_map() behavior per
object_ids value in get_terms()</strong></p>';
echo '<table style="border-collapse:collapse">';
echo '<tr>'
. '<th style="padding:4px 8px;border:1px solid
#ccc">object_ids</th>'
. '<th style="padding:4px 8px;border:1px solid
#ccc">Result</th>'
. '</tr>';
foreach ( $cases as $val ) {
if ( $is_patched ) {
$result = ( null === $val || '' === $val )
? 'skip → []'
: 'array_map → ' . var_export( array_map(
'intval', (array) $val ), true );
} else {
$result = ( '' === $val )
? 'skip → []'
: 'array_map → ' . var_export( array_map(
'intval', (array) $val ), true );
}
$bg = ( null === $val ) ? '#fff3cd' : '#fff';
echo '<tr style="background:' . $bg . '">'
. '<td style="padding:4px 8px;border:1px solid
#ccc"><code>' . esc_html( var_export( $val, true ) ) . '</code></td>'
. '<td style="padding:4px 8px;border:1px solid
#ccc">' . esc_html( $result ) . '</td>'
. '</tr>';
}
echo '</table></div>';
} );
}}}
2. Observe object_ids `NULL` does not skip and results as `array_map →
array ( )`
3. Apply the patch
4. `NULL` now correctly skips `array_map()`. All other values behave
identically to unpatched version
5. ✅ Patch is solving the problem
=== Expected result
- When `object_ids` is not set (defaults to `null`), `array_map()` should
be skipped.
- All other `object_ids` values (`''`, `0`, `false`, valid IDs) should
behave unchanged.
=== Screenshots/Screencast with results
Before
[[Image(https://core.trac.wordpress.org/raw-
attachment/ticket/63256/before-63256.png)]]
After
[[Image(https://core.trac.wordpress.org/raw-
attachment/ticket/63256/after-63256.png)]]
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63256#comment:27>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list