Skip to content

Commit

Permalink
apc oci pg php-cs-fixer changes
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-davis committed Jun 6, 2018
1 parent b34ef90 commit c0c583a
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 69 deletions.
20 changes: 10 additions & 10 deletions lib/private/Memcache/APC.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,30 @@ class APC extends Cache implements IMemcache {
use CADTrait;

public function get($key) {
$result = apc_fetch($this->getPrefix() . $key, $success);
$result = \apc_fetch($this->getPrefix() . $key, $success);
if (!$success) {
return null;
}
return $result;
}

public function set($key, $value, $ttl = 0) {
return apc_store($this->getPrefix() . $key, $value, $ttl);
return \apc_store($this->getPrefix() . $key, $value, $ttl);
}

public function hasKey($key) {
return apc_exists($this->getPrefix() . $key);
return \apc_exists($this->getPrefix() . $key);
}

public function remove($key) {
return apc_delete($this->getPrefix() . $key);
return \apc_delete($this->getPrefix() . $key);
}

public function clear($prefix = '') {
$ns = $this->getPrefix() . $prefix;
$ns = \preg_quote($ns, '/');
$iter = new \APCIterator('user', '/^' . $ns . '/', APC_ITER_KEY);
return apc_delete($iter);
return \apc_delete($iter);
}

/**
Expand All @@ -70,7 +70,7 @@ public function clear($prefix = '') {
* @return bool
*/
public function add($key, $value, $ttl = 0) {
return apc_add($this->getPrefix() . $key, $value, $ttl);
return \apc_add($this->getPrefix() . $key, $value, $ttl);
}

/**
Expand All @@ -82,7 +82,7 @@ public function add($key, $value, $ttl = 0) {
*/
public function inc($key, $step = 1) {
$this->add($key, 0);
return apc_inc($this->getPrefix() . $key, $step);
return \apc_inc($this->getPrefix() . $key, $step);
}

/**
Expand All @@ -93,7 +93,7 @@ public function inc($key, $step = 1) {
* @return int | bool
*/
public function dec($key, $step = 1) {
return apc_dec($this->getPrefix() . $key, $step);
return \apc_dec($this->getPrefix() . $key, $step);
}

/**
Expand All @@ -107,7 +107,7 @@ public function dec($key, $step = 1) {
public function cas($key, $old, $new) {
// apc only does cas for ints
if (\is_int($old) and \is_int($new)) {
return apc_cas($this->getPrefix() . $key, $old, $new);
return \apc_cas($this->getPrefix() . $key, $old, $new);
} else {
return $this->casEmulated($key, $old, $new);
}
Expand All @@ -129,7 +129,7 @@ public static function isAvailable() {
if (!\function_exists('apc_exists')) {
function apc_exists($keys) {
$result = false;
apc_fetch($keys, $result);
\apc_fetch($keys, $result);
return $result;
}
}
18 changes: 9 additions & 9 deletions lib/private/Memcache/APCu.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,23 @@ class APCu extends Cache implements IMemcache {
use CADTrait;

public function get($key) {
$result = apcu_fetch($this->getPrefix() . $key, $success);
$result = \apcu_fetch($this->getPrefix() . $key, $success);
if (!$success) {
return null;
}
return $result;
}

public function set($key, $value, $ttl = 0) {
return apcu_store($this->getPrefix() . $key, $value, $ttl);
return \apcu_store($this->getPrefix() . $key, $value, $ttl);
}

public function hasKey($key) {
return apcu_exists($this->getPrefix() . $key);
return \apcu_exists($this->getPrefix() . $key);
}

public function remove($key) {
return apcu_delete($this->getPrefix() . $key);
return \apcu_delete($this->getPrefix() . $key);
}

public function clear($prefix = '') {
Expand All @@ -63,7 +63,7 @@ public function clear($prefix = '') {
} else {
$iter = new \APCUIterator('/^' . $ns . '/', APC_ITER_KEY);
}
return apcu_delete($iter);
return \apcu_delete($iter);
}

/**
Expand All @@ -75,7 +75,7 @@ public function clear($prefix = '') {
* @return bool
*/
public function add($key, $value, $ttl = 0) {
return apcu_add($this->getPrefix() . $key, $value, $ttl);
return \apcu_add($this->getPrefix() . $key, $value, $ttl);
}

/**
Expand All @@ -87,7 +87,7 @@ public function add($key, $value, $ttl = 0) {
*/
public function inc($key, $step = 1) {
$this->add($key, 0);
return apcu_inc($this->getPrefix() . $key, $step);
return \apcu_inc($this->getPrefix() . $key, $step);
}

/**
Expand All @@ -98,7 +98,7 @@ public function inc($key, $step = 1) {
* @return int | bool
*/
public function dec($key, $step = 1) {
return apcu_dec($this->getPrefix() . $key, $step);
return \apcu_dec($this->getPrefix() . $key, $step);
}

/**
Expand All @@ -112,7 +112,7 @@ public function dec($key, $step = 1) {
public function cas($key, $old, $new) {
// apc only does cas for ints
if (\is_int($old) and \is_int($new)) {
return apcu_cas($this->getPrefix() . $key, $old, $new);
return \apcu_cas($this->getPrefix() . $key, $old, $new);
} else {
return $this->casEmulated($key, $old, $new);
}
Expand Down
48 changes: 24 additions & 24 deletions lib/private/Setup/OCI.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function setupDatabase($username) {
$easy_connect_string = '//'.$e_host.'/'.$e_dbname;
}
$this->logger->debug('connect string: ' . $easy_connect_string, ['app' => 'setup.oci']);
$connection = @oci_connect($this->dbUser, $this->dbPassword, $easy_connect_string);
$connection = @\oci_connect($this->dbUser, $this->dbPassword, $easy_connect_string);
if (!$connection) {
$errorMessage = $this->getLastError();
if ($errorMessage) {
Expand All @@ -93,15 +93,15 @@ public function setupDatabase($username) {

$query='SELECT count(*) FROM user_role_privs, role_sys_privs'
." WHERE user_role_privs.granted_role = role_sys_privs.role AND privilege = 'CREATE ROLE'";
$stmt = oci_parse($connection, $query);
$stmt = \oci_parse($connection, $query);
if (!$stmt) {
$entry = $this->trans->t('DB Error: "%s"', [$this->getLastError($connection)]) . '<br />';
$entry .= $this->trans->t('Offending command was: "%s"', [$query]) . '<br />';
$this->logger->warning($entry, ['app' => 'setup.oci']);
}
$result = oci_execute($stmt);
$result = \oci_execute($stmt);
if ($result) {
$row = oci_fetch_row($stmt);
$row = \oci_fetch_row($stmt);

if ($row[0] > 0) {
//use the admin login data for the new database user
Expand Down Expand Up @@ -132,7 +132,7 @@ public function setupDatabase($username) {
//FIXME check tablespace exists: select * from user_tablespaces

// the connection to dbname=oracle is not needed anymore
oci_close($connection);
\oci_close($connection);

// connect to the oracle database (schema=$this->dbuser) an check if the schema needs to be filled
$this->dbUser = $this->config->getSystemValue('dbuser');
Expand All @@ -147,24 +147,24 @@ public function setupDatabase($username) {
} else {
$easy_connect_string = '//'.$e_host.'/'.$e_dbname;
}
$connection = @oci_connect($this->dbUser, $this->dbPassword, $easy_connect_string);
$connection = @\oci_connect($this->dbUser, $this->dbPassword, $easy_connect_string);
if (!$connection) {
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";
$stmt = oci_parse($connection, $query);
$stmt = \oci_parse($connection, $query);
$un = $this->tablePrefix.'users';
oci_bind_by_name($stmt, ':un', $un);
\oci_bind_by_name($stmt, ':un', $un);
if (!$stmt) {
$entry = $this->trans->t('DB Error: "%s"', [$this->getLastError($connection)]) . '<br />';
$entry .= $this->trans->t('Offending command was: "%s"', [$query]) . '<br />';
$this->logger->warning($entry, ['app' => 'setup.oci']);
}
$result = oci_execute($stmt);
$result = \oci_execute($stmt);

if ($result) {
$row = oci_fetch_row($stmt);
$row = \oci_fetch_row($stmt);
}
if (!$result or $row[0]==0) {
\OC_DB::createDbFromStructure($this->dbDefinitionFile);
Expand All @@ -178,32 +178,32 @@ private function createDBUser($connection) {
$name = $this->dbUser;
$password = $this->dbPassword;
$query = "SELECT * FROM all_users WHERE USERNAME = :un";
$stmt = oci_parse($connection, $query);
$stmt = \oci_parse($connection, $query);
if (!$stmt) {
$entry = $this->trans->t('DB Error: "%s"', [$this->getLastError($connection)]) . '<br />';
$entry .= $this->trans->t('Offending command was: "%s"', [$query]) . '<br />';
$this->logger->warning($entry, ['app' => 'setup.oci']);
}
oci_bind_by_name($stmt, ':un', $name);
$result = oci_execute($stmt);
\oci_bind_by_name($stmt, ':un', $name);
$result = \oci_execute($stmt);
if (!$result) {
$entry = $this->trans->t('DB Error: "%s"', [$this->getLastError($connection)]) . '<br />';
$entry .= $this->trans->t('Offending command was: "%s"', [$query]) . '<br />';
$this->logger->warning($entry, ['app' => 'setup.oci']);
}

if (! oci_fetch_row($stmt)) {
if (! \oci_fetch_row($stmt)) {
//user does not exist, so let's create them :)
//password must start with alphabetic character in oracle
$query = 'CREATE USER '.$name.' IDENTIFIED BY "'.$password.'" DEFAULT TABLESPACE '.$this->dbtablespace;
$stmt = oci_parse($connection, $query);
$stmt = \oci_parse($connection, $query);
if (!$stmt) {
$entry = $this->trans->t('DB Error: "%s"', [$this->getLastError($connection)]) . '<br />';
$entry .= $this->trans->t('Offending command was: "%s"', [$query]) . '<br />';
$this->logger->warning($entry, ['app' => 'setup.oci']);
}
//oci_bind_by_name($stmt, ':un', $name);
$result = oci_execute($stmt);
$result = \oci_execute($stmt);
if (!$result) {
$entry = $this->trans->t('DB Error: "%s"', [$this->getLastError($connection)]) . '<br />';
$entry .= $this->trans->t('Offending command was: "%s", name: %s, password: %s',
Expand All @@ -212,15 +212,15 @@ private function createDBUser($connection) {
}
} else { // change password of the existing role
$query = "ALTER USER :un IDENTIFIED BY :pw";
$stmt = oci_parse($connection, $query);
$stmt = \oci_parse($connection, $query);
if (!$stmt) {
$entry = $this->trans->t('DB Error: "%s"', [$this->getLastError($connection)]) . '<br />';
$entry .= $this->trans->t('Offending command was: "%s"', [$query]) . '<br />';
$this->logger->warning($entry, ['app' => 'setup.oci']);
}
oci_bind_by_name($stmt, ':un', $name);
oci_bind_by_name($stmt, ':pw', $password);
$result = oci_execute($stmt);
\oci_bind_by_name($stmt, ':un', $name);
\oci_bind_by_name($stmt, ':pw', $password);
$result = \oci_execute($stmt);
if (!$result) {
$entry = $this->trans->t('DB Error: "%s"', [$this->getLastError($connection)]) . '<br />';
$entry .= $this->trans->t('Offending command was: "%s"', [$query]) . '<br />';
Expand All @@ -229,13 +229,13 @@ private function createDBUser($connection) {
}
// grant necessary roles
$query = 'GRANT CREATE SESSION, CREATE TABLE, CREATE SEQUENCE, CREATE TRIGGER, UNLIMITED TABLESPACE TO '.$name;
$stmt = oci_parse($connection, $query);
$stmt = \oci_parse($connection, $query);
if (!$stmt) {
$entry = $this->trans->t('DB Error: "%s"', [$this->getLastError($connection)]) . '<br />';
$entry .= $this->trans->t('Offending command was: "%s"', [$query]) . '<br />';
$this->logger->warning($entry, ['app' => 'setup.oci']);
}
$result = oci_execute($stmt);
$result = \oci_execute($stmt);
if (!$result) {
$entry = $this->trans->t('DB Error: "%s"', [$this->getLastError($connection)]) . '<br />';
$entry .= $this->trans->t('Offending command was: "%s", name: %s, password: %s',
Expand All @@ -250,9 +250,9 @@ private function createDBUser($connection) {
*/
protected function getLastError($connection = null) {
if ($connection) {
$error = oci_error($connection);
$error = \oci_error($connection);
} else {
$error = oci_error();
$error = \oci_error();
}
foreach (['message', 'code'] as $key) {
if (isset($error[$key])) {
Expand Down
Loading

0 comments on commit c0c583a

Please sign in to comment.