WordPress Automatic Install and Upgrade Errors

A friend is just about to undertake a short ‘WordPress Introduction’ course. She had a list of requirements from her tutor with essential criteria being that the user should be able to apply themes, plugins and core upgrades using the built in WordPress upgrade functionality.

I’ve just installed two default WordPress installations for Karlene and – given that I haven’t used the built in upgrade features extensively before – came across a few errors.

The first issue to trouble me was the fact Karlene isn’ overly tech savvy (sorry, Mrs. P) … and I didn’t want to trouble here with the need to enter FTP host, username and password details every single time she wanted to install any kind of feature. The solution? Hardcode those details into the wp-config.php file using WordPress Upgrade Constants

define('FTP_USER', 'username');
define('FTP_PASS', 'password');
define('FTP_HOST', 'ftp.example.org');
define('FTP_BASE', '/path/to/wordpress/');
define('FTP_CONTENT_DIR', '/path/to/wordpress/wp-content/');
define('FTP_PLUGIN_DIR ', '/path/to/wordpress/wp-content/plugins/');

Now, every time Karlene wants to install anything, she can do so via the admin control panel without any FTP entanglements.

The second issue that troubled me were the following errors:

Unable to Locate WordPress Plugin Directory

Warning: array_keys() [function.array-keys]: The first argument should be an array in /home/www/wp-admin/includes/class-wp-upgrader.php on line 189

The Problem Code

I search the WordPress Codex for a solution and found this code that you would copy into the bottom of your wp-config.php file (although it’s code we won’t use: see below).

This will tell WordPress to use the “direct write” method; with create_function as a quick hack (that should be expanded upon). You would then tell WordPress (via defined constants) what permissions to apply to the files and folders it creates.

define( 'FS_CHMOD_DIR', 0777 );
define( 'FS_CHMOD_FILE', 0777 );

However, a quick search of the WordPress Codex found constants that negate the need for any of the above. So, open up config.php and copy the following somewhere near the top of the file.

define( 'FS_METHOD', 'direct' );
define( 'FS_CHMOD_DIR', 0777 );
define( 'FS_CHMOD_FILE', 0777 );

Defining FS_METHOD as”direct” forces WordPress to use Direct File I/O requests from within PHP. The manual sensibly states that this is fraught with opening up security issues on poorly configured hosts. Use with caution.

Common Errors

  • Remember, your wp-content folder should be given appropriate permissions (maybe 0777 if all else fails)
  • If the system fails to create an ‘upgrade‘ directory in wp-content, create it manually (as you would with your uploads directory)

Shortt URL for this post:

Leave a Reply

Your email address will not be published. Required fields are marked *