Adventures in WordPress
So… I messed up, and I knew better.
With the recent changes to Google’s Search Engine Ranking Algorithm, it was suggested that websites with SSL enabled by default would have better search ranking. I figured it was time to put an SSL cert on israellopezconsulting.com and did so.
However, after getting the CSR, and jumping through Certificate Authority hoops, installing and testing; I found that the site wasnt entirely SSL.
There were some elements still being hosted over plain HTTP. Little by little I worked to fix issues, most of them were fixed by using the Wordpress HTTPS plugin. However, there was one small issue. The favicon.ico file.
This file was not defined by the domain.com/favicon.ico, but the “Shortcut Icon” declaration in the HTML. After looking at my themes PHP I found that the value was used directly as it was stored in the database.
Putting on my MySQL hat, I jumped into PhpMyAdmin and reviewed my databases wp_options table. I found the offending record, and discovered that the value was in a odd string format. I was not fased, I found the string that contained the direct URL, and edited that value directly and saved.
I visited my site and it did not look nearly like it should have been. Thinking it was a cache issue, I issued forced refresh commands in Firefox and Chrome to no avail. Then I made my biggest mistake, I visited my Wordpress Admin Panel for the Theme.
Everything was blank, as if I started from scratch. What happened?
As I wait for the Namecheap hosting rep to restore my database, I started working backwards to what the issue was. Editing the database was not a bad idea, BUT, editing that “odd string” was the root cause.
The “odd string” was really PHP’s Object Serialization. Its common for wordpress theme/plugin designers to save application state not in individual rows, but in PHP objects.
When I changed that string, I neglected to change the offset/length of the string. +1 char for “S”. Once that happened, PHP could not de-serialize it, and I guess the theme’s admin panel just assumes the data is bunk, and saves known defaults.
Once I figured that out, I with shame asked the Namecheap rep if they had a backup, and they did as of 2 days ago.
*Sigh* I knew too much to be dangerous.
Afterwards I looked up more key words of what I did and found a very obvious StackOverflow post. http://stackoverflow.com/questions/15138893/fix-serialized-data-broken-due-to-editing-mysql-database-in-a-text-editor
Had I only known.