Skip to content
Permalink
Browse files

Fix error reporting when etc/auth.db missing

  • Loading branch information...
Vojtech Pithart authored and LarsMichelsen committed Jun 12, 2019
1 parent 1bd191d commit 8be537e6af1123287ac74bb145e60a513db63f51
Showing with 10 additions and 4 deletions.
  1. +5 −0 .gitignore
  2. +5 −4 share/server/core/classes/CorePDOHandler.php
@@ -6,6 +6,11 @@
.metadata
.site
install.log
launch.json

# Exclude actual config files
etc/auth.db
etc/perms.db

# Exclude main configuration file
etc/nagvis.ini.php
@@ -261,6 +261,7 @@ public function open($driver, $params, $username, $password) {
}
$drv_data = self::$DRIVERS[$driver];
$dsn = "$driver:".$drv_data['build_dsn']($params);
$this->dsn = $dsn;
try {
$this->DB = new PDO($dsn, $username, $password, array(
@@ -270,12 +271,12 @@ public function open($driver, $params, $username, $password) {
));
} catch(PDOException $e) {
error_log('Could not initialize a database connection: '.$e->getMessage());
$this->lastErrorInfo = $e->getMessage();
return false;
}
}
if($this->DB === false || $this->DB === null)
return false;
$this->dsn = $dsn;
$this->driver = $driver;
$this->data = $drv_data;
$this->updating = false;
@@ -356,7 +357,7 @@ public function error() {
if (isset($this->lastErrorInfo))
return $this->lastErrorInfo;
else
return $this->DB->errorInfo();
return $this->DB ? $this->DB->errorInfo() : '';
}
public function errorString() {
@@ -618,7 +619,7 @@ public function createInitialDb() {
// Access control: View URLs e.g. in rotation pools
$this->queryFatal('-perm-add', array('mod' => 'Url', 'act' => 'view', 'obj' => '*'));
// Assign the new permission to the managers, users, guests
$this->queryFatal('-create-pop-roles-perms-3', array(
'r1' => 'Managers', 'r2' => 'Users (read-only)', 'r3' => 'Guests',

0 comments on commit 8be537e

Please sign in to comment.
You can’t perform that action at this time.