[wp-trac] [WordPress Trac] #35058: PHP Fatal when map_deep tries to work on an object that has a property by reference

WordPress Trac noreply at wordpress.org
Tue Dec 15 21:10:03 UTC 2015


#35058: PHP Fatal when map_deep tries to work on an object that has a property by
reference
--------------------------+--------------------
 Reporter:  jeff@…        |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  4.4.1
Component:  Formatting    |     Version:  4.4
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+--------------------

Comment (by jeff@…):

 This replacement function seems much better ...

 {{{#!php

 function map_deep( &$value, $callback ) {
         if ( is_array( $value ) || is_object( $value ) ) {
                 foreach ( $value as $index => $item ) {
                         if ( is_object( $value ) ) {
                                 $value->$index = map_deep( $item,
 $callback );
                         } else {
                                 $value[$index] = map_deep( $item,
 $callback );
                         }
                 }
                 return $value;
         } else {
                 return call_user_func( $callback, $value );
         }
 }
 }}}

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


More information about the wp-trac mailing list