[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
Wed Dec 16 22:12:56 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:  needs-patch   |     Focuses:
--------------------------+--------------------

Comment (by jeff@…):

 '''This is the revised implementation:'''



 {{{
 function map_deep( $value, $callback ) {
         if ( is_array( $value ) ) {
                 foreach ( $value as $index => $item ) {
                         $value[$index] = map_deep( $item, $callback );
                 }
         } elseif ( is_object( $value ) ) {
                 $object_vars = get_object_vars( $value );
                 foreach ( $object_vars as $property_name =>
 $property_value ) {
                         $value->$property_name = map_deep(
 $property_value, $callback );
                 }
         } else {
                 $value = call_user_func( $callback, $value );
         }

         return $value;
 }

 }}}

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


More information about the wp-trac mailing list