greg.harvey's blog

Page And Block Caching

I had an issue the other day born out of a misconception about the way block and page caching works. I created a Known User Role module, which includes a block saying something like "Welcome back, !username" to so-called "known" users. I created it on my development Drupal site with caching Disabled (at admin/settings/performance) and it worked great. I implemented this in hook_block(), which I presumed would exclude this dynamic block from all caches:

<?php
if ($op == 'list') {

Strict Typing And XML-RPC

You may or may not be aware web services are very strictly typed (well, XML is, period). That means if you send a web service a string, e.g. '233', when it wants an integer, e.g. 233 (note the very subtle difference) it will break!

Consider this XML-RPC call to the Services module in Drupal:

<?php
$nid
= 144;
$result = xmlrpc('http://www.mydomain.com/services/xmlrpc', 'file.getNodeFiles', $nid);
?>

This will make Drupal's XML-RPC handling functions build the following XML envelope to send to the web service at http://www.mydomain.com/services/xmlrpc:

Triggers And Uninstalling Modules

Note, Actions and Triggers are core in Drupal 6.x so this only applies to Drupal 5.x if you are using the Actions module as a 5.x contributed module:
http://drupal.org/project/actions

If you are using Triggers in Drupal 5.x then you have probably installed something like the Node Triggers module, which allows Actions to be triggered on node-related events (using hook_nodeapi()):
http://drupal.org/project/nodetriggers

Using The module_exists Function Effectively

In our team I'm as guilty of this as anyone, but we're occasionally caught out by the creation an un-managed and un-documented dependency on a module, perhaps in a theme's template.php file or even in a module where someone forgot to list the dependency in the .info file or meant to remove the function call and forgot.

Nasty Apache 2 vhosts Gotcha

This is worth a blog post, as it took us a while to get to the root of the problem. We had a fresh installation of RedHat (RHEL 5, to be precise) which comes with Apache 2. I'm used to having a vhosts include for httpd.conf that looks something like this:

NameVirtualHost *:80


DocumentRoot "c:/xampplite/htdocs"
ServerName localhost

Options +Indexes
AllowOverride All
Allow from all


DocumentRoot "c:/projects/d6"

Theming In Drupal 6

Don't get me wrong, the documentation relating to theming for module developers in Drupal 6.x is all there and complete. The trouble is, it's spread over several different places. The purpose of this blog entry is to do a step-by-step guide to theming something in a module for Drupal 6. It is inspired by my colleague, Brendan, who created a really neat little demo module this morning which shows how the various bits of the theming API work. I felt, having compiled all the information in one place, it deserved a write-up.

A Note On Updating

These days, now the Update Status module is core in Drupal 6, people find themselves updating their core, modules and themes far more regularly than before. This is, of course, a very good thing. I'd just like to raise a couple of points of order on the matter:

When updating it is always tempting to copy the contents of the downloaded tar file straight over the existing module or theme. Don't! It is entirely possible there are files with the old version which are not required by the new one. Worse, they may even do some harm.

Bootstrap And Your Module

I had an interesting gotcha this afternoon. With Drupal 6.x came a new hook, hook_boot(). It supercedes the !$may_cache behaviour in Drupal 5.x by providing a hook that any code which *must* run on all pages, cached or otherwise, can be placed in.

This is pretty useful, because unlike hook_init() which only fires on pages that are not cached, hook_boot() always fires.

More On Deploying With JMeter - Shell Scripting Deployment

The other day I expanded on someone else's blog about load testing Drupal with JMeter, by writing about how one can submit forms, and as such potentially handle deployments, with Drupal.

This entry continues on that theme, but looks at scripting your JMeter plans from Linux shell, to make deployment of many JMeter scripts across many different potential environments much, much easier.

Finally Upgraded

I've finally updated this site to Drupal 6.6. It's using a new theme, because my old one isn't ready yet. I may port it myself, as my girlfriend says she liked the green, but for now it's grey and claret.

Hope you like the new colours!

Worth reporting there were no real updating issues for any of the modules. This site uses:

  • CCK
  • Date
  • Email Field
  • Link Field
  • Pathauto
  • Token
  • Node Comments
  • Views
  • Codefilter
  • CAPTCHA
  • Google Analytics
  • Node Images
Syndicate content