The Case of the Missing Div... (or not)

I’ve filed this under “Cool Bugs”, but I’m just not sure exactly what the bug was in...

This morning I was wondering why anonymous users of one of my Drupal web sites couldn’t see the mailing list subscription box in the right sidebar. Then I realised that the right sidebar wasn’t showing up on the home page. It was showing up on all other pages, just not the front page.

I tried different themes but the problem persisted. I tried turning off various modules, particularly those that play with the front page but the problem persisted.

In desperation I tried clearing all the cache tables, turning off caching and rebuilding node permissions. Nothing worked.

At this point I started to suspect the worst... that there was a bug in the HTML that was being created by Drupal, perhaps due to a version mismatch between modules or something equally insidious. A quick look at the HTML using Firebug confirmed my suspicions: there was a missing </div> tag... (or, as I later came to think of it, a mismatch in the number of divs... oh how important it is to define the problem correctly when searching for a solution :-).

So I started the arduous task of comparing the HTML of a “working” page with the broken front page.

After about ten minutes of trawling through HTML a thought occurred to me: perhaps the problem was that an extra <div> tag had somehow crept into the output!

As it happens, I had recently installed the mailhandler module to allow people to post entries by email. Somebody had e-mailed from a rich mail client and the resulting HTML was very verbose. I don’t know if the e-mail application was to blame for the extra <div> tag, because I later edited the node with FCKEditor, which may also have contributed to the problem. At any rate, removing that node from the front page fixed the problem.

The really weird thing is that the front page had been rendering fine with the dodgy node included when logged in, which is why I hadn’t noticed (for some time, unfortunately) that the right sidebar had disappeared. D’oh!

Note to self: Disable “Full HTML” input filter for all but administrator. :-)

Yet Another Programming Blog

Where James Gordon rambles about PHP and web development in general.

Find me on Twitter Find me on Stack Exchange Find me on Github Subscribe