If we fail to connect, the dbh->trace will crash

pull/2090/head^2
Isaac Connor 2018-04-30 13:02:13 -04:00
parent c3b6cd4bab
commit 8e5ee94420
1 changed files with 13 additions and 13 deletions

View File

@ -77,39 +77,39 @@ sub zmDbConnect {
}
my $options = shift;
if ( ( ! defined( $dbh ) ) or ! $dbh->ping() ) {
if ( ( !defined($dbh) ) or ! $dbh->ping() ) {
my ( $host, $portOrSocket ) = ( $ZoneMinder::Config::Config{ZM_DB_HOST} =~ /^([^:]+)(?::(.+))?$/ );
my $socket;
if ( defined($portOrSocket) ) {
if ( $portOrSocket =~ /^\// ) {
$socket = ";mysql_socket=".$portOrSocket;
$socket = ';mysql_socket='.$portOrSocket;
} else {
$socket = ";host=".$host.";port=".$portOrSocket;
$socket = ';host='.$host.';port='.$portOrSocket;
}
} else {
$socket = ";host=".$Config{ZM_DB_HOST};
$socket = ';host='.$Config{ZM_DB_HOST};
}
my $sslOptions = "";
my $sslOptions = '';
if ( $Config{ZM_DB_SSL_CA_CERT} ) {
$sslOptions = ';'.join(';',
"mysql_ssl=1",
"mysql_ssl_ca_file=".$Config{ZM_DB_SSL_CA_CERT},
"mysql_ssl_client_key=".$Config{ZM_DB_SSL_CLIENT_KEY},
"mysql_ssl_client_cert=".$Config{ZM_DB_SSL_CLIENT_CERT}
'mysql_ssl=1',
'mysql_ssl_ca_file='.$Config{ZM_DB_SSL_CA_CERT},
'mysql_ssl_client_key='.$Config{ZM_DB_SSL_CLIENT_KEY},
'mysql_ssl_client_cert='.$Config{ZM_DB_SSL_CLIENT_CERT}
);
}
$dbh = DBI->connect( "DBI:mysql:database=".$Config{ZM_DB_NAME}
$dbh = DBI->connect( 'DBI:mysql:database='.$Config{ZM_DB_NAME}
.$socket . $sslOptions . ($options?';'.join(';', map { $_.'='.$$options{$_} } keys %{$options} ) : '' )
, $Config{ZM_DB_USER}
, $Config{ZM_DB_PASS}
);
$dbh->trace( 0 );
$dbh->trace(0) if $dbh;
}
return( $dbh );
}
return $dbh;
} # end sub zmDbConnect
sub zmDbDisconnect {
if ( defined( $dbh ) ) {