WordPress.org

Make WordPress Core

Changeset 34102


Ignore:
Timestamp:
09/14/2015 01:22:23 AM (5 years ago)
Author:
wonderboymusic
Message:

Objects are passed by-reference since PHP 5. In _get_custom_object_labels(), cast $object->labels back to object before returning. This function is weird.

Adds unit test.

Props Toro_Unit.
Fixes #33023.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post-functions.php

    r34100 r34102  
    13941394    }
    13951395    $labels = array_merge( $defaults, $object->labels );
     1396    $object->labels = (object) $object->labels;
     1397   
    13961398    return (object) $labels;
    13971399}
  • trunk/tests/phpunit/tests/post/types.php

    r34100 r34102  
    143143        $this->assertFalse( post_type_exists( 'foo' ) );
    144144    }
     145
     146    /**
     147     * @ticket 33023
     148     */
     149    public function test_get_post_type_object_casting() {
     150        register_post_type( 'foo' );
     151
     152        $before = get_post_type_object( 'foo' )->labels;
     153
     154        get_post_type_labels( get_post_type_object( 'foo' ) );
     155
     156        $after = get_post_type_object( 'foo' )->labels;
     157
     158        $this->assertEquals( $before, $after );
     159
     160        _unregister_post_type( 'foo' );
     161    }
    145162}
Note: See TracChangeset for help on using the changeset viewer.