MT / Perl error: "can't call prepare on ..."

Can anyone offer some insight on this error:

Can't call method "prepare" on an undefined value at lib/MT/ObjectDriver/DBI.pm line 103. at lib/MT.pm line 867Content-Type: text/plain; charset=utf-8 Got an error: Can't call method "prepare" on an undefined value at lib/MT/ObjectDriver/DBI.pm line 103. at lib/MT/App/CMS.pm line 906I’ve been getting it since I upgraded to MT version 3.32; Googling doesn’t find much.

It happens when I save an entry after adding or editing it, but not when I preview those changes. I believe it’s part of the page-rebuilding process (though simply rebuilding files doesn’t trigger it either).

I can’t comment out the offending part of the code (below) without creating other errors:

[code] my($tbl, $sql, $bind) =
$driver->prepare_from_where($class, $terms, $args);
my(%rec, @bind, @cols);
my $cols = $class->column_names;
for my $col (@$cols) {
push @cols, $col;
push @bind, $rec{$col};
}
my $tmp = "select ";
$tmp .= "distinct " if $args->{join} && $args->{join}[3]{unique};
$tmp .= join(’, ', map "${tbl}
$_", @cols) . “\n”;
$sql = $tmp . $sql;
my $dbh = $driver->{dbh};
warn “load - Preparing SQL: $sql” if $MT::DebugMode & 4;

my $sth = $dbh->prepare($sql)
or return $driver->error(MT->translate(“Loading data failed with SQL error [_1]”, $dbh->errstr));

[/code]I’m no Perl guru, but it seems to me that $sql should be defined in the first line of the code snippet.

I ran mt-check and got the all-clear. I ran mt-upgrade and it did what it needed to (doing so subsequently confirms that the database schema is OK). I’m pretty much stumped at this point.

It doesn’t have to do with the argument to the prepare() method.

A method is called based on an an object reference or class name. So the variable must be a reference or a non-empty string. The error here is that $dbh is undefined in the call $dbh->prepare().

And of course its not obvious why $driver->{dbh} is returning a null value. Is it possible the database connection is not being made? Or maybe it is a bug.

:cool: [color=#6600CC]Atropos[/color] | openvein.org

This is helpful – I really appreciate it.

I will take another look at the code, put in some debugging statements, and see what happens.

I’ll let you know what I find.