From 3338eede3ccb2ead223a46fd537b7504bb4786e0 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 26 Nov 2014 12:30:07 +0100 Subject: [PATCH] Correctly namespace DatabaseSetupException --- lib/private/databasesetupexception.php | 12 ++++++++++++ lib/private/setup.php | 5 +---- lib/private/setup/mssql.php | 2 +- lib/private/setup/mysql.php | 6 +++--- lib/private/setup/oci.php | 6 +++--- lib/private/setup/postgresql.php | 4 ++-- 6 files changed, 22 insertions(+), 13 deletions(-) create mode 100644 lib/private/databasesetupexception.php diff --git a/lib/private/databasesetupexception.php b/lib/private/databasesetupexception.php new file mode 100644 index 00000000000..9235cda8c0e --- /dev/null +++ b/lib/private/databasesetupexception.php @@ -0,0 +1,12 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OC; + +class DatabaseSetupException extends HintException { +} diff --git a/lib/private/setup.php b/lib/private/setup.php index 1125933c8e9..45c97bbd225 100644 --- a/lib/private/setup.php +++ b/lib/private/setup.php @@ -8,9 +8,6 @@ use OCP\IConfig; -class DatabaseSetupException extends \OC\HintException { -} - class OC_Setup { /** @var IConfig */ protected $config; @@ -195,7 +192,7 @@ class OC_Setup { try { $dbSetup->initialize($options); $dbSetup->setupDatabase($username); - } catch (DatabaseSetupException $e) { + } catch (\OC\DatabaseSetupException $e) { $error[] = array( 'error' => $e->getMessage(), 'hint' => $e->getHint() diff --git a/lib/private/setup/mssql.php b/lib/private/setup/mssql.php index b8329f99079..5143545b76f 100644 --- a/lib/private/setup/mssql.php +++ b/lib/private/setup/mssql.php @@ -17,7 +17,7 @@ class MSSQL extends AbstractDatabase { } else { $entry = ''; } - throw new \DatabaseSetupException($this->trans->t('MS SQL username and/or password not valid: %s', array($entry)), + throw new \OC\DatabaseSetupException($this->trans->t('MS SQL username and/or password not valid: %s', array($entry)), $this->trans->t('You need to enter either an existing account or the administrator.')); } diff --git a/lib/private/setup/mysql.php b/lib/private/setup/mysql.php index 5558a2d1e51..8f8d86d388c 100644 --- a/lib/private/setup/mysql.php +++ b/lib/private/setup/mysql.php @@ -9,7 +9,7 @@ class MySQL extends AbstractDatabase { //check if the database user has admin right $connection = @mysql_connect($this->dbhost, $this->dbuser, $this->dbpassword); if(!$connection) { - throw new \DatabaseSetupException($this->trans->t('MySQL/MariaDB username and/or password not valid'), + throw new \OC\DatabaseSetupException($this->trans->t('MySQL/MariaDB username and/or password not valid'), $this->trans->t('You need to enter either an existing account or the administrator.')); } //user already specified in config @@ -96,13 +96,13 @@ class MySQL extends AbstractDatabase { $query = "CREATE USER '$name'@'localhost' IDENTIFIED BY '$password'"; $result = mysql_query($query, $connection); if (!$result) { - throw new \DatabaseSetupException($this->trans->t("MySQL/MariaDB user '%s'@'localhost' exists already.", array($name)), + throw new \OC\DatabaseSetupException($this->trans->t("MySQL/MariaDB user '%s'@'localhost' exists already.", array($name)), $this->trans->t("Drop this user from MySQL/MariaDB", array($name))); } $query = "CREATE USER '$name'@'%' IDENTIFIED BY '$password'"; $result = mysql_query($query, $connection); if (!$result) { - throw new \DatabaseSetupException($this->trans->t("MySQL/MariaDB user '%s'@'%%' already exists", array($name)), + throw new \OC\DatabaseSetupException($this->trans->t("MySQL/MariaDB user '%s'@'%%' already exists", array($name)), $this->trans->t("Drop this user from MySQL/MariaDB.")); } } diff --git a/lib/private/setup/oci.php b/lib/private/setup/oci.php index 23b5232438a..b75b658bae2 100644 --- a/lib/private/setup/oci.php +++ b/lib/private/setup/oci.php @@ -45,14 +45,14 @@ class OCI extends AbstractDatabase { if(!$connection) { $errorMessage = $this->getLastError(); if ($errorMessage) { - throw new \DatabaseSetupException($this->trans->t('Oracle connection could not be established'), + throw new \OC\DatabaseSetupException($this->trans->t('Oracle connection could not be established'), $errorMessage.' Check environment: ORACLE_HOME='.getenv('ORACLE_HOME') .' ORACLE_SID='.getenv('ORACLE_SID') .' LD_LIBRARY_PATH='.getenv('LD_LIBRARY_PATH') .' NLS_LANG='.getenv('NLS_LANG') .' tnsnames.ora is '.(is_readable(getenv('ORACLE_HOME').'/network/admin/tnsnames.ora')?'':'not ').'readable'); } - throw new \DatabaseSetupException($this->trans->t('Oracle username and/or password not valid'), + throw new \OC\DatabaseSetupException($this->trans->t('Oracle username and/or password not valid'), 'Check environment: ORACLE_HOME='.getenv('ORACLE_HOME') .' ORACLE_SID='.getenv('ORACLE_SID') .' LD_LIBRARY_PATH='.getenv('LD_LIBRARY_PATH') @@ -124,7 +124,7 @@ class OCI extends AbstractDatabase { } $connection = @oci_connect($this->dbuser, $this->dbpassword, $easy_connect_string); if(!$connection) { - throw new \DatabaseSetupException($this->trans->t('Oracle username and/or password not valid'), + throw new \OC\DatabaseSetupException($this->trans->t('Oracle username and/or password not valid'), $this->trans->t('You need to enter either an existing account or the administrator.')); } $query = "SELECT count(*) FROM user_tables WHERE table_name = :un"; diff --git a/lib/private/setup/postgresql.php b/lib/private/setup/postgresql.php index 4d0c9b52a4d..3777d1620bc 100644 --- a/lib/private/setup/postgresql.php +++ b/lib/private/setup/postgresql.php @@ -27,7 +27,7 @@ class PostgreSQL extends AbstractDatabase { $connection = @pg_connect($connection_string); if(!$connection) - throw new \DatabaseSetupException($this->trans->t('PostgreSQL username and/or password not valid'), + throw new \OC\DatabaseSetupException($this->trans->t('PostgreSQL username and/or password not valid'), $this->trans->t('You need to enter either an existing account or the administrator.')); } $e_user = pg_escape_string($this->dbuser); @@ -80,7 +80,7 @@ class PostgreSQL extends AbstractDatabase { $connection_string = "host='$e_host' dbname='$e_dbname' user='$e_user' port='$port' password='$e_password'"; $connection = @pg_connect($connection_string); if(!$connection) { - throw new \DatabaseSetupException($this->trans->t('PostgreSQL username and/or password not valid'), + throw new \OC\DatabaseSetupException($this->trans->t('PostgreSQL username and/or password not valid'), $this->trans->t('You need to enter either an existing account or the administrator.')); } $query = "select count(*) FROM pg_class WHERE relname='".$this->tableprefix."users' limit 1"; -- 2.39.5