From 21e75158f4107b88d7cfc14ca1aa7867885765f3 Mon Sep 17 00:00:00 2001 From: Davide Franco Date: Sun, 26 Jun 2011 17:34:08 +0200 Subject: [PATCH] bacula-web: Fixed php bugs in Bweb class - Added new function TriggerDBError() --- gui/bacula-web/includes/bweb.inc.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/gui/bacula-web/includes/bweb.inc.php b/gui/bacula-web/includes/bweb.inc.php index d5918c6fcd..08e221d201 100644 --- a/gui/bacula-web/includes/bweb.inc.php +++ b/gui/bacula-web/includes/bweb.inc.php @@ -328,7 +328,7 @@ class Bweb extends DB die( "Unable to get the pool list from catalog" ); }else { while( $pool = $result->fetchRow(DB_FETCHMODE_ASSOC) ) { - array_push( $pool_list, array( $pool['Name'] => $pool['PoolId'] ) ); + array_push( $pool_list, array( $pool['name'] => $pool['poolid'] ) ); } return $pool_list; } @@ -424,12 +424,13 @@ class Bweb extends DB public function CountVolumesByPool( $pool_id ) { - foreach( $pools as $pool_name => $pool ) { + foreach( $pool_id as $pool_name => $pool ) { $query = "SELECT COUNT(*) AS nb_vol FROM Media WHERE PoolId = '$pool_id'"; $result = $this->db_link->query( $query ); if( PEAR::isError( $result ) ) { - die("Unable to get volume number from catalog"); + $this->TriggerDBError( 'Unable to get volume number from catalog', $result ); + //die("Unable to get volume number from catalog"); }else{ $nb_vol = $result->fetchRow(DB_FETCHMODE_ASSOC); return array( $pool_name, $nb_vol['nb_vol'] ); @@ -558,5 +559,15 @@ class Bweb extends DB return array( $day, $stored_files ); } } + + private function TriggerDBError( $message, $db_error) + { + echo 'Error: ' . $message . '
'; + echo 'Standard Message: ' . $db_error->getMessage() . "\n"; + echo 'Standard Code: ' . $db_error->getCode() . "\n"; + echo 'DBMS/User Message: ' . $db_error->getUserInfo() . "\n"; + echo 'DBMS/Debug Message: ' . $db_error->getDebugInfo() . "\n"; + exit; + } } // end class Bweb ?> -- 2.39.5