WordPress.org

Make WordPress Core

Ticket #40820: 40820.diff

File 40820.diff, 2.2 KB (added by davilera, 3 years ago)
  • src/wp-includes/class-wp-theme.php

     
    267267                        }
    268268                }
    269269
     270                if ( ! $this->template && $this->stylesheet === $this->headers['Template']) {
     271                        $this->errors = new WP_Error( 'theme_child_invalid', __( 'The theme defines itself as its parent theme. Please fix the "Template" header.' ) );
     272                        $this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet ) );
     273                        return;
     274                }//end if
     275
    270276                // (If template is set from cache [and there are no errors], we know it's good.)
    271277                if ( ! $this->template && ! ( $this->template = $this->headers['Template'] ) ) {
    272278                        $this->template = $this->stylesheet;
  • tests/phpunit/data/themedir1/child-parent-itself/style.css

     
     1/*
     2Theme Name: Child Theme
     3Template: child-parent-itself
     4*/
  • tests/phpunit/tests/theme/WPTheme.php

    Property changes on: tests/phpunit/data/themedir1/child-parent-itself/style.css
    ___________________________________________________________________
    Added: svn:executable
    ## -0,0 +1 ##
    +*
    \ No newline at end of property
     
    140140                $this->assertFalse( $theme->display( 'Tags' ) );
    141141        }
    142142
     143        /**
     144         * @ticket 40820
     145         */
     146        function test_child_theme_with_itself_as_parent_should_appear_as_broken() {
     147                $theme = new WP_Theme( 'child-parent-itself', $this->theme_root );
     148                $errors = $theme->errors();
     149                $this->assertWPError( $errors );
     150                $this->assertEquals( 'theme_child_invalid', $errors->get_error_code() );
     151        }
     152
    143153
    144154        /**
    145155         * Enable a single theme on a network.
     
    217227
    218228                $this->assertEqualSetsWithIndex( $allowed_themes, $new_allowed_themes );
    219229        }
     230
    220231}