]> git.sur5r.net Git - bacula/bacula/commitdiff
bacula-web: Fixed php bugs in Bweb class
authorDavide Franco <bacula-dev@dflc.ch>
Sun, 26 Jun 2011 15:34:08 +0000 (17:34 +0200)
committerKern Sibbald <kern@sibbald.com>
Sat, 20 Apr 2013 12:49:16 +0000 (14:49 +0200)
 - Added new function TriggerDBError()

gui/bacula-web/includes/bweb.inc.php

index d5918c6fcdf2b5e56a149295cc2996d84c27c440..08e221d2019152c6764b81b3157b4363e18e7cf1 100644 (file)
@@ -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 . '<br />';
+               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
 ?>