Webmin / MySQL / DBD::mysql - undefined variable Perl error.

Technical Q&A involving operating systems, networking, software, and hardware issues.

Moderator: jasonb

Post Reply
User avatar
jasonb
Site Administrator
Posts: 105
Joined: Tue Apr 22, 2003 1:54 pm
Location: Toronto, Canada
Contact:

Webmin / MySQL / DBD::mysql - undefined variable Perl error.

Post by jasonb »

I recently upgraded to the latest Perl module of DBD::mysql (2.9002). After having done so, I discovered that I was unable to access the "Permission" sub-modules of Webmin's MySQL interface. When trying to do so, I got some kind of error message involving Perl, a hash, and not being able to use an undefined variable on line 113 of /usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi/DBD/mysql.pm.

After trying to reinstall the Perl module to no better effect, I finally stumbled onto the solution. Here's what that section of code, from that file, looks like:

Code: Select all

# create a 'blank' dbh
my($this, $privateAttrHash) = (undef, $attrhash);
$privateAttrHash = { %$privateAttrHash,
    'Name' => $dsn,
    'user' => $username,
    'password' => $password
};
Line 113 is the line that starts "$privateAttrHash". I have only a general idea of what this bit of code means (I know it's a way of defining an array variable with information about the database that's being accessed). However, when trying to troubleshoot "undefined variable" that one thing that stood out was the "(undef, $attrhash)" section of code. "Undef", to me, read a lot like "undefined".

So, I tried the trial and error method of replacing "undef" with "def" - thinking, in a very uneducated, shot in the dark fashion, that this might actually define the variable. To my total amazement this actually worked. After having done that, Webmin works just fine when I use the "Permission" sub-modules.

I'm left wondering why the latest version of module would, by default, do something so silly as to declare a variable without defining it, and causing other things to break. I'm equally confused that this would even be a possibility - if you declare a variable you should, by default, be defining it - shouldn't you?
Last edited by jasonb on Sat Nov 01, 2003 6:14 pm, edited 1 time in total.
User avatar
jasonb
Site Administrator
Posts: 105
Joined: Tue Apr 22, 2003 1:54 pm
Location: Toronto, Canada
Contact:

Post by jasonb »

Oops - not so fast.

While this fixed Webmin, it broke Movable Type (my blog software).

With this change, when I try to access the administrative portion of MT, I get an error message about a "bare def". Changing it back again (to "undef") allows Movable Type to work again.

So - either Webmin works or Movable Type works, but not both. This pretty much sucks...
User avatar
jasonb
Site Administrator
Posts: 105
Joined: Tue Apr 22, 2003 1:54 pm
Location: Toronto, Canada
Contact:

Post by jasonb »

Okay, problem solved.

I re-installed the older version of the module and checked the code there. Then I reinstalled the new version again and simply replaced the new code with the old code which looked like this:

Code: Select all

# create a 'blank' dbh
   my($this, $privateAttrHash);
   $privateAttrHash = {
       'Name' => $dsn,
       'user' => $username,
       'password' => $password
   };
Everything now works again without any errors.
Post Reply