WordPress.org

Make WordPress Core

Ticket #16953: 16953.no-single-file.2.diff

File 16953.no-single-file.2.diff, 1.3 KB (added by rmccue, 7 years ago)

Ensure we normalise base plugin directory paths

  • wp-includes/plugin.php

    diff --git wp-includes/plugin.php wp-includes/plugin.php
    index f5d213d..8b8b166 100644
    function plugin_basename( $file ) { 
    642642function wp_register_plugin_realpath( $file ) {
    643643        global $wp_plugin_paths;
    644644
     645        // Normalize, but store as static to avoid constant recalculation of a
     646        // constant value
     647        static $wp_plugin_path, $wpmu_plugin_path;
     648        if ( empty( $wp_plugin_path ) || empty( $wpmu_plugin_path ) ) {
     649                $wp_plugin_path = wp_normalize_path( WP_PLUGIN_DIR );
     650                $wpmu_plugin_path = wp_normalize_path( WPMU_PLUGIN_DIR );
     651        }
     652
    645653        $plugin_path = wp_normalize_path( dirname( $file ) );
    646654        $plugin_realpath = wp_normalize_path( dirname( realpath( $file ) ) );
    647655
     656        if ( $plugin_path === $wp_plugin_path || $plugin_path === $wpmu_plugin_path ) {
     657                return false;
     658        }
     659
    648660        if ( $plugin_path !== $plugin_realpath ) {
    649661                $wp_plugin_paths[ $plugin_path ] = $plugin_realpath;
    650662        }
     663
     664        return true;
    651665}
    652666
    653667/**
  • wp-settings.php

    diff --git wp-settings.php wp-settings.php
    index aee35b3..9f73195 100644
    $GLOBALS['wp_plugin_paths'] = array(); 
    168168
    169169// Load must-use plugins.
    170170foreach ( wp_get_mu_plugins() as $mu_plugin ) {
    171         wp_register_plugin_realpath( $mu_plugin );
    172171        include_once( $mu_plugin );
    173172}
    174173unset( $mu_plugin );