Resetting hook_update_N module schema

While I’m developing and testing a hook_update_N() function for my module, there are several ways to reset the schema_version in the system database table. The manual way:

update system set schema_version=0 where name='mymodule';

Or the automated way…throw a Drupal Update Exception:

 * Comment on what this update does
function mymodule_update_7001(&$sandbox) {
  throw new DrupalUpdateException('Ignore error while testing update.');

Caveat: this is only useful for testing prior to actual committing to the changes, once you make database schema or node changes, throwing the exception could cause your database to corrupt.

Drush aliases and Multi-Site

As a Drupal administrator, Drush aliases is a tool I cannot live without. It provides a way for me to connect to any Drupal site on any environment and run drush commands. The only requirement is that I have SSH access to those servers.

Anyone who has worked with Drush and Drupal multi-site should be aware of the @sites shortcut, which allows you to run Drush commands on all your sites as a single command. However, the @sites shortcut is the same format as the Drush remote alias format, @example, which causes Drush to not recognize the multi-site shortcut. So for instance:

$ drush @sites cache-clear all

Won’t work. Instead use the following simple fix:

$ drush "@sites cache-clear all"

And now Drush will pass everything within the quotes to the remote server.

Hope this helps!!

Update: Due to a bug with how the uri is passed to SSH, you will need to use the latest dev version of Drush 7

Case Sensitivity on Git for Macs

Today I ran into an issue with git and case sensitivity on Macs. Although Macs preserve case, their filesystems is case insensitive. So something like:


is equivalent to:


However, they are completely different when deployed to a linux server. Therefore it completely ignored any attempt to change the case and Drupal was actually using “themes/ODOC” instead of the correct “themes/odoc”. If you ever run into this issue, I found this blog entry to be extremely valuable:

NetBeans Local History to the rescue

I did not realize the power of git reset. If you need to do a git reset on your working copy and you have modified (tracked, but uncommitted) changes, then git reset will blow away all your changes without warning.

To recover your changes:
If your IDE doesn’t do local backups, then your changes are lost forever. However, if you use NetBeans IDE, then you should have no problem recovering your lost changes. Ever since NetBeans version 6.x, by default it keeps 7 days work of file changes.

In order to view your file’s local history, make sure the file is open and click Team -> Local History -> Show Local History. NetBeans should give you a diff breakdown of your current file with previous timed snapshots. Once you find the snapshot you want, right click the date and choose Revert from History.

Hope this helps!!

Enabling Xdebug for Acquia Dev Desktop

There are three essential tools I use in order to develop Drupal sites: Acquia Dev Desktop, NetBeans IDE, and Xdebug. Xdebug is a great tool to step through your code in order to troubleshoot a bug, however, it comes disabled by default on Acquia Dev Desktop. The following are instructions to enable Xdebug on Acquia Dev Desktop (ADD).

Note: although both ADD and Netbeans are cross-platform applications, these instructions are for Mac OS X. Windows and Linux instructions might differ slightly.

1) Start ADD and click the Settings… button

Acquia Dev Desktop

2) In Settings, click the Config tab

Acquia Dev Desktop Config screen

3) Click the Edit link to the right of PHP

4) After your text editor starts, look for the following line:


and replace with:


5) Save the file and close the text editor

6) Click the OK button and restart the Acquia Drupal Stack

Once you have Xdebug enabled, you should now be able to step through your code on NetBeans. Here are the steps to verify Xdebug is working with NetBeans:

1) After you start NetBeans edit your project’s properties: File -> Project Properties

2) Under Run Configuration change the Project URL from the default URL to Acquia Dev Desktop’s URL (e.g. http://localhost:8082/)

NetBeans - Project Properties

3) Click the OK button

4) Start the project debugger, on the menu click Debug -> Debug Project

5) Look in the NetBeans status bar for netbeans-xdebug running

NetBeans Debugging Status Bar

6) Once xdebug is running, you can now step through your code by clicking the Step Through buttons

Netbeans debugger

You should now be stepping through your code. Feel free to step into functions and following the logica flow of your application. More information on PHP debugging with NetBeans can be found here:

Happy Debugging!!!


Drupal DSpace Module Launched

Today I launched my new Drupal DSpace project. There are two modules included in this project, the DSpace module and the DSpace Biblio module.

DSpace Module:
The purpose of the DSpace module is to parse a DSpace REST XML feed using the Feeds module and map the feed items into nodes.

DSpace Biblio Module:
The DSpace Biblio module maps DSpace metadata fields with Biblio fields.

More information can be found here:


Accidentally Adding a Git Submodule

Git LogoRecently I’ve been working on a Drupal project at work and a fellow co-worker wanted to piggy-back resources on a similar project. He sent me over the code for a custom module I was going to use on the project.

Only after committing and pushing the folder from my local git repo to the origin server did I notice the remnants of my co-workers .git folder. This cause git to treat the subfolder as a git submodule and ignore the contents of the subfolder as I push my project to the origin server.

Here is what you need to do in order to remove the submodule and add as a subfolder:

git rm --cached subfolder
git add subfolder
git commit -m "Enter message here"
git push

Now the origin should be able to see the contents of the subfolder.