best practice
Using hook_requirements In Drupal 6.x
Submitted by greg.harvey on Tue, 27/01/2009 - 19:25You probably know about dependencies in modules and how to declare them in a module's .info file. In case you're not familiar with the concept, it looks like this:
dependencies[] = imagefield
dependencies[] = nodereference
dependencies[] = content_copy
dependencies[] = views
dependencies[] = imagecache(Slightly different in Drupal 5.x - be warned!)
Each one of those modules must be enabled before Drupal will allow you to enable the module you want to install. Neat, huh? But there is a problem:
Strict Typing And XML-RPC
Submitted by greg.harvey on Wed, 17/12/2008 - 20:06You 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:
Using The module_exists Function Effectively
Submitted by greg.harvey on Fri, 12/12/2008 - 14:31In 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.
A Note On Updating
Submitted by greg.harvey on Thu, 27/11/2008 - 17:17These 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.
Baby, Don't You Loose Your Type On Me
Submitted by greg.harvey on Fri, 29/08/2008 - 18:30Many programmers from beyond the realm of PHP, deep in the black country where the dragons reside, whinge like an Australian swim-coach about PHP's loose variable typing. Many PHP developers either don't know what this means or don't care. I didn't much care, until recently, where I got a practical lesson in why loose typing can, on ocassion, really suck.
Here are some interesting effects of PHP's loose typing:
<?php
$var1 = 1;
$var2 = '1';
print 'Result: '.($var1 == $var2);
?>
