[wp-trac] [WordPress Trac] #38825: wp_get_post_revisions default $args value
WordPress Trac
noreply at wordpress.org
Sun Dec 13 20:36:02 UTC 2020
#38825: wp_get_post_revisions default $args value
-------------------------------------+-------------------------
Reporter: natostanco | Owner: (none)
Type: defect (bug) | Status: closed
Priority: normal | Milestone:
Component: Revisions | Version: 2.6
Severity: normal | Resolution: worksforme
Keywords: reporter-feedback close | Focuses:
-------------------------------------+-------------------------
Changes (by hellofromTonya):
* status: new => closed
* resolution: => worksforme
* milestone: Awaiting Review =>
Comment:
I was unable to reproduce the reported issue. As it's marked as a `close`
candidate, I'm closing it. Why?
Let's talk about what's happening in the code.
When invoking `wp_get_post_revisions` without passing the 2nd argument,
`$args` is set to `null` within the function. This is its initial state.
{{{#!php
function wp_get_post_revisions( $post_id = 0, $args = null ) {
}}}
When `null` is passed to `wp_parse_args`, the `$defaults` array is
returned [https://3v4l.org/P9tVH as demonstrated here].
{{{#!php
$defaults = array(
'order' => 'DESC',
'orderby' => 'date ID',
'check_enabled' => true,
);
$args = wp_parse_args( $args, $defaults );
}}}
After the above code, `$args` is set to the default array and is no longer
`null`.
When the code gets to the `array_merge`, `$args` is an array and not
`null`.
**What could be happening?**
There's a filter in `wp_parse_str()`:
{{{#!php
function wp_parse_str( $string, &$array ) {
parse_str( $string, $array );
/**
* Filters the array of variables derived from a parsed string.
*
* @since 2.3.0
*
* @param array $array The array populated with variables.
*/
$array = apply_filters( 'wp_parse_str', $array );
}
}}}
A callback may be incorrectly running `null` instead of an array.
Searching core, there is not a callback registered to this hook.
I suspect there's a callback in a plugin, must use script, or theme that
is returning `null` to cause the problem @natostanco is reporting.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/38825#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list