From 5944b33d5624e1ca76d3ff01cdb99fe1d0197d12 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Tue, 20 Oct 2015 08:53:57 +0200 Subject: [PATCH] [OCI setup] remove static logger/config calls * logger/config object are already injected - this only uses it --- lib/private/setup/oci.php | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/lib/private/setup/oci.php b/lib/private/setup/oci.php index 1e1eb1ff54..c3f0356716 100644 --- a/lib/private/setup/oci.php +++ b/lib/private/setup/oci.php @@ -40,7 +40,7 @@ class OCI extends AbstractDatabase { // allow empty hostname for oracle $this->dbHost = $config['dbhost']; - \OC_Config::setValues([ + $this->config->setSystemValues([ 'dbhost' => $this->dbHost, 'dbtablespace' => $this->dbtablespace, ]); @@ -66,7 +66,7 @@ class OCI extends AbstractDatabase { } else { $easy_connect_string = '//'.$e_host.'/'.$e_dbname; } - \OCP\Util::writeLog('setup oracle', 'connect string: ' . $easy_connect_string, \OCP\Util::DEBUG); + $this->logger->debug('connect string: ' . $easy_connect_string, ['app' => 'setup.oci']); $connection = @oci_connect($this->dbUser, $this->dbPassword, $easy_connect_string); if(!$connection) { $errorMessage = $this->getLastError(); @@ -93,7 +93,7 @@ class OCI extends AbstractDatabase { if (!$stmt) { $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '
'; $entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '
'; - \OCP\Util::writeLog('setup.oci', $entry, \OCP\Util::WARN); + $this->logger->warning($entry, ['app' => 'setup.oci']); } $result = oci_execute($stmt); if($result) { @@ -116,7 +116,7 @@ class OCI extends AbstractDatabase { } } - \OC_Config::setValues([ + $this->config->setSystemValues([ 'dbuser' => $this->dbUser, 'dbname' => $this->dbName, 'dbpassword' => $this->dbPassword, @@ -131,9 +131,9 @@ class OCI extends AbstractDatabase { oci_close($connection); // connect to the oracle database (schema=$this->dbuser) an check if the schema needs to be filled - $this->dbUser = \OC_Config::getValue('dbuser'); + $this->dbUser = $this->config->getSystemValue('dbuser'); //$this->dbname = \OC_Config::getValue('dbname'); - $this->dbPassword = \OC_Config::getValue('dbpassword'); + $this->dbPassword = $this->config->getSystemValue('dbpassword'); $e_host = addslashes($this->dbHost); $e_dbname = addslashes($this->dbName); @@ -155,7 +155,7 @@ class OCI extends AbstractDatabase { if (!$stmt) { $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '
'; $entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '
'; - \OCP\Util::writeLog('setup.oci', $entry, \OCP\Util::WARN); + $this->logger->warning( $entry, ['app' => 'setup.oci']); } $result = oci_execute($stmt); @@ -178,14 +178,14 @@ class OCI extends AbstractDatabase { if (!$stmt) { $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '
'; $entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '
'; - \OCP\Util::writeLog('setup.oci', $entry, \OCP\Util::WARN); + $this->logger->warning($entry, ['app' => 'setup.oci']); } oci_bind_by_name($stmt, ':un', $name); $result = oci_execute($stmt); if(!$result) { $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '
'; $entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '
'; - \OCP\Util::writeLog('setup.oci', $entry, \OCP\Util::WARN); + $this->logger->warning($entry, ['app' => 'setup.oci']); } if(! oci_fetch_row($stmt)) { @@ -196,7 +196,8 @@ class OCI extends AbstractDatabase { if (!$stmt) { $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '
'; $entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '
'; - \OCP\Util::writeLog('setup.oci', $entry, \OCP\Util::WARN); + $this->logger->warning($entry, ['app' => 'setup.oci']); + } //oci_bind_by_name($stmt, ':un', $name); $result = oci_execute($stmt); @@ -204,7 +205,8 @@ class OCI extends AbstractDatabase { $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '
'; $entry .= $this->trans->t('Offending command was: "%s", name: %s, password: %s', array($query, $name, $password)) . '
'; - \OCP\Util::writeLog('setup.oci', $entry, \OCP\Util::WARN); + $this->logger->warning($entry, ['app' => 'setup.oci']); + } } else { // change password of the existing role $query = "ALTER USER :un IDENTIFIED BY :pw"; @@ -212,7 +214,7 @@ class OCI extends AbstractDatabase { if (!$stmt) { $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '
'; $entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '
'; - \OCP\Util::writeLog('setup.oci', $entry, \OCP\Util::WARN); + $this->logger->warning($entry, ['app' => 'setup.oci']); } oci_bind_by_name($stmt, ':un', $name); oci_bind_by_name($stmt, ':pw', $password); @@ -220,7 +222,7 @@ class OCI extends AbstractDatabase { if(!$result) { $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '
'; $entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '
'; - \OCP\Util::writeLog('setup.oci', $entry, \OCP\Util::WARN); + $this->logger->warning($entry, ['app' => 'setup.oci']); } } // grant necessary roles @@ -229,14 +231,14 @@ class OCI extends AbstractDatabase { if (!$stmt) { $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '
'; $entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '
'; - \OCP\Util::writeLog('setup.oci', $entry, \OCP\Util::WARN); + $this->logger->warning($entry, ['app' => 'setup.oci']); } $result = oci_execute($stmt); if(!$result) { $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '
'; $entry .= $this->trans->t('Offending command was: "%s", name: %s, password: %s', array($query, $name, $password)) . '
'; - \OCP\Util::writeLog('setup.oci', $entry, \OCP\Util::WARN); + $this->logger->warning($entry, ['app' => 'setup.oci']); } }