Situation: You are migrating your WordPress blog from PHP4 to PHP5 (intentionally or being forced to as you web host won’t support PHP4 anymore). Most of the times, this is as simple as adding some simple lines to .htaccess (e.g.
AddHandler application/x-httpd-php5 .php ). And you might not notice any issues. But many of you still do. The issues range from weird page layouts, to some controls not working, to some errors popping up here and there, and probably your blog not even displaying. This occurs because even though WordPress is PHP5 compatible, some of the plugins you are using might not be. But even if you ensure that all your plugins are PHP5 compatible, there is still one more problem that I just saw today.
Problem: My host supports both PHP4 and PHP5. I decided to migrate my personal blog to PHP5 today by adding the aforementioned line to my .htaccess. Immediately, my blog disappeared, and in its place, all that was left was a few errors:
[07-Apr-2008 12:11:49] PHP Warning: flock() expects parameter 1 to be resource, boolean given in /…/wp-cache-phase2.php on line 105
[07-Apr-2008 12:11:49] PHP Warning: fopen/…/wp-cache-e3ba4b7161eb59d50c5e976a0b66782a.meta) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: Permission denied in /…/wp-cache-phase2.php on line 240
[07-Apr-2008 12:11:49] PHP Warning: fputs(): supplied argument is not a valid stream resource in /…/wp-cache-phase2.php on line 241
Note: I’ve deleted the exact file paths above for security reasons.
It gave me an idea that it had something to do with wp-cache. When I tried to open the settings for wp-cache, it again gve error that web server doesn’t have the permissions to write the file wp-cache-config.php, wp_cache_mutex.lock etc.
Analysis: On checking the file permissions for these mentioned files, I found that they already belong to the user under which the web server runs. So, write permissions shouldn’t have been a problem. I guessed that maybe this issue is because of another “handler” (x-httpd-php5) now trying to modify the files while earlier they were created by the php4 handler. But I couldn’t change the permissions now because they were created by the web server and I can’t modify/delete them through ssh/ftp under my username.
Solution: So, the solution (or workaround as you may call it) was to login to my cpanel, and use the “File Manager” there, since all operations done by it would also be carried out by the web-server. So, all I did was:
Went back to PHP4
Disabled WP-Cache Plugin
Launched the file manager, deleted the wp-content/wp-cache-config.php and wp-content/cache/wp_cache_mutex.lock. Came out.
Enabled PHP5 in .htaccess
Enable the WP-Cache Plugin
And that’s it. My Personal Blog is now running happily over PHP5 goodness :). let me know if you have any comments about this or any other suggestions that are better than this workaround.
Note: This problem might not be limited to WP-Cache alone. There might be other plugins as well having the same problem.
Note2: If you feel uncomfortable deleting any file, then make a copy of it through ssh/ftp (so that it is under your user name), delete the original file, and replace it by the copy you made. Now, you can give this file a permission of “777” (that is readable, writable, executable by all), so that the web server can also modify it.
[tags]WordPress, WP-Cache, plugins, PHP4, PHP5, migrating from PHP4 to PHP5, permissions, errors, web-server[/tags]