In WordPress 2.7 there is a nice feature to automatically update plugins or the core via one simple click on a link. For quite a while I couldn’t get it to work as it was producing errors like:
Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/var/tmp//1220989448) is not within the allowed path(s): (/home/usr123/:/tmp:/usr/local/lib/php/) in /usr/home/usr123/../wp-includes/functions.php on line 1960
Warning: touch() [function.touch]: open_basedir restriction in effect. File(/var/tmp/1220989448) is not within the allowed path(s): (/home/usr123/:/tmp:/usr/local/lib/php/) in /usr/home/usr123/../wp-admin/includes/file.php on line 122
Warning: fileowner() [function.fileowner]: open_basedir restriction in effect. File(/var/tmp/1220989448) is not within the allowed path(s): (/home/usr123/:/tmp:/usr/local/lib/php/) in /usr/home/usr123/../wp-admin/includes/file.php on line 487
Warning: unlink() [function.unlink]: open_basedir restriction in effect. File(/var/tmp/1220989448) is not within the allowed path(s): (/home/usr123/:/tmp:/usr/local/lib/php/) in /usr/home/usr123/../wp-admin/includes/file.php on line 489
This morning I finally found THE hint that has lead me to the solution to fix it and to be honest it was amazingly simple!!
WordPress is trying to use the wrong path, duhh, but the correct path is also provided in the error message. In my case I have to point WordPress to the /tmp path instead of the found /var/tmp path!!
When you follow the error messages you finally end up in the get_temp_dir function (/wp-admin/includes/file.php:97) which basically provides the answer straight away after you run a full source code search on WP_TEMP_DIR…
function get_temp_dir() {
if ( defined('WP_TEMP_DIR') )
return trailingslashit(WP_TEMP_DIR);
So the solution is to define WP_TEMP_DIR in the wp-config.php file:
define('WP_TEMP_DIR','/tmp');
Happy auto updating!