[wp-trac] [WordPress Trac] #38825: wp_get_post_revisions default $args value

WordPress Trac noreply at wordpress.org
Wed Nov 16 17:44:03 UTC 2016


#38825: wp_get_post_revisions default $args value
-------------------------------------+------------------------------
 Reporter:  natostanco               |       Owner:
     Type:  defect (bug)             |      Status:  new
 Priority:  normal                   |   Milestone:  Awaiting Review
Component:  Revisions                |     Version:  2.6
 Severity:  normal                   |  Resolution:
 Keywords:  reporter-feedback close  |     Focuses:
-------------------------------------+------------------------------

Comment (by natostanco):

 Replying to [comment:1 ocean90]:
 > Hello @natostanco, do you have some code which is currently failing for
 you? Because of the `wp_parse_args()` call `$args` should never be `null`.
 >
 > {{{#!php
 > <?php
 > $args     = null;
 > $defaults = [ 'foo' => 'bar' ];
 > $args     = wp_parse_args( $args, $defaults );
 > var_dump( $args ); // array(1) { ["foo"]=> string(3) "bar" }
 > }}}
 >
 >
 > Introduced in [7987].

 yes `wp_parse_args()` should return not null, this is another case of
 `null` =/= `''`. If `$args` is null `parse_str()` does not touch `$r`
 which is then left undefined/null, then array_merge fails. For
 `pars_str()` to work and set `$r` to empty array `$args` must be empty
 string `''`, not null

--
Ticket URL: <https://core.trac.wordpress.org/ticket/38825#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list