WordPress.org

Make WordPress Core

Ticket #31620: 31620.2.patch

File 31620.2.patch, 1.4 KB (added by McGuive7, 5 years ago)

Update patch to use wp_normalize_path() in place of realpath() to avoid potentialissues with symlinks.

  • src/wp-includes/theme.php

     
    626626function get_raw_theme_root( $stylesheet_or_template, $skip_cache = false ) {
    627627        global $wp_theme_directories;
    628628
    629         if ( count($wp_theme_directories) <= 1 )
     629        $theme_dir_count = count( $wp_theme_directories );
     630
     631        if ( 0 === $theme_dir_count ) {
    630632                return '/themes';
     633        }
    631634
     635        if ( 1 === $theme_dir_count ) {
     636                $theme_path = reset( $wp_theme_directories );
     637                $theme_path_normalized = wp_normalize_path( $theme_path );
     638                $content_path_normalized = wp_normalize_path( WP_CONTENT_DIR );
     639                return strpos( $theme_path_normalized, $content_path_normalized ) === 0 ? substr( $theme_path_normalized, strlen( $content_path_normalized ) ) : $theme_path_normalized;
     640        }
     641
    632642        $theme_root = false;
    633643
    634644        // If requesting the root for the current theme, consult options to avoid calling get_theme_roots()
  • tests/phpunit/tests/media.php

     
    583583                wp_delete_attachment( $post_id );
    584584
    585585                $this->assertEquals( 'This is a comment. / Это комментарий. / Βλέπετε ένα σχόλιο.', $post->post_excerpt );
     586
     587                // Delete test image.
     588                wp_delete_attachment( $post_id );
    586589        }
    587590
    588591}