Make WordPress Core


Ignore:
Timestamp:
11/06/2015 06:57:53 AM (9 years ago)
Author:
westonruter
Message:

Customize: Fix typo in WP_Customize_Manager::_cmp_priority() which caused unstable sorting for same-priority constructs in PHP.

The issue, however, does not manifest in the UI because the UI is now built via JS and the wp.customize.utils.prioritySort() algorithm did not have the same typo.

Props bordoni, westonruter.
Fixes #34594.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/customize/manager.php

    r35483 r35553  
    398398        return array( 'nav_menus' );
    399399    }
     400
     401    /**
     402     * @ticket 30225
     403     * @ticket 34594
     404     */
     405    function test_prepare_controls_stable_sorting() {
     406        $manager = new WP_Customize_Manager();
     407        $manager->register_controls();
     408        $section_id = 'foo-section';
     409        wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
     410        $manager->add_section( $section_id, array(
     411            'title'      => 'Section',
     412            'priority'   => 1,
     413        ) );
     414
     415        $added_control_ids = array();
     416        $count = 9;
     417        for ( $i = 0; $i < $count; $i += 1 ) {
     418            $id = 'sort-test-' . $i;
     419            $added_control_ids[] = $id;
     420            $manager->add_setting( $id );
     421            $control = new WP_Customize_Control( $manager, $id, array(
     422                'section' => $section_id,
     423                'priority' => 1,
     424                'setting' => $id,
     425            ) );
     426            $manager->add_control( $control );
     427        }
     428
     429        $manager->prepare_controls();
     430
     431        $sorted_control_ids = wp_list_pluck( $manager->get_section( $section_id )->controls, 'id' );
     432        $this->assertEquals( $added_control_ids, $sorted_control_ids );
     433    }
    400434}
Note: See TracChangeset for help on using the changeset viewer.