[wp-trac] [WordPress Trac] #44979: Parameter 1 to wp_default_styles() expected to be a reference, value given

WordPress Trac noreply at wordpress.org
Tue Feb 25 00:36:21 UTC 2020

#44979: Parameter 1 to wp_default_styles() expected to be a reference, value given
 Reporter:  jqz                                  |       Owner:
                                                 |  SergeyBiryukov
     Type:  defect (bug)                         |      Status:  accepted
 Priority:  normal                               |   Milestone:  5.4
Component:  Script Loader                        |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch needs-testing dev-         |     Focuses:
  feedback                                       |

Comment (by SergeyBiryukov):

 In my testing, the issue happens with:
 * PHP 7.2.x, `php_tideways_xhprof` extension (tested versions 5.0.1 and
 * PHP 7.2.x, `php_uopz` extension (version 5.0.2).

 Does not happen with:
 * PHP 7.2.x and later, `php_uopz` extension (version 5.1.0+).
 * PHP 7.3.x and later, `php_tideways_xhprof` extension.

 Replacing `do_action_ref_array()` with `do_action()` was previously
 explored in #16661 and #25160. It might actually break things and cause
 the same warning if plugins hooked to `wp_default_scripts` still use a
 reference in the function signature, for example:
 function my_scripts( &$scripts ) {
 add_action( 'wp_default_scripts', 'my_scripts' );

 As noted in comment:23:ticket:25160, the warning is caused by
 `call_user_func_array()` usage in [source:tags/5.3/src/wp-includes/class-
 wp-hook.php?marks=288#L265 WP_Hook::apply_filters()]. As a bit more
 complete illustration from comment:24:ticket:25160, this snippet:
 include 'wp-load.php';

 class Test_Me {
     function __construct() {
         do_action( 'woo', $this );

 function __woo( &$ref ) {


 add_action( 'woo', '__woo' );

 new Test_Me();
 produces: `PHP Warning: Parameter 1 to __woo() expected to be a reference,
 value given`.

 In my testing, `do_action_ref_array()` is not the issue here (there are
 ~90 instances of `do_action_ref_array()` and `apply_filters_ref_array()`
 in core that don't cause the warning).

 The real issue is the reference in these function signatures:
 function wp_register_tinymce_scripts( &$scripts, $force_uncompressed =
 false )
 function wp_default_packages_vendor( &$scripts )
 function wp_get_script_polyfill( &$scripts, $tests )
 function wp_default_packages_scripts( &$scripts )
 function wp_default_packages_inline_scripts( &$scripts )
 function wp_default_packages( &$scripts )
 function wp_default_scripts( &$scripts )
 function wp_default_styles( &$styles )

 Most of these were just copied from `wp_default_scripts()`. Removing the
 references appears to resolve the warnings without affecting the

Ticket URL: <https://core.trac.wordpress.org/ticket/44979#comment:27>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list