Averting Blog Disaster - Fri, 11 Dec 2020
Yesterday, I logged into my account at my webhost Netfirms and I was met with a somewhat alarming message:
That was not pleasing to me. I knew what that meant. Likely I’d need to make major revisions to my website to get my Behold blog and my GenSoftReviews site to work under the new version of PHP.
My Behold blog and GenSoftReviews sites are 12 years old. I developed them both myself with WordPress. GenSoftReviews uses a WordPress plugin called WP Review Site that I purchased and then customized to my liking. My Behold Forum uses bbPress version 0.8 that was able to integrate with WordPress.
I spent many months customizing my blogs and forum to my liking, starting with the Behold style that I created to make my blog and the forum completely match the rest of my site. I added a user database for my Behold and DMT trials and purchases and automated the sending out of trial keys and recording of purchases. I created an integrated login system so people could post comments on my blog and messages in my forum. I added sophisticated spam filters to prevent the multitude of spam from getting onto my page. I added my newsletter system into the framework. Almost every single thing is tweaked and customized exactly to my liking.
The programming language for this is PHP and the database is MySQL. I had never used either of them prior to this endeavor, so it was a trial by fire. I’m proud of what I created and it has worked almost without a hitch for the past 12 years. That is of course without upgrading the underlying versions of WordPress and bbPress that I was using. I couldn’t upgrade them, really. The customizations I had done were extensive and some of the plugins that I was using were no longer available and were not being upgraded to work with new versions of WordPress.
Flipping the PHP Switch
I knew what would happen when I selected a PHP version 7 or greater: My blog would stop working. I tested it out and sure enough, only an error message appeared where my blog should be. I changed it back, and it worked again.
I spent the next couple of hours adding PHP 7.4 to my computer. I went back to my live blog and tried a few things. I flipped the PHP switch on my live site again and got the error again. I flipped it back to 5.6 and … oh oh, I still had the error.
This was no ordinary error. This was the dreaded Error 500 – Internal Server Error, that told you absolutely zip, zero, zilch about what was going on:
So how do you figure out what’s causing an error when no information is given? Into my Wordpress PHP code I went. For the next 3 hours, I was debugging it live online, line by line, putting in “here I am” statements and tracing to find what line is causing the error. I found out it was the line that was trying to initialize the MySQL database.
$wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
I spent two hours trying to get WordPress to initialize the database and tried everything including setting up test programs, and scanning the web and StackOverflow for this type of problem and solutions. I almost went as far as changing the password on the database. The funny thing that I noticed was GenSoftReviews was still working, but what that meant didn’t yet register on me.
It was now 1 a.m. I used Netfirms Support chat and got help from one of their support people. I was trying to figure out from the support person why the PHP change and then changing back now resulted in my blog not working. We tried a number of things and finally I was given a ticket where a Technical Specialist would contact me in 24 to 48 hours. It was 2:30 am and I went to bed.
The next morning I was right back at it with some new ideas. I tried various things and continued debugging. Overnight and for much of the day, I had a sad little message posted on my blog and forum:
After a few hours working through it all, I checked my email and I had got this message:
Umm. What!?. This is an automated message from WordPress to me. Sure enough, lots of WordPress files were missing on the server. And there were extra files as well. What I had on my computer which was supposed to be a working copy was different than what was online.
So I used BeyondCompare to mirror the tens of thousands of files on my computer in my blog directory back onto my website at Netfirms. When that completed a half an hour later, my blog appeared and worked fine!
An earlier email from the morning said this:
What had happened earlier that I didn’t realize was that WordPress on my website updated itself to its latest version. That I knew would crash my blog just as would the PHP upgrade. It should have twigged on me that because GenSoftReviews still worked. It couldn’t have been the PHP upgrade and downgrade that caused the problem since that would have affected GenSoftReviews as well.
Phew. Problem solved. But no images were being displayed in my blog. Another whoops. The images were uploaded from my blogging program Open Live Writer. Open Live Writer updates the blog posts into my blog’s MySQL database at Netfirms, but the images are put into the wp-content/upload folder with the WordPress code. I had never thought of syncing those images back to my computer. So I inadvertently deleted them when I mirrored up my files.
Another support chat with Netfirms and they were able to restore that folder for me from their backup.
By the way, I was very pleased with the Netfirm support chats. There was no waiting and the support person at the other end was very courteous and knowledgeable and helpful! It was not like this 5 years ago at Netfirms. They have really upped their game impressively.
Upgrade Necessary
I was still being presented with this message::
This is a window I was now getting when I try to go into Admin mode for my blog. Prior to last night, I had never seen this message before. I don’t know what triggered this message to start happening, but I did notice it at some point last night and dismissed it as something I can’t do and not to worry about.
Maybe I accidentally hit that “Upgrade WordPress link”, or maybe WordPress itself may have detected an error in the plugin when I switched to PHP 7 – I’m not sure which. But something caused Wordpress to merrily start upgrading itself in the background. That’s why the database wouldn’t open. That’s why all the files were different. That might have initiated those emails.
That “Database Upgrade Required” message prevents me from getting into the Admin mode in Wordpress. I tried using the:
define(‘WP_AUTO_UPDATE_CORE’, false);
directive that is supposed to turn the display of the message off, but it didn’t for me. So instead I just hacked the WordPress code and commented out the calls to the routine:
wp-admin/includes/upgrade.php
Netfirms is forcing its users to upgrade to PHP 7. As I result I will also have to upgrade WordPress and bbPress. I guess after 12 years of smooth sailing, it’s come to this and I’ll finally have to bite the bullet and update everything.
Sigh! That’s not what I wanted to have to do now. I’ve got updates to both DMT and Behold that I’m working on. But neither of those will be of use if I don’t have a working website to present them.
I’ve got an adventure ahead of me. It will be a lot of work, and a lot of learning, but it should be interesting and fun as well.
Followup, Jan 6, 2022: I finally completed the upgrade to PHP 7.4 on my sites, not without a few challenges. See: A Bit of Downtime on my Sites.