Ticket #28441: 28441.2.patch
File 28441.2.patch, 2.3 KB (added by , 9 years ago) |
---|
-
src/wp-includes/plugin.php
677 677 // $wp_plugin_paths contains normalized paths. 678 678 $file = wp_normalize_path( $file ); 679 679 680 arsort( $wp_plugin_paths ); 680 681 foreach ( $wp_plugin_paths as $dir => $realdir ) { 681 682 if ( strpos( $file, $realdir ) === 0 ) { 682 683 $file = $dir . substr( $file, strlen( $realdir ) ); -
tests/phpunit/tests/functions/pluginBasename.php
9 9 class Tests_Plugin_Basename extends WP_UnitTestCase { 10 10 11 11 /** 12 * @var array 13 */ 14 protected $wp_plugin_paths_backup; 15 16 public function setUp() { 17 parent::setUp(); 18 19 $this->wp_plugin_paths_backup = $GLOBALS['wp_plugin_paths']; 20 } 21 22 public function tearDown() { 23 $GLOBALS['wp_plugin_paths'] = $this->wp_plugin_paths_backup; 24 25 parent::tearDown(); 26 } 27 28 /** 12 29 * @ticket 29154 13 30 */ 14 function test_ should_return_correct_basename_for_symlinked_plugins() {31 function test_return_correct_basename_for_symlinked_plugins() { 15 32 global $wp_plugin_paths; 16 33 17 $old_wp_plugin_paths = $wp_plugin_paths; 34 $wp_plugin_paths = array( 35 WP_PLUGIN_DIR . '/a-symlinked-plugin' => 'C:/www/path/plugins/a-plugin', 36 ); 18 37 19 $wp_plugin_paths[ WP_PLUGIN_DIR . '/a-symlinked-plugin' ] = 'C:/www/path/plugins/a-plugin';20 21 38 $basename = plugin_basename( 'c:\www\path\plugins\a-plugin\plugin.php' ); 39 $this->assertSame( 'a-symlinked-plugin/plugin.php', $basename ); 40 } 22 41 23 $wp_plugin_paths = $old_wp_plugin_paths; 42 /** 43 * @ticket 28441 44 */ 45 function test_return_correct_basename_for_symlinked_plugins_with_path_conflicts() { 46 global $wp_plugin_paths; 24 47 25 $this->assertSame( 'a-symlinked-plugin/plugin.php', $basename ); 48 $wp_plugin_paths = array( 49 WP_PLUGIN_DIR . '/plugin' => '/Users/me/Dropbox/Development/Repositories/plugin', 50 WP_PLUGIN_DIR . '/trunk' => '/Users/me/Dropbox/Development/Repositories/plugin/trunk', 51 ); 52 53 $basename = plugin_basename( '/Users/me/Dropbox/Development/Repositories/plugin/trunk/plugin.php' ); 54 $this->assertSame( 'trunk/plugin.php', $basename ); 26 55 } 27 56 }