Archive for July, 2007

Turn on VIM Syntax Highlighting

I have noticed that a few people have come to my blog hoping to find out why their VIM doesn’t have syntax highlighting at all. Well, if the syntax highlighting is disabled, you just go in the command mode and do:

:syntax on

Of course, you wouldn’t want to do that every time you edit a file. To make it default, just create/edit the file ~/.vimrc and put “syntax on ” on a line of itself.

July 26, 2007 at 6:55 am Leave a comment

Bugzilla 2.18.3 Stopped Working

At work we use Mozilla’s Bugzilla as our bug tracking solution. It is a great tool coming from the open-source community, by the way. We were still stuck on version 2.18.3 since we saw no need to upgrade it. However, today my co-worker told me he ran into an error while submitting a new bug. I quickly tried to see what the problem was and as soon as I did a search on open bugs, I saw:

Software error:

DBD::mysql::st execute failed: Unknown column 'bugs.bug_id' in 'on clause' [for Statement "SELECT bugs.bug_id, bugs.bug_severity, bugs.priority, bugs.bug_status, bugs.resolution, bugs.bug_severity, bugs.priority, bugs.rep_platform, map_assigned_to.login_name, bugs.bug_status, bugs.resolution, bugs.short_desc FROM bugs, profiles AS map_assigned_to  LEFT JOIN bug_group_map  ON bug_group_map.bug_id = bugs.bug_id  WHERE bugs.assigned_to = map_assigned_to.userid AND (bugs.bug_status IN ('UNCONFIRMED','NEW','ASSIGNED','REOPENED')) AND bugs.creation_ts IS NOT NULL AND ((bug_group_map.group_id IS NULL)) GROUP BY bugs.bug_id"] at Bugzilla/DB.pm line 62
	Bugzilla::DB::SendSQL('SELECT bugs.bug_id, bugs.bug_severity, bugs.priority, bugs.bu...') called at [webroot location]/buglist.cgi line 766

That is odd. First thing I checked was to see if it was a MySQL permission issue. Nope, the user permission settings were just fine. If I ran that SQL statement manually as the Bugzilla user at MySQL console, I got:

ERROR 1054 (42S22): Unknown column 'bugs.bug_id' in 'on clause'

Ok, that showed me something was not right with MySQL, rather than Bugzilla itself (or the Perl DBI and DBD::mysql modules). I did a quick Google search on that “ERROR 1054″ and it turned out that it was a bug in MySQL5 with the way it interprets a SQL statement when JOIN is involved. To confirm that, I changed the SQL statement from:

SELECT bugs.bug_id, bugs.bug_severity, bugs.priority, bugs.bug_status, bugs.resolution, bugs.bug_severity, bugs.priority, bugs.rep_platform, map_assigned_to.login_name, bugs.bug_status, bugs.resolution, bugs.short_desc FROM bugs, profiles AS map_assigned_to  LEFT JOIN bug_group_map  ON bug_group_map.bug_id = bugs.bug_id  WHERE bugs.assigned_to = map_assigned_to.userid AND (bugs.bug_status IN ('UNCONFIRMED','NEW','ASSIGNED','REOPENED')) AND bugs.creation_ts IS NOT NULL AND ((bug_group_map.group_id IS NULL)) GROUP BY bugs.bug_id

To (notice the parentheses surrounding “bugs, profiles AS map_assigned_to”):

SELECT bugs.bug_id, bugs.bug_severity, bugs.priority, bugs.bug_status, bugs.resolution, bugs.bug_severity, bugs.priority, bugs.rep_platform, map_assigned_to.login_name, bugs.bug_status, bugs.resolution, bugs.short_desc FROM (bugs, profiles AS map_assigned_to)  LEFT JOIN bug_group_map  ON bug_group_map.bug_id = bugs.bug_id  WHERE bugs.assigned_to = map_assigned_to.userid AND (bugs.bug_status IN ('UNCONFIRMED','NEW','ASSIGNED','REOPENED')) AND bugs.creation_ts IS NOT NULL AND ((bug_group_map.group_id IS NULL)) GROUP BY bugs.bug_id

That modified SQL statement worked fine. This also means that to make our version of Bugzilla work with MySQL 5, those statements will need to be changed to work around the bug. That is not an acceptable solution for us to do. I’m sure the Bugzilla team was aware of the problem and should have a solution for it in the latest version.

I went ahead and upgraded to latest version of Bugzilla which is 3.0. Viola! It worked. Bugzilla now works happily with MySQL 5 and my collegeue can finally go back to his bug-crushing activity. :)

July 16, 2007 at 9:39 pm 2 comments

VIM Syntax Highlighting

For anyone who uses CakePHP 1.2 branch should know the template/view files now end with the .ctp extension (instead of .thtml). However, Vim doesn’t recognize that extension so syntax highlighting won’t be activated when you edit the files in Vim. Last thing I want to do is to code in Vim without syntax highlighting! To remedy the problem, I simply modified the filetype file to tell Vim to syntax highlight .ctp files as .php files. To do so in Ubuntu 7.04, open the filetype:

vi /usr/share/vim/vimcurrent/filetype.vim

Search for the string “php” and you will find the lines you need to modify and just add *.ctp like below:

" Php, php3, php4, etc.
au BufNewFile,BufRead *.ctp,*.php,*.phpd               setf php

Next time you open any .ctp file you will be greeted with those beautiful colors again that inspire us to write more wonderful code in PHP. :)

July 11, 2007 at 6:26 am 5 comments


 

July 2007
M T W T F S S
« Jun   Aug »
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

Recent Posts

Top Clicks

  • None

Feeds


Follow

Get every new post delivered to your Inbox.