summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2015-03-26 23:00:36 +0100
committerLukas Reschke <lukas@owncloud.com>2015-03-26 23:00:36 +0100
commita64c3fb3a26e7a721d1f61aaeb09ed5fab8bf0a6 (patch)
tree9e7bb28186a7cabefca8d74001a1cd8c78390ec2
parent93ae742ad84bb296dd09871b70a7aaaf2d8aa710 (diff)
parentced104c20689b4316f61bfdf099111e68386dc81 (diff)
downloadnextcloud-server-a64c3fb3a26e7a721d1f61aaeb09ed5fab8bf0a6.tar.gz
nextcloud-server-a64c3fb3a26e7a721d1f61aaeb09ed5fab8bf0a6.zip
Merge pull request #14497 from owncloud/kill-substr-mssql-stable8
[stable8] Remove hacky Substring support for MSSQL
-rw-r--r--lib/private/db/statementwrapper.php102
1 files changed, 0 insertions, 102 deletions
diff --git a/lib/private/db/statementwrapper.php b/lib/private/db/statementwrapper.php
index a85c0167e0b..8f08a9d3582 100644
--- a/lib/private/db/statementwrapper.php
+++ b/lib/private/db/statementwrapper.php
@@ -51,15 +51,6 @@ class OC_DB_StatementWrapper {
}
$this->lastArguments = $input;
if (count($input) > 0) {
-
- if (!isset($type)) {
- $type = OC_Config::getValue( "dbtype", "sqlite" );
- }
-
- if ($type == 'mssql') {
- $input = $this->tryFixSubstringLastArgumentDataForMSSQL($input);
- }
-
$result = $this->statement->execute($input);
} else {
$result = $this->statement->execute();
@@ -75,99 +66,6 @@ class OC_DB_StatementWrapper {
}
}
- private function tryFixSubstringLastArgumentDataForMSSQL($input) {
- $query = $this->statement->getWrappedStatement()->queryString;
- $pos = stripos ($query, 'SUBSTRING');
-
- if ( $pos === false) {
- return $input;
- }
-
- try {
- $newQuery = '';
-
- $cArg = 0;
-
- $inSubstring = false;
- $queryLength = strlen($query);
-
- // Create new query
- for ($i = 0; $i < $queryLength; $i++) {
- if ($inSubstring == false) {
- // Defines when we should start inserting values
- if (substr ($query, $i, 9) == 'SUBSTRING') {
- $inSubstring = true;
- }
- } else {
- // Defines when we should stop inserting values
- if (substr ($query, $i, 1) == ')') {
- $inSubstring = false;
- }
- }
-
- if (substr ($query, $i, 1) == '?') {
- // We found a question mark
- if ($inSubstring) {
- $newQuery .= $input[$cArg];
-
- //
- // Remove from input array
- //
- array_splice ($input, $cArg, 1);
- } else {
- $newQuery .= substr ($query, $i, 1);
- $cArg++;
- }
- } else {
- $newQuery .= substr ($query, $i, 1);
- }
- }
-
- // The global data we need
- $name = OC_Config::getValue( "dbname", "owncloud" );
- $host = OC_Config::getValue( "dbhost", "" );
- $user = OC_Config::getValue( "dbuser", "" );
- $pass = OC_Config::getValue( "dbpassword", "" );
- if (strpos($host, ':')) {
- list($host, $port) = explode(':', $host, 2);
- } else {
- $port = false;
- }
- $opts = array();
-
- if ($port) {
- $dsn = 'sqlsrv:Server='.$host.','.$port.';Database='.$name;
- } else {
- $dsn = 'sqlsrv:Server='.$host.';Database='.$name;
- }
-
- $PDO = new PDO($dsn, $user, $pass, $opts);
- $PDO->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
- $PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
-
- $this->statement = $PDO->prepare($newQuery);
-
- $this->lastArguments = $input;
-
- return $input;
- } catch (PDOException $e){
- $entry = 'PDO DB Error: "'.$e->getMessage().'"<br />';
- $entry .= 'Offending command was: '.$this->statement->queryString .'<br />';
- $entry .= 'Input parameters: ' .print_r($input, true).'<br />';
- $entry .= 'Stack trace: ' .$e->getTraceAsString().'<br />';
- OC_Log::write('core', $entry, OC_Log::FATAL);
- OC_User::setUserId(null);
-
- $l = \OC::$server->getL10N('lib');
- throw new \OC\HintException(
- $l->t('Database Error'),
- $l->t('Please contact your system administrator.'),
- 0,
- $e
- );
- }
- }
-
/**
* provide an alias for fetch
*