Make WordPress Core

Changeset 27745


Ignore:
Timestamp:
03/26/2014 06:21:45 PM (13 years ago)
Author:
nacin
Message:

WP_Theme: Return false from the display() method when get() fails.

Fixes a potential warning on the themes page when the active theme is deleted.

fixes #26873.

Location:
trunk
Files:
2 edited

Legend:

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

    r27471 r27745  
    536536         *
    537537         * @param string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags.
    538          * @return string String on success, false on failure.
     538         * @return string|bool String on success, false on failure.
    539539         */
    540540        public function get( $header ) {
    … …  
    572572         * @param bool $markup Optional. Whether to mark up the header. Defaults to true.
    573573         * @param bool $translate Optional. Whether to translate the header. Defaults to true.
    574          * @return string Processed header, false on failure.
     574         * @return string|bool Processed header, false on failure.
    575575         */
    576576        public function display( $header, $markup = true, $translate = true ) {
    577577                $value = $this->get( $header );
     578                if ( false === $value ) {
     579                        return false;
     580                }
    578581
    579582                if ( $translate && ( empty( $value ) || ! $this->load_textdomain() ) )
  • trunk/tests/phpunit/tests/theme/WPTheme.php

    r27710 r27745  
    129129                return 'subdir/theme with spaces';
    130130        }
     131
     132        /**
     133         * @ticket 26873
     134         */
     135        function test_display_method_on_get_method_failure() {
     136                $theme = new WP_Theme( 'nonexistent', $this->theme_root );
     137                $this->assertEquals( 'nonexistent', $theme->get( 'Name' ) );
     138                $this->assertFalse( $theme->get( 'AuthorURI' ) );
     139                $this->assertFalse( $theme->get( 'Tags' ) );
     140                $this->assertFalse( $theme->display( 'Tags' ) );
     141        }
    131142}
Note: See TracChangeset for help on using the changeset viewer.