Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#12113 closed defect (bug) (duplicate)

Plugin, theme, etc install issue (Could not create directory.)

Reported by: jfine Owned by: dd32
Milestone: Priority: normal
Severity: normal Version: 2.9.1
Component: Filesystem API Keywords: Plugin, theme, could not create directory
Focuses: Cc:


PHP: PHP 5.2.4-2ubuntu5.10 with Suhosin-Patch - Running as FastCGI
Wordpress: 2.9.1 clean install
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:

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-

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.


Change History (2)

comment:1 @jfine6 years ago

Appears to relate to a PHP bug where mkdir fails with a trailing slash under safe_mode. The bug continues to go unresolved since 2002 so it still likely makes sense to update the WP code.


comment:2 @dd326 years ago

  • Milestone Unassigned deleted
  • Resolution set to duplicate
  • Status changed from new to closed


[12741]: Fix WP_Filesystem_Direct::mkdir() when running under safe_mode on certain ...
Fix WP_Filesystem_Direct::mkdir() when running under safe_mode on certain versions of PHP. Props remi. Fixes #10497
By dd32 — 01/17/10 02:58:09

[12740]: Fix wp_mkdir_p() when running under safe_mode on certain PHP versions. ...
Fix wp_mkdir_p() when running under safe_mode on certain PHP versions. Props Denis-de-Bernardy. Fixes #8830
By dd32 — 01/17/10 02:45:01

Note: See TracTickets for help on using tickets.