WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 5 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:

Description

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 8 years ago.
mkdir-fix.patch (1.4 KB) - added by sjmurdoch 8 years ago.
Updated version of patch to fix mkdir problem

Download all attachments as: .zip

Change History (7)

comment:1 sjmurdoch8 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

comment:2 davidhouse8 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.

davidhouse8 years ago

sjmurdoch8 years ago

Updated version of patch to fix mkdir problem

comment:3 sjmurdoch8 years ago

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

comment:4 davidhouse8 years ago

  • Keywords bg|commit added

comment:5 ryan8 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.