Could Not Create Directory Issue in WordPress (a PHP 5.2.5 bug)

Bookmark and Share
Sunday, January 24 2010

I noticed this while setting up a WordPress (build 2.9.1) blog on a SUSE 10.3 Linux Server running PHP 5.2.5.

I encountered the following error when uploading or installing a plugin from the Add new section:

Could not create directory. /[WordPress Root]/wp-content/plugins/[My Plugin]/

I reviewed my file permissions and they appeared to be correct. I then proceeded to take a look at WordPress' wp-filesystem manager.

Looking at the file: [WordPress Root]/wp-admin/includes/class-wp-filesystem-direct.php, It appears that the path value being sent to the mkdir method contains a trailing slash, which is causing @mkdir to barf.

This is a bug reported in php 5.2.5 (http://bugs.php.net/bug.php?id=42739)

 

Best advice is to upgrade to the latest version of PHP.

 

However, if you are not in a position to upgrade, you can add the following line to the start of the mkdir method in the file [WordPress Root]/wp-admin/includes/class-wp-filesystem-direct.php

$path = preg_replace('(/$)', '', $path);

This will allow WordPress to bypass the PHP Bug.

 

 

Tagged as: , , , , , ,

Bookmark and Share

5 comment(s) so far

    • steve graham
    •  avatar
       
      Jul 29, 2010

      I have just downloaded the latest daily build and they have fixed the trailing slash issue but this still happen on my server.

      If I create the upgrade directory myself and set the permission to full I then get.

      Could not create directory. /user/htdocs/blog/wp-content/upgrade/wordpress-importer.tmp

      Help please.

    • Iphone 4 cases
    •  avatar
       
      Aug 01, 2010

      Hi,

      Firstable,congratulations on Your beautyful Web Site.

      We are looking to find link partners for our Iphone website.We sell all kind of Iphone 4 accessories.If you are interested,please send us your link details and will add you link immediately.

      Best Regards,

      John

Post your comment

Thanks for your comments


To use your gravatar, enter the email or username associated with that gravatar.

  • Comment

 

Office Cam

Search

My Tweets

  • johnny861: A man with explosives has taken hostages at the Discovery Channel bldg. I guess he didn't like shark week.
  • johnny861: Ford's bet on Facebook pays off: http://tinyurl.com/2cjs3as
  • johnny861: Why does "Killer Klowns from Outer Space" have 3.5 stars on netflix?
  • johnny861: US Government legalizes jail breaking for smart phones. http://tinyurl.com/397qbk6
  • johnny861: Being fairly rooted in all things Microsoft, I'm surprised to discover that the majority of my software purchases this year are Apple based.
  • johnny861: It's amazing how many people fall for this... http://i.imgur.com/VlYaV.jpg I bet their grandparents were hunting martians in New Jersey
  • johnny861: If the late night test of the Emergency Broadcast System no longer alerts you with its abrupt sound, you might just have a sleeping problem.
 

Powered By: