SimpleTests for Drupal Modules

I recently completed the process of adding SimpleTest tests to two modules that I maintain on drupal.org: Porter Stemmer (a module that adds linguistics-based matching of word forms to Drupal’s core Search module, so that you can match “walk”, “walking”, “walks” etc. in searches), and Search by Page (a module that lets you search Drupal site pages (nodes, user profiles, attachments, and other pages such as views) as they are rendered by your theme, and allows you to restrict searching to certain content types, user roles, attachment fields, and/or other pages on your site).

It was an interesting experience. SimpleTest is pretty well documented, and I’ve been a professional software developer for a long time, so the concept of testing is not new to me. But it took quite a while to decide exactly what I should test (functional and unit tests), to figure out the details of SimpleTest (such as how to get cron to run and how to use its built-in browser), and when my first tries at tests inevitably failed, to decide whether the tests or the modules were at fault and fix the bugs.

The end result was worth it though. For one thing, I found several bugs both modules in the course of testing, as the tests are quite thorough. For instance, the Porter Stemmer tests go through a huge list of words provided by Porter (the creator of the stemming algorithm) and verifies that all the words are stemmed correctly to their root forms, and also has a functional test that verifies that the module meshes correctly with Drupal’s core Search module. The Search by Page module tests that only the content you want to search is searched, that permissions are honored, and also tests many more options than an ad-hoc “let’s see if this is working” sort of test would be able to verify.

Another benefit is “regression testing”: whenever I make an update to either module, I can run the tests and be reasonably certain that my changes aren’t going to break anything. And since SimpleTest has been incorporated into the core of Drupal version 7, when I port my modules to Drupal 7, I can also port the tests and once I get the tests to pass, I’ll be reasonably certain that my modules are working.

All you other module maintainers out there: I recommend that you learn about SimpleTest as soon as possible, if you haven’t done so already!

Plugin Update: Language Switcher 1.21 for WordPress

I’ve just released version 1.21 of the Language Switcher plugin for WordPress, which is a plugin for creating a multi-lingual site or blog.

This new release contains a bug fix for the upcoming version 2.9 of WordPress, which I uncovered while testing the 2.9 Beta 1 release. The bug was that with Language Switcher, tag clouds were not being sorted alphabetically by name correctly in WordPress 2.9. If you install the new version of the Language Switcher plugin, you will be ready when WordPress 2.9 is released (the new version of Language Switcher still works fine with older versions of WordPress).

Upcoming Seattle Drupal class

I am teaching a beginner-level Drupal class in Seattle in two weeks (October 2, 2009), with lots of help from the Seattle Drupal User Group. Enrollment for this class is pretty full, but you can take a look at poplarclass.com, to find out what we’re covering. (That site may experience an outage… I was testing out a new web hosting company [A2 hosting], but have decided not to continue with them, for various reasons. So sometime in October or November I’ll be moving that site to another web host, and it will could experience a short outage.)

I may also teach the class again, either through the Seattle Drupal User Group, or possibly at a local community college. Let me know if you’re interested in seeing that happen (you can leave a comment here).

Plugin Update: Routes 2.2.5 for WordPress

The Routes plugin for WordPress (which adds geographical information and Google Maps to WordPress) has just been updated with a bug fix. When you do a generic keyword search in WordPress, Routes is also supposed to make it search in the city and state/country fields of any routes you have defined. This wasn’t working for recent versions of WordPress in Routes 2.2.4 and earlier versions; it now should work in all versions of WordPress.

Article Update: Drupal Cheat Sheet

I finally found some time to update my Drupal Cheat Sheet article, which is a beginner’s guide to creating a Drupal site. The new version has a few minor oversights and errors corrected, including some previously-missing updates for Drupal 6, and several changes to the recommended modules list (mostly additions, as I’ve discovered some new Drupal modules that work well).

Module update: Porter Stemmer version 6.x-2.0 for Drupal

A few weeks ago, I became the co-maintainer of the Porter Stemmer module for Drupal, which adds American English stemming to Drupal’s core search functionality. (Stemming is the process of reducing words to their stems for better searching, so that for instance walk, walking, walks, and walked will all be equivalent in a search.)

Today I released a new version (6.x-2.0) of Porter Stemmer, which updates the module to use Version 2 of Porter’s stemming algorithm (the version Porter currently recommends using for production applications). I also was able to completely test the stemming functionality of the module using the SimpleTest framework, and verify that every word in Porter’s word list is stemmed correctly by the module.

New Article: Drupal vs. WordPress

I just published a new article on poplarware.com: Drupal vs. WordPress. It’s a comparison of the Drupal and WordPress content management systems, aimed at helping the reader choose which CMS is better for which types of web site projects.

Plugin Security Update: Language Switcher 1.20 for WordPress

I’ve just released version 1.20 of the Language Switcher plugin for WordPress, which is a plugin for creating a multi-lingual site or blog.

This is a security update, and it is highly recommended that you update to this version, if you are using any previous version of Language Switcher. It fixes a potential cross-site scripting (XSS) vulnerability, brought to my attention by Alien Hackers (thanks!). The vulnerability was unlikely to be exploited in practice, but it did open up the possibility that if an Internet Explorer user who was already logged into their own site clicked on a maliciously-formed link to their own blog that someone had emailed them, and then immediately clicked on a sidebar link generated by the Language Switcher to switch languages, they could potentially compromise their site’s security. It’s a rather convoluted chain of circumstances, and as I said unlikely to occur, but anyway the vulnerability has now been eliminated and it is advisable that you update your site.

Plugin Update: Language Switcher 1.19 for WordPress

I’ve just released version 1.19 of the Language Switcher plugin for WordPress, which is a plugin for creating a multi-lingual site or blog.

The new version has some changes for compatibility of WordPress 2.8, and a fix for an efficiency bug. The plugin now works with version 2.8 Beta 1 of WordPress, which was released a couple of days ago; the plugin still also works with earlier versions, so it is recommended to upgrade now.

I also tested my other two plugins (Routes and Subscription Icons) with WordPress 2.8 Beta 1, and they are fine as-is. Hopefully the changes between Beta 1 and the final release of WordPress 2.8 will not change affect compatiblity.

Article Update: Creating a Compound Field Module for CCK in Drupal

I just updated my article on Creating a Compound Field Module for CCK in Drupal. It’s a programming tutorial on how to create a custom field module for the Drupal content management system and its Content Construction Kit module. In particular, the article covers how to create a custom field that packages an image upload, a caption, and taxonomy term, as one “compound” field.

The article and the accompanying module download have now been updated for compatibility with the released 6.x-3.0 versions of ImageField and FileField. Unfortunately, these modules changed a lot between the Alpha releases and the final releases, so the earlier version of the compound field module was totally incompatible with the released versions. The version in the article now is compatible. (Thanks to Greg Dunlap AKA heyrocker for pointing out the incompatibility.)

I also added more examples for compound fields that don’t contain an image.