Archive for the ‘WordPress’ Category

More problems with WordPress feeds

Monday, October 23rd, 2006

Welcome to the second installment of WordPress Bug Friday. You may have noticed that it’s Monday, but … uh … weekends don’t count. Yeah, that’s the ticket! Furthermore, it’s almost the end of Daylight Saving Time, so I’m just getting a head start on rolling back the clocks.

Until I saw it in my web site logs, I didn’t even realize that my blog had an Atom feed. Incidentally, I’m a bit surprised that my logs are filled with requests from NetNewsWire. I am the developer of Vienna after all! Where are you, Vienna users? Anyway, the WordPress template for Atom is obsolete. We’re talking Edsel, Betamax, Eric Clapton obsolete here. The template, contained in the file wp-atom.php, is based on Atom 0.3, which has been deprecated.

The other issue I had was that I revised the post Build settings for Xcode projects on Sunday, but the post didn’t show up as revised in Vienna, which has a neat little feature I added that gives revised articles a green dot to distinguish them visually from blue-dotted new articles. (If you prefer, you can turn the feature off with defaults write uk.co.opencommunity.vienna2 CheckForUpdatedArticles -bool no.) Neither the Atom nor the RSS 2.0 feed showed the post as revised. Indeed, I was getting the dreaded HTTP 304 response (Leave me alone, I’m playing Doom!).

The bug with the (obsolete) Atom feed was that the template calls the same function, get_post_time, for both the (obsolete) issued and (obsolete) modified fields. The correct post creation and modification dates are listed in the blog’s database, so I could use get_post_time for one and get_post_modified_time for the other. With the RSS 2.0 feed, in contrast, it wasn’t clear that there was a bug, because RSS 2.0 has only one default field for item dates, pubDate. I wanted post revisions to show up in the feed, so I replaced get_post_time with get_post_modified_time for pubDate in the WordPress RSS 2.0 template file, wp-rss2.php.

If your WordPress posts have date-based permalinks, do not, I repeat, DO NOT edit the timestamp of an already published post in order to change the date in the feed. (And don’t sit with your back to any doors.) Editing the timestamp will not only change the date in the feed but also change the URL of the post! You’re a very bad man, Jerry, for suggesting this. Fortunately, I was able to repair the damage quickly. Even if your posts don’t have date-based permalinks, editing the timestamp could mess up your archives. To change the date in the feed, use my method of calling get_post_modified_time in the feed template.

I’ve updated my blog’s wp-atom.php file to conform to the Atom 1.0 specifications and made it available for download at wp-atom.txt (the extension has been changed from php to txt). You might want to consider using the attribute type="xhtml" rather than type="html" for the content and summary fields, depending on how your posts are formatted. One element that’s missing from the template is the recommended rel=self link to the feed itself, because I didn’t know how to request the feed link. I’d appreciate help from WordPress experts out there.

Tune in next week, same bat time, same bat channel, for the next exciting installment of WordPress bug Friday! Or maybe some other bat time.

WordPress bug with post comment feeds

Friday, October 13th, 2006

In the tradition of Apple Bug Friday (RSS), this post inaugurates WordPress Bug Friday. Actually, it’s just a coincidence that I fixed the bug on a Friday. Anyway, the bug is that the comments feeds for posts were returning HTTP code 304 (Not Modified) in Vienna, even though the posts had new comments that did appear in the main comments feed for the blog. Vienna, being a good net citizen, reads the Last-Modified date from a feed’s HTTP headers and sends the date back as If-Modified-Since in its request headers to the feed.

The cause of the bug in WordPress 2.0.4—as well as earlier versions of 2.0, I believe—appears to be that the comments feeds for posts were checking the last modified date for posts rather than the last modified date for comments, because unlike the main comments feed for the blog, http://lapcatsoftware.com/blog/comments/feed/, the comments feeds for posts, e.g., http://lapcatsoftware.com/blog/2006/10/09/stand-and-unfold-yourself/feed/, do not contain /comments/ in their URLs.

I discovered a ticket at the WordPress Trac discussing the bug, along with a patch. The patch was just two lines of code (or one, depending on how you count), so the change in the file /wp-includes/classes.php was easy to make, and it seems to be working fine now. Please let me know if you experience any problems.

While I’m on the subject of WordPress bugs, I’ll mention another one that has bit me a few times. If your post includes escaped HTML characters such as less-than and greater-than symbols, then when you edit your post again after saving or publishing, WordPress unescapes the characters in the editing view. Consequently, if you don’t re-escape those characters before saving or publishing, your post will be messed up. The technical term to describe this situation is lame. In some circles, they use sucky. My workaround is to compose a post entirely in a text editor such as Smultron and ensure that everything is perfect before I enter the post once and only once in WordPress.

Thus our first edition of WordPress Bug Friday comes to a close. I would be remiss, perhaps, if I did not also throw in an Apple bug. Since this post is lacking somewhat by my usual standards of (attempted) humor, I’ll mention an amusing and harmless little bug I came across. As a member of the Apple Developer Connection, I receive a monthly mailing containing a DVD with documentation and software updates. On the mailing label a few months ago, between my name and address, there was a line with the text NULL. Obviously the mailing label software was printing an additional field that in my case was empty. Given my programming background, I found this to be hilarious. (Admittedly, no one else did.)

By the way, I also find it amusing that ADC keeps track of us by PersonID. I am not a number, I am a person! Oh wait, I’m both.