Rediscovering an Old WordPress Bug Through a Newer Feature
Friday, March 23rd, 2007I created a test page using the page-creation functionality that was added in WordPress 1.5 then I decided to change that test page into an “About” page, which showed up in my custom index with the original page slug in the URL: “test” rather than “about”. I looked in the database both to check on the wp_posts.guid value and to see how I might be able to differentiate between WordPress “Posts” and WordPress “Pages” in my custom index-generator. My suspicion about the error was correct: wp_posts.guid was set to a non-existent URL with the original page slug, so that same old issue that was mentioned on the WordPress Web site two years ago remains in WordPress 2.1.2.
I changed the wp_posts.guid value manually, but I am still not sure why it falls out of synch with the value of wp_posts.post_name. I do not know of any good intentional reason for that to be allowed, so perhaps the WordPress developers have merely overlooked something where their code updates entries to the wp_posts table. Perhaps I can track it down, fix it, and contribute my fix to the WordPress project.
The other issue—my custom index of WordPress “Posts” including a WordPress “Page”—was easy to track down and resolve. As I suspected from the rather high integer in my “About” page editing links, WordPress “Pages” are stored with WordPress “Posts” in the wp_posts table. The two are differentiated by values in a column named “post_type”, so I added a constraint for wp_posts.post_type values of “post” when loading information for my custom index. Done.