Make WordPress Core

Opened 12 years ago

Closed 12 years ago

Last modified 9 years ago

#2345 closed defect (bug) (wontfix)

Wordpress fails to create upload directories, even when parent is writable

Reported by: sjmurdoch Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.0
Component: General Keywords: bg|has-patch bg|commit
Focuses: Cc:


When I attempt to upload a small text file to Wordpress, it fails with the error message:

Unable to create directory /var/sites/lbt/wp-content/uploads/2006/01. Is /var/sites/lbt/wp-content/uploads/2006 writable?

The webserver runs as user www-data, group www-data and the directory is writable

$ ls -ld /var/sites/lbt/wp-content/uploads/2006 
drwxrwxr-x    2 www-data lbt          4096 Jan 27 18:10 /var/sites/lbt/wp-content/uploads/2006

The error message comes from wp-includes/functions-post.php:874

if ( ! @ mkdir( $pathym ) )
 return array('error' => "Unable to create directory $pathym. Is $pathy writable?");

If I remove the "@" to show errors, I get the following output:

Warning: Wrong parameter count for mkdir() in /var/sites/lbt/wp-includes/functions-post.php on line 874 Unable to create directory /var/sites/lbt/wp-content/uploads/2006/01. Is /var/sites/lbt/wp-content/uploads/2006 writable?

As indicated by the error message above, the mode flag is not optional in PHP < 4.2. Replacing the call with the following fixes the problem:

if ( ! @ mkdir( $pathym, 0775 ) )

Attachments (2)

2345.diff (750 bytes) - added by davidhouse 12 years ago.
mkdir-fix.patch (1.4 KB) - added by sjmurdoch 12 years ago.
Updated version of patch to fix mkdir problem

Download all attachments as: .zip

Change History (7)

#1 @sjmurdoch
12 years ago

I should add:

  • Version tested: wordpress-2.0-RC1
  • PHP version: 4.1.2-7.woody5
  • Operating system: Debian GNU/Linux 3.0

#2 @davidhouse
12 years ago

  • Keywords bg|has-patch added

Adds the modes in. I've left the chmods because they might be necessary in weird places like safe_mode. Perhaps not. I just left them in to be safe.

12 years ago

12 years ago

Updated version of patch to fix mkdir problem

#3 @sjmurdoch
12 years ago

The use of mkdir has changed in Wordpress 2.0.1, so I have attached an updated patch.

#4 @davidhouse
12 years ago

  • Keywords bg|commit added

#5 @ryan
12 years ago

  • Resolution set to wontfix
  • Status changed from new to closed

We require PHP 4.2 or greater.

Note: See TracTickets for help on using tickets.