Make WordPress Core

Ticket #28441: 28441.patch

File 28441.patch, 1.5 KB (added by jdgrimes, 10 years ago)

Sort the paths with arsort() before resolving symlinks

  • src/wp-includes/plugin.php

     
    643643function plugin_basename( $file ) {
    644644        global $wp_plugin_paths;
    645645
     646        arsort( $wp_plugin_paths );
    646647        foreach ( $wp_plugin_paths as $dir => $realdir ) {
    647648                if ( strpos( $file, $realdir ) === 0 ) {
    648649                        $file = $dir . substr( $file, strlen( $realdir ) );
  • tests/phpunit/tests/plugin.php

     
     1<?php
     2
     3/**
     4 * @group plugin
     5 */
     6class Tests_Plugin extends WP_UnitTestCase {
     7
     8        protected $wp_plugin_paths_backup;
     9
     10        public function setUp() {
     11                parent::setUp();
     12
     13                $this->wp_plugin_paths_backup = $GLOBALS['wp_plugin_paths'];
     14        }
     15
     16        public function tearDown() {
     17                $GLOBALS['wp_plugin_paths'] = $this->wp_plugin_paths_backup;
     18
     19                parent::tearDown();
     20        }
     21
     22        /**
     23         * @ticket 28441
     24         */
     25        public function test_symlink_path_conflicts_resolved() {
     26
     27                global $wp_plugin_paths;
     28
     29                $wp_plugin_paths[ WP_PLUGIN_DIR . '/shopp' ] = '/Users/me/Dropbox/Development/Repositories/shopp';
     30                $wp_plugin_paths[ WP_PLUGIN_DIR . '/trunk'] = '/Users/me/Dropbox/Development/Repositories/shopp-arrange/trunk';
     31
     32                $this->assertEquals(
     33                        'trunk/shopp-arrange.php'
     34                        , plugin_basename( '/Users/me/Dropbox/Development/Repositories/shopp-arrange/trunk/shopp-arrange.php' )
     35                );
     36        }
     37}