Drupal Development Blog is brought to you by Face 2 Interface, home of open source applications for your website.

My First Kludge

The history of the kludge apparently may go back as early as the 1940's.

Every computer programmer is all too familiar with what a kludge is, and how undesirable it is to be a part of one. On the flip side is the importance that software work well and consistently.

Here's what happened.

I wanted to check out the node access module and downloaded the 4.7.x-1.1 release, installing it on my 5.1 system. The reason is that this is the only official release available right now.

After uploading and enabling from the admin >> modules screen I went to configure it, and started getting error messages. I tried uninstalling from the admin screen but still had problems, so I then went to phpMyAdmin and saw the nodeaccess table was still there. So I dropped it. That's when the errors really started to fly.

Next I downloaded and installed the 5.x-1.x-dev release which is not an official release, but hoped that might straighten things out. It didn't. I installed, then uninstalled. The nodeaccess table still was on my database and there was an error with every click on my site:

user warning: Table 'faceup2i_drpl1.node_access' doesn't exist
query: SELECT COUNT(*) FROM node_access WHERE nid = 0 AND ((gid = 0 AND realm = 'all')) AND grant_view >= 1 in /home/faceup2i/public_html/drupal/includes/database.mysql.inc on line 172.

Not good. Can't have this type of stuff showing up everytime someone clicks over to my website. Looking in the code of the MySQL include file I tinkered around a bit and ended up wrapping this little if statement around the code that was printing the error:

// override nodeaccess table related errors 2007-08-06 M. Landman
if ( ! preg_match ("/node_access/i", $query) ) {
trigger_error(check_plain(mysql_error($active_db) ."\nquery: ". $query), E_USER_WARNING);
return FALSE;
}

Reply

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options