Pet peeve #1 - the comparison operator
Submitted by naxoc on 10 December, 2009 - 23:08I have a lot of pet peeves when it comes to programming, databases, web content, food, beer, and, well just about everyting. I am thinking of making a series of pet peeves here on this site. Some will seem like plain rants, and others will be more like tips.
When making comparisons, switch the order of the things you compare like this:
if ('book' == $node->type) {
// Stuff happens
}You might think why? And that looks weird! Yes, it does look a little weird. But I do this to not accidentially assign the
$node->type the value I am comparing it with. It is hell to find an error like this when debugging:if ($node->type = 'book') {
// Stuff happens whether you like it or not
}Backup and migrate module + Dropbox = peace of mind
Submitted by naxoc on 16 November, 2009 - 22:06The backup and migrate module is truly sweet. We all know that it is a *really* good idea to back up data. But if you are like me - you forgot to do it or just don't do it for some lame reason. So backups should be automated. The backup and migrate module does exactly that - it can be configured to run every X hours if you have cron (and you should have) running on your site.
The module makes a dump of the database and puts it in a folder in the files folder of the site. Even if you use the public download method, the security is OK - a .htacces file put in the folder by the backup and migrate module and dissalows access to the folder's content. Read more »
Hide Drupal files with .htaccess
Submitted by naxoc on 14 November, 2009 - 00:50If one goes to somedrupalsite.com/CHANGELOG.txt - it is normally possible to read the file and see what version of Drupal the site is running. If you don't want everybody to see what version you are running, it is a good idea to cloak the *.txt files in the Drupal install.
Using rewrite rules in .htaccess, the *.txt files in Drupal can be hidden. I use a 403 - forbidden on these files. That is what the [F] means See the Apache documentation on RewriteRule for more options.
Read more »
# No need for the common visitor to read these files.
# They can just go download their own Drupal. It's
# free and everything.
RewriteRule ^(.*)CHANGELOG\.txt$ - [F]
RewriteRule ^(.*)INSTALL\.mysql\.txt$ - [F]


Recent comments
21 weeks 6 days ago