Published by Philip G
Wow, I just had a nice, big post written, and it was all lost because one database table attribute was not copied over in the move: auto_increment. ugh!
So, what did I say … Wordpress sucks, well, annoying if you don’t understand its limitations. Yes, I hadn’t posted in a while. There are a couple of good reasons for that: 1) I’ve been busy with other things, 2) I moved my sites to a new server, dreamhost was just way too slow and 3) In the move, wordpress buggered up and prevented me from accessing my admin page. Did I say two? I meant three.
Anyway, I just spent the last few days debugging a problem with Wordpress which came to find out is a horrible design decision on the part of the developers. Anybody that’s familiar with Wordpress knows of it’s install process where you’re asked what table prefix do you want to use. Simple enough, you accept the default or add your own and install Wordpress. So, I ask you, what if you wanted or needed to change it later on down the road?
“Oh, that’s simple,” you may say. You may also say, “All you have to do is change the table names and update the table_prefix in the config file.” Wrong. Well, you’re actually only half right. You see, the table_prefix value, which is suppose to be for only table prefixes, is also used as a namespace prefix. What do I mean by that? In the database you have name = value key-value pairs. Some deranged soul over at Wordpress decided it would be a good idea to use the table_prefix as a namespace prefix. You know, to prevent any conflicts to any plugins that wish to use values, too — I would assume. Needless to say, because I only changed the table names, I ended up locking myself out of the admin sectopm. This of course, took a few days of debugging to figure out.
How did I figure this out? At first, I did everything I could think of on my end. I thought I borked up the move some out. I checked data; I recopied data; I reverted the table_prefix change … whoa that worked. But why? I have two WP installs in this one db. The prefix had to be change. The only logical conclusion in this is WP was using the table prefix value somewhere else. But where?
Instead of hunting all over creation to figure out where, I decided to hit up Wordpress themselves and ask. At first, I was a good samaritan; I did a search on the error I recieved: “You do not have the sufficient permissions to view this page” (or something long those lines). The search came up with 10+ pages…oh great. I check out a few random posts to see if I can see anything similar; page 2, page 3, page 4, this was going nowhere. Not only did none of those posts talked about my problem, all of them were different. My error appeared to be an “all emcompassing” error message…oh great, again. I decided I needed to post my own plea for help.
Unfortunately this plea didn’t get any immediate, useful responses. The first being “change the config” … gee thanks, I already did that. Second one being, “you can’t, wp requires that for values in the db,” which started me on “omg, do not tell me that’s true!” Sadly, a day goes by and I bump my post (shame on me, I know). A new reply hits, this time a useful response. He linked across a plug-in that will change your table prefixes for you. Of course, since I’ve already done half the job, I use the source to find out what I was missing. Sadly, my nightmare was confirmed: Wordpress is using table_prefix as part of its values within the database. What kind of developer does this? Who in their right mind thought “Hey, you know what, why don’t we use table_prefix in the db to separate our db values for other db values? Such a good idea, no?” Uhm, no, it’s not.
Needless to say, I updated the said table rows and, low-and-behold, it worked. Yay!
Lesson learned; wordpress developers smoke crack and don’t update your table_prefixes. If you must, use the WP Prefix Changer plug-in.
Oh yeah and also, make sure your db migration properly copies over your auto_increment keys. It’ll save you time and the need to rewrite an entire post…doh!
. Oct 31, 2007
Filed under: Delusioned