WordPress.org

Make WordPress Core

Changeset 37648


Ignore:
Timestamp:
06/06/2016 09:50:29 PM (4 years ago)
Author:
ocean90
Message:

Widgets: Revert [37425] and [37427].

The change can cause fatal errors under certain conditions, like when the subclass has a different function signature for widget() or doesn't even implement the method.

See #35981.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-widget.php

    r37492 r37648  
    1717 * @since 2.8.0
    1818 * @since 4.4.0 Moved to its own file from wp-includes/widgets.php
    19  * @abstract
    2019 */
    21 abstract class WP_Widget {
     20class WP_Widget {
    2221
    2322    /**
     
    9897     * @since 2.8.0
    9998     * @access public
    100      * @abstract
    10199     *
    102100     * @param array $args     Display arguments including 'before_title', 'after_title',
     
    104102     * @param array $instance The settings for the particular instance of the widget.
    105103     */
    106     abstract public function widget( $args, $instance );
     104    public function widget( $args, $instance ) {
     105        die('function WP_Widget::widget() must be over-ridden in a sub-class.');
     106    }
    107107
    108108    /**
  • trunk/tests/phpunit/tests/widgets.php

    r37427 r37648  
    337337     */
    338338    function test_wp_widget_form() {
    339         $widget = new WP_Widget_Mock( 'foo', 'Foo' );
     339        $widget = new WP_Widget( 'foo', 'Foo' );
    340340        ob_start();
    341341        $retval = $widget->form( array() );
     
    351351        $id_base = 'foo';
    352352        $name = 'Foo';
    353         $foo_widget = new WP_Widget_Mock( $id_base, $name );
     353        $foo_widget = new WP_Widget( $id_base, $name );
    354354
    355355        $this->assertEquals( $id_base, $foo_widget->id_base );
     
    369369            'id_base' => 'bar_id_base',
    370370        );
    371         $bar_widget = new WP_Widget_Mock( $id_base, $name, $widget_options, $control_options );
     371        $bar_widget = new WP_Widget( $id_base, $name, $widget_options, $control_options );
    372372        $this->assertEquals( $widget_options['classname'], $bar_widget->widget_options['classname'] );
    373373        $this->assertEquals( $control_options['id_base'], $bar_widget->control_options['id_base'] );
     
    380380     */
    381381    function test_wp_widget_get_field_name( $expected, $value_to_test ) {
    382         $widget = new WP_Widget_Mock( 'foo', 'Foo' );
     382        $widget = new WP_Widget( 'foo', 'Foo' );
    383383        $widget->_set( 2 );
    384384        $this->assertEquals( $expected, $widget->get_field_name( $value_to_test ) );
     
    431431     */
    432432    function test_wp_widget_get_field_id( $expected, $value_to_test ) {
    433         $widget = new WP_Widget_Mock( 'foo', 'Foo' );
     433        $widget = new WP_Widget( 'foo', 'Foo' );
    434434        $widget->_set( 2 );
    435435        $this->assertEquals( $expected, $widget->get_field_id( $value_to_test ) );
     
    504504        global $wp_customize;
    505505
    506         $widget = new WP_Widget_Mock( 'foo', 'Foo' );
     506        $widget = new WP_Widget( 'foo', 'Foo' );
    507507
    508508        $this->assertEmpty( $wp_customize );
     
    680680
    681681}
    682 
    683 /**
    684  * Mock of WP_Widget.
    685  *
    686  * @since 4.6.0
    687  */
    688 class WP_Widget_Mock extends WP_Widget {
    689     public function widget( $args, $instance ) {
    690         return;
    691     }
    692 };
Note: See TracChangeset for help on using the changeset viewer.