WordPress Upgrade Problems

I decided to upgrade WordPress to version 2.8 using the Automatic Upgrade Tool. The upgrade looked something like this:

Downloading update from http://wordpress.org/wordpress-2.8.zip
Unpacking the core update
Verifying the unpacked files
Installing the latest version
Warning: copy(/home/www/blog/wp-content/themes/default/index.php) [function.copy]: failed to open stream: Permission denied in /home/www/blog/wp-admin/includes/class-wp-filesystem-direct.php on line 122
Warning: copy(/home/www/blog/wp-content/themes/default/index.php) [function.copy]: failed to open stream: Permission denied in /home/www/blog/wp-admin/includes/class-wp-filesystem-direct.php on line 122

After that, my blog wouldn’t load at all, and when I looked on my server, the entire blog directory was empty. I recognized the two listed files as ones I had changed in this post about displaying the author. It turns out that I had inadvertently set the owner of the file to root which gave the WordPress upgrade no permission to upgrade the file. Instead of failing gracefully, it simply dumped the entire blog directory.

It appears this bug has been addressed in this ticket. Hopefully a similar error won’t cause me any problems during my next upgrade.

Edit: It turns out the damage was a bit greater than I initially realized. This bug deleted almost every file that was owned by the Apache user. This included two wikis that I run and several other miscellaneous sites. Luckily I was able to restore everything from backups. I have also changed the ownership of many of the files to something other than the Apache user.

Show the Author in WordPress

I had added the code to the default WordPress theme a while back, but when I upgraded, it apparently cleared it out. This time I documented the changes I made to the default theme. Changes must be made to two files in “wp-content/themes/default” which is the default theme directory.

The first file is “index.php” and only requires the removal of the comments around “the_author()” portion.

<small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>

The second file is “single.php” and requires the addition of a “the_author()” block similar to the following.

on <?php the_time('l, F jS, Y') ?> at <?php the_time() ?> by <?php the_author() ?>

I achieved these changes with the following sed commands.

cd wp-content/themes/default
mv index.php index.php.default
sed 's/<!-- by <?php the_author() ?> -->/by <?php the_author() ?>/' index.php.default > index.php
mv single.php single.php.default
sed "s/on <?php the_time('l, F jS, Y') ?> at <?php the_time() ?>/on <?php the_time('l, F jS, Y') ?> at <?php the_time() ?> by <?php the_author() ?>/" single.php.default > single.php

The better solution is probably to find a theme that does this by default instead of enabling it every time the theme gets updated; however, I haven’t gone looking for a replacement theme yet.

This has been tested with WordPress 2.7.1.

Edit: It is advisable to then set the permissions on those two files back to that of the Apache user:

chown www-data:www-data index.php single.php

This will help prevent possible problems during an upgrade.