openrat-cms

OpenRat Content Management System
git clone http://git.code.weiherhei.de/openrat-cms.git
Log | Files | Refs | README

commit b2db938bc5cf7ae728e66e1b1028349b8ad5fcdc
parent 8ed397807c20f7a130282377ed20e854d0618c82
Author: Jan Dankert <develop@jandankert.de>
Date:   Sun,  4 Oct 2020 21:24:40 +0200

Fix: Throw correct DatabaseException

Diffstat:
Mmodules/cms/Dispatcher.class.php | 3++-
Mmodules/database/driver/PDODriver.class.php | 3+--
Mmodules/language/Messages.class.php | 1-
Mmodules/language/lang-cn.php | 1-
Mmodules/language/lang-de.php | 1-
Mmodules/language/lang-en.php | 1-
Mmodules/language/lang-es.php | 1-
Mmodules/language/lang-fr.php | 1-
Mmodules/language/lang-it.php | 1-
Mmodules/language/lang-ru.php | 1-
Mmodules/language/language.yml | 3---
Mmodules/util/FileUtils.class.php | 13++++++++-----
12 files changed, 11 insertions(+), 19 deletions(-)

diff --git a/modules/cms/Dispatcher.class.php b/modules/cms/Dispatcher.class.php @@ -15,6 +15,7 @@ use cms\base\Version; use configuration\ConfigurationLoader; use database\Database; use cms\update\Update; +use language\Messages; use modules\cms\base\HttpRequest; use util\Http; use logger\Logger; @@ -399,7 +400,7 @@ class Dispatcher Session::setDatabase( $db ); }catch(\Exception $e) { - throw new UIException('DATABASE_ERROR_CONNECTION', $e->getMessage(),$e); + throw new UIException(Messages::DATABASE_CONNECTION_ERROR, $e->getMessage(),$e); } diff --git a/modules/database/driver/PDODriver.class.php b/modules/database/driver/PDODriver.class.php @@ -101,8 +101,7 @@ class PDODriver } catch(\PDOException $e) { - Logger::warn( "Could not connect to database with dsn=$url and user=$user: ".$e->getMessage() ); - throw new DatabaseException("Could not connect to database on host $url.",0,$e); + throw new DatabaseException("Could not connect to database on host $url.",$e); } // This should never happen, because PDO should throw an exception if the connection fails. diff --git a/modules/language/Messages.class.php b/modules/language/Messages.class.php @@ -978,7 +978,6 @@ class Messages { const COPIED = 'COPIED'; const DUPLICATE_INPUT = 'DUPLICATE_INPUT'; const DATABASE_CONNECTION_ERROR = 'DATABASE_CONNECTION_ERROR'; - const ERROR_DATABASE_CONNECTION = 'ERROR_DATABASE_CONNECTION'; const ERROR_DATABASE = 'ERROR_DATABASE'; const DONE = 'DONE'; const GROUPS_MAY_CONFLICT_WITH_LDAP = 'GROUPS_MAY_CONFLICT_WITH_LDAP'; diff --git a/modules/language/lang-cn.php b/modules/language/lang-cn.php @@ -978,7 +978,6 @@ function language() { return array( 'COPIED'=>'was copied', 'DUPLICATE_INPUT'=>'Duplicate Input detected.', 'DATABASE_CONNECTION_ERROR'=>'The connection to the database could not be established.', -'ERROR_DATABASE_CONNECTION'=>'The connection to the database could not be established.', 'ERROR_DATABASE'=>'The database query could not executed.', 'DONE'=>'Finished successful', 'GROUPS_MAY_CONFLICT_WITH_LDAP'=>'The user-group-relations my conflict with the directory service. Memberships were synchronized at login time.', diff --git a/modules/language/lang-de.php b/modules/language/lang-de.php @@ -978,7 +978,6 @@ function language() { return array( 'COPIED'=>'wurde kopiert.', 'DUPLICATE_INPUT'=>'Ihre Eingabe muss eindeutig sein.', 'DATABASE_CONNECTION_ERROR'=>'Es konnte keine Verbindung zur Datenbank hergestellt werden.', -'ERROR_DATABASE_CONNECTION'=>'Es konnte keine Verbindung zur Datenbank hergestellt werden.', 'ERROR_DATABASE'=>'Es gab einen Fehler bei der Durchführung einer Datenbankanfrage.', 'DONE'=>'Der Vorgang wurde ausgeführt.', 'GROUPS_MAY_CONFLICT_WITH_LDAP'=>'Die in der Benutzerverwaltung eingetragenen Gruppenzugehörigkeiten stehen möglicherweise in Konflikt mit den Gruppenzugehörigkeiten aus dem Verzeichnisdienst. Beim Login ueber den Verzeichnisdienst werden die hier eingetragenenen Gruppenzugehörigkeiten überschrieben.', diff --git a/modules/language/lang-en.php b/modules/language/lang-en.php @@ -978,7 +978,6 @@ function language() { return array( 'COPIED'=>'was copied', 'DUPLICATE_INPUT'=>'Duplicate Input detected.', 'DATABASE_CONNECTION_ERROR'=>'The connection to the database could not be established.', -'ERROR_DATABASE_CONNECTION'=>'The connection to the database could not be established.', 'ERROR_DATABASE'=>'The database query could not executed.', 'DONE'=>'Finished successful', 'GROUPS_MAY_CONFLICT_WITH_LDAP'=>'The user-group-relations my conflict with the directory service. Memberships were synchronized at login time.', diff --git a/modules/language/lang-es.php b/modules/language/lang-es.php @@ -1002,7 +1002,6 @@ MENU_INDEX_ADMINISTRATION_DESC =', 'COPIED'=>'fue copiada', 'DUPLICATE_INPUT'=>'Duplicate Input detected.', 'DATABASE_CONNECTION_ERROR'=>'The connection to the database could not be established.', -'ERROR_DATABASE_CONNECTION'=>'The connection to the database could not be established.', 'ERROR_DATABASE'=>'The database query could not executed.', 'DONE'=>'Finished successful', 'GROUPS_MAY_CONFLICT_WITH_LDAP'=>'The user-group-relations my conflict with the directory service. Memberships were synchronized at login time.', diff --git a/modules/language/lang-fr.php b/modules/language/lang-fr.php @@ -978,7 +978,6 @@ function language() { return array( 'COPIED'=>'a été copié', 'DUPLICATE_INPUT'=>'Duplicate Input detected.', 'DATABASE_CONNECTION_ERROR'=>'The connection to the database could not be established.', -'ERROR_DATABASE_CONNECTION'=>'The connection to the database could not be established.', 'ERROR_DATABASE'=>'The database query could not executed.', 'DONE'=>'Finished successful', 'GROUPS_MAY_CONFLICT_WITH_LDAP'=>'The user-group-relations my conflict with the directory service. Memberships were synchronized at login time.', diff --git a/modules/language/lang-it.php b/modules/language/lang-it.php @@ -978,7 +978,6 @@ function language() { return array( 'COPIED'=>'è stata copiata', 'DUPLICATE_INPUT'=>'Duplicate Input detected.', 'DATABASE_CONNECTION_ERROR'=>'The connection to the database could not be established.', -'ERROR_DATABASE_CONNECTION'=>'The connection to the database could not be established.', 'ERROR_DATABASE'=>'The database query could not executed.', 'DONE'=>'Finished successful', 'GROUPS_MAY_CONFLICT_WITH_LDAP'=>'The user-group-relations my conflict with the directory service. Memberships were synchronized at login time.', diff --git a/modules/language/lang-ru.php b/modules/language/lang-ru.php @@ -978,7 +978,6 @@ function language() { return array( 'COPIED'=>'копирования', 'DUPLICATE_INPUT'=>'Duplicate Input detected.', 'DATABASE_CONNECTION_ERROR'=>'The connection to the database could not be established.', -'ERROR_DATABASE_CONNECTION'=>'The connection to the database could not be established.', 'ERROR_DATABASE'=>'The database query could not executed.', 'DONE'=>'Finished successful', 'GROUPS_MAY_CONFLICT_WITH_LDAP'=>'The user-group-relations my conflict with the directory service. Memberships were synchronized at login time.', diff --git a/modules/language/language.yml b/modules/language/language.yml @@ -4782,9 +4782,6 @@ DUPLICATE_INPUT: DATABASE_CONNECTION_ERROR: de: Es konnte keine Verbindung zur Datenbank hergestellt werden. en: The connection to the database could not be established. -ERROR_DATABASE_CONNECTION: - en: The connection to the database could not be established. - de: Es konnte keine Verbindung zur Datenbank hergestellt werden. ERROR_DATABASE: en: The database query could not executed. de: Es gab einen Fehler bei der Durchführung einer Datenbankanfrage. diff --git a/modules/util/FileUtils.class.php b/modules/util/FileUtils.class.php @@ -77,12 +77,13 @@ class FileUtils /** - * Liest die Dateien aus dem angegebenen Ordner in ein Array. + * Gets all files from a directory. * - * @param $dir string Verzeichnis, welches gelesen werden soll - * @return array Liste der Dateien im Ordner + * @param $dir string directory to read + * @param null $extension only files with this extension (default: all files) + * @return array List of all files in this directory */ - public static function readDir($dir) + public static function readDir($dir,$extension=null) { $dir = FileUtils::slashify($dir); $dateien = array(); @@ -94,7 +95,9 @@ class FileUtils if ($dh = opendir($dir)) { while (($verzEintrag = readdir($dh)) !== false) { if (substr($verzEintrag, 0, 1) != '.') { - $dateien[] = $verzEintrag; + if ( !$extension || substr($verzEintrag,(strlen($extension)+1)*-1) == '.'.$extension ) { + $dateien[] = $verzEintrag; + } } } closedir($dh);