Modify Drupal 7 text field maximum length

When creating a text field in Drupal 7, you must a choose a maximum length for your data. As soon as you create any data for this field, the maximum length become immutable in the Drupal field settings.

It's understandable that this would be disabled for decreasing the maximum length because it could results in a loss of data, however, it should be possible to increase the maximum length for any field.


A Subversion diff with only filenames

I had about 100 commits to Subversion for the next release on a project and wanted to see all the files changed since the last release. I finally found a solution with the --summarize argument for svn diff. The following command will list all files changed from revision 16074 to the latest commit.

svn diff --summarize -r 16074:HEAD

Drupal Security at Drupal Camp Wisconsin

Today a presented on Security and Drupal at Drupal Camp Wisconsin. Great group with great questions and feedback afterwards. Here are the slides in PDF form for those interested.

Apache automatically adds .html

I had an issue with Apache that was driving me nuts. I've got a Drupal site with a page that uses the path /new. Simple enough. However, I also have a static HTML page in the root of the site at the path /new.html. Every time I'd click a link to /new it would render the static HTML page, though not via a redirect. The browser address bar would still show /new, but it would show me the new.html file.


Drush PHP Memory Limit

I was banging my head against the wall this morning because Drush kept telling me that I was exhausting PHP's memory at 128MB. I finally figured out the problem and thought I'd share for others searching the internet for a solution.

The first thing I did was check my php.ini file. Sometimes PHP on the command line will use a different php.ini file than the Apache version. In my case, the php.ini file is shared for both.

Render a Single Field in Drupal 7

I needed a simple method to render a single field from a node object in Drupal 7, but couldn't find any good answers by searching the web.

Here is the solution I finally came to by searching the documentation:

  // Render the field named "field_image"
  $field = field_view_value('node', $node, 'field_image', $node->field_image[$node->language][0]);
  print render($field);

Command line bookmarks / shortcut script

I grew tired of typing some of the same long commands into my terminal; especially ssh commands to log into a myriad of remote machines. I needed a way to create bookmarks or shortcuts to these long commands that I use on a regular basis. So several month ago I decided solving this problem would be a good opportunity to dabble into some Ruby (which I'd been meaning to do for a long time).

The script is freely available on

I was able to find a ruby command-line template as a starting point (I can't recall where I got the template from).


Copying objects in PHP 5 using clone

In PHP 4 object variables were simple. Assigning one object to another worked exactly as you'd expect.

$object1->title = "Title One";
$object2 = $object1;
$object2->title = "Title Two";
print $object1->title; // returns "Title One"

You could make a copy of the original, and modify your copy with full assurance that your original would remain untouched.

That changed in PHP 5. Now when you assign an object to a new variable.

Views Index Hint module

On one of my projects, I cam across a certain performance edge case on a site with a large volume of data. For whatever reason, the MySQL optimizer refused to use the fastest index in a handful of views queries, causing these queries to be painfully slow.

Here is a simplified example of a query generated by views:

SELECT nid, title FROM node WHERE status <> 0 AND type IN ("story") ORDER BY created DESC;

When viewing the explain plan for this query, it shows my that MySQL is choosing to use the node_type index instead of node_created.

Drush command to close comments

There is a great module called Comment Closer that allows you to automatically close comments on certain nodes after a certain time period.

On a recent project, needed to come up with a solution to close comments apart from a cron job and without adding yet another module to the site.

I decided to make use of drush and created my first drush command.

With the drush file properly installed, I can now execute the following command from the site root directory:

drush comment-close --days=7 --types=story,blog

This command will close comments on all story and blog nodes that are older than 7 days.