[wp-trac] [WordPress Trac] #12113: Plugin, theme, etc install issue (Could not create directory.)
WordPress Trac
wp-trac at lists.automattic.com
Tue Feb 2 00:36:19 UTC 2010
#12113: Plugin, theme, etc install issue (Could not create directory.)
--------------------------+-------------------------------------------------
Reporter: jfine | Owner: dd32
Type: defect (bug) | Status: new
Priority: normal | Milestone: Unassigned
Component: Filesystem | Version: 2.9.1
Severity: normal | Keywords: Plugin, theme, could not create directory
--------------------------+-------------------------------------------------
PHP: PHP 5.2.4-2ubuntu5.10 with Suhosin-Patch 0.9.6.2 - Running as
FastCGI[[BR]]
Wordpress: 2.9.1 clean install[[BR]]
OS: Ubuntu 8.04 LTS Server
After digging through the source the issue appears to be with how the
$remote_destination is found. If $remote_destination ends with a trailing
slash the call to mkdir() will fail.
This issue appears to be a partially a PHP issue as indicated by the two
examples:
[http://us3.php.net/manual/en/function.mkdir.php#73848][[BR]]
[http://stackoverflow.com/questions/1399174/php-mkdir-recursive-true-
skips-last-directory]
Never the less the wordpress mkdir() function should be patched to check
for a trailing slash and if found remove it.
Example failure (notice the trailing slash on the directory path):
{{{
Installing Plugin: Contact Form 7 2.1.1
Downloading install package from http://downloads.wordpress.org/plugin
/contact-form-7.2.1.1.zip.
Unpacking the package.
Installing the plugin.
Could not create directory.
/var/www/vhosts/bizplancompetitions.com/httpdocs/wp-content/plugins
/contact-form-7/
Plugin Install Failed.
}}}
Example fix (patch for wp-admin/includes/class-wp-filesystem-direct.php):
{{{
--- class-wp-filesystem-direct.php 2010-02-02 00:27:28.000000000
+0000
+++ class-wp-filesystem-direct.php.new 2010-02-02 00:28:36.000000000
+0000
@@ -280,6 +280,9 @@
}
function mkdir($path, $chmod = false, $chown = false, $chgrp =
false) {
+ if( preg_match('/^(.+)\/+$/', $path, $matches) )
+ $path = $matches[1];
+
if ( ! $chmod )
$chmod = FS_CHMOD_DIR;
}}}
Not sure if your better off using strpos() or a better regex but the one
above seems to fix all the issues I was having. I'm also not sure if it
makes sense to apply a similar patch to the other filesystem mkdir()
functions, although it's not likely necessary, it probably wouldn't hurt.
Cheers.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/12113>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list