[wp-trac] [WordPress Trac] #42670: Symlinked plugin makes plugin_basename function return wrong basename
WordPress Trac
noreply at wordpress.org
Thu Nov 23 11:36:12 UTC 2017
#42670: Symlinked plugin makes plugin_basename function return wrong basename
--------------------------+-----------------------------
Reporter: sergiienko | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Plugins | Version: 4.9
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
Symlinked plugin makes plugin_basename function return wrong basename for
plugins which goes after the symlinked plugin. If symlinked plugin name is
substring of WP root directory name.
For instance, plugin name is feedback-plugin and WP root directory is
feedback-plugin-wp.
Cause of such a behavior is condition:
{{{#!php
// wp-includes/plugin.php plugin_basename function (line 658).
if ( strpos( $file, $realdir ) === 0 ) {
$file = $dir . substr( $file, strlen( $realdir ) );
}
}}}
Solution:
{{{#!php
$pattern = '/^' . str_replace('/', '\/', $realdir) . '\//';
if ( preg_match( $pattern, $file ) ) {
$file = $dir . substr( $file, strlen( $realdir ) );
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/42670>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list