]> source.dussan.org Git - nextcloud-server.git/commitdiff
oracle fixes, missing backticks, LIMIT to param
authorJörn Friedrich Dreyer <jfd@butonic.de>
Mon, 29 Apr 2013 10:25:27 +0000 (12:25 +0200)
committerJörn Friedrich Dreyer <jfd@butonic.de>
Fri, 14 Jun 2013 11:13:29 +0000 (13:13 +0200)
Conflicts:
lib/files/cache/cache.php

lib/app.php
lib/db.php
lib/files/cache/cache.php
lib/setup.php
lib/user.php
lib/user/database.php

index 4f1b6a816ddd63ac384e293741966d397fa0ab2d..811d6e4675e51fa9b4382974041e87f38800d669 100644 (file)
@@ -173,8 +173,11 @@ class OC_App{
                }
                $apps=array('files');
                $query = OC_DB::prepare( 'SELECT `appid` FROM `*PREFIX*appconfig`'
-                       .' WHERE `configkey` = \'enabled\' AND `configvalue`=\'yes\'' );
+                       .' WHERE `configkey` = \'enabled\' AND to_char(`configvalue`)=\'yes\'' );
                $result=$query->execute();
+               if( \OC_DB::isError($result)) {
+                       throw new DatabaseException($result->getMessage(), $query);
+               }
                while($row=$result->fetchRow()) {
                        if(array_search($row['appid'], $apps)===false) {
                                $apps[]=$row['appid'];
index 5a91421f7ab74e0e7c62f7125c57dfcaf97d1309..013351fcdcfcb1166c3e60270ff6844f13dc0162 100644 (file)
@@ -276,15 +276,10 @@ class OC_DB {
                                                        'phptype'  => 'oci8',
                                                        'username' => $user,
                                                        'password' => $pass,
+                                                       'service'  => $name,
+                                                       'hostspec' => $host,
                                                        'charset' => 'AL32UTF8',
                                        );
-                                       if ($host != '') {
-                                               $dsn['hostspec'] = $host;
-                                               $dsn['database'] = $name;
-                                       } else { // use dbname for hostspec
-                                               $dsn['hostspec'] = $name;
-                                               $dsn['database'] = $user;
-                                       }
                                        break;
                                case 'mssql':
                                        $dsn = array(
index 2890049826b5a1c28c38f720c303be9890c3240c..51912ffd315925326754a0a9cfa678fc9402bf81 100644 (file)
@@ -159,8 +159,11 @@ class Cache {
                if ($fileId > -1) {
                        $query = \OC_DB::prepare(
                                'SELECT `fileid`, `storage`, `path`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `mtime`, `encrypted`, `unencrypted_size` , `etag`
-                                FROM `*PREFIX*filecache` WHERE `parent` = ? ORDER BY `name` ASC');
+                                FROM `*PREFIX*filecache` WHERE `parent` = ? ORDER BY `name` ASC');
                        $result = $query->execute(array($fileId));
+                       if (\OC_DB::isError($result)) {
+                               \OCP\Util::writeLog('cache', 'getFolderContents failed: '.$result->getMessage(), \OCP\Util::ERROR);
+                       }
                        $files = $result->fetchAll();
                        foreach ($files as &$file) {
                                $file['mimetype'] = $this->getMimetype($file['mimetype']);
@@ -212,7 +215,7 @@ class Cache {
                                . ' VALUES(' . implode(', ', $valuesPlaceholder) . ')');
                        $result = $query->execute($params);
                        if (\OC_DB::isError($result)) {
-                               \OCP\Util::writeLog('cache', 'Insert to cache failed: ' . $result, \OCP\Util::ERROR);
+                               \OCP\Util::writeLog('cache', 'Insert to cache failed: ' . $result->getMessage(), \OCP\Util::ERROR);
                        }
 
                        return (int)\OC_DB::insertid('*PREFIX*filecache');
@@ -378,6 +381,9 @@ class Cache {
                $pathHash = md5($file);
                $query = \OC_DB::prepare('SELECT `size` FROM `*PREFIX*filecache` WHERE `storage` = ? AND `path_hash` = ?');
                $result = $query->execute(array($this->numericId, $pathHash));
+               if( \OC_DB::isError($result)) {
+                       \OCP\Util::writeLog('cache', 'get status failed: '.$result->getMessage(), \OCP\Util::ERROR);
+               }
                if ($row = $result->fetchRow()) {
                        if ((int)$row['size'] === -1) {
                                return self::SHALLOW;
@@ -515,8 +521,11 @@ class Cache {
         */
        public function getIncomplete() {
                $query = \OC_DB::prepare('SELECT `path` FROM `*PREFIX*filecache`'
-                       . ' WHERE `storage` = ? AND `size` = -1 ORDER BY `fileid` DESC LIMIT 1');
+                       . ' WHERE `storage` = ? AND `size` = -1 ORDER BY `fileid` DESC',1);
                $result = $query->execute(array($this->numericId));
+               if (\OC_DB::isError($result)) {
+                       \OCP\Util::writeLog('cache', 'getIncomplete failed: '.$result->getMessage(), \OCP\Util::ERROR);
+               }
                if ($row = $result->fetchRow()) {
                        return $row['path'];
                } else {
index dff66069ff1a9899dad6feab022eb0f4a1c6eddb..6522b45cf679efd50b32e1fb6961ac800902c875 100644 (file)
@@ -152,8 +152,12 @@ class OC_Setup {
                                        self::setupOCIDatabase($dbhost, $dbuser, $dbpass, $dbname, $dbtableprefix, $dbtablespace, $username);
                                } catch (Exception $e) {
                                        $error[] = array(
-                                               'error' => $l->t('Oracle username and/or password not valid'),
-                                               'hint' => $l->t('You need to enter either an existing account or the administrator.')
+                                               'error' => $l->t('Oracle connection could not be established'),
+                                               'hint' => $e->getMessage().' 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'
                                        );
                                        return $error;
                                }
@@ -451,9 +455,13 @@ class OC_Setup {
                } else {
                        $easy_connect_string = '//'.$e_host.'/'.$e_dbname;
                }
+               \OC_Log::write('setup oracle', 'connect string: '.$easy_connect_string, \OC_Log::DEBUG);
                $connection = @oci_connect($dbuser, $dbpass, $easy_connect_string);
                if(!$connection) {
                        $e = oci_error();
+                       if (is_array ($e) && isset ($e['message'])) {
+                               throw new Exception($e['message']);
+                       }
                        throw new Exception($l->t('Oracle username and/or password not valid'));
                }
                //check for roles creation rights in oracle
index 311e9af866a77107e2d1c0c7a609afa66d419010..64aff3d9373fec580acc453031365b73aad1ad40 100644 (file)
@@ -610,7 +610,7 @@ class OC_User {
         */
        public static function isEnabled($userid) {
                $sql = 'SELECT `userid` FROM `*PREFIX*preferences`'
-                       .' WHERE `userid` = ? AND `appid` = ? AND `configkey` = ? AND `configvalue` = ?';
+                       .' WHERE `userid` = ? AND `appid` = ? AND `configkey` = ? AND to_char(`configvalue`) = ?';
                $stmt = OC_DB::prepare($sql);
                if ( ! OC_DB::isError($stmt) ) {
                        $result = $stmt->execute(array($userid, 'core', 'enabled', 'false'));
index 210c7f3e1eb28c38b0cd42164ae3c2371a0755ef..35cc68e3c051dd452803d58d2d1e09ca6b643605 100644 (file)
@@ -136,7 +136,7 @@ class OC_User_Database extends OC_User_Backend {
         */
        public function getDisplayName($uid) {
                if( $this->userExists($uid) ) {
-                       $query = OC_DB::prepare( 'SELECT displayname FROM `*PREFIX*users` WHERE `uid` = ?' );
+                       $query = OC_DB::prepare( 'SELECT `displayname` FROM `*PREFIX*users` WHERE `uid` = ?' );
                        $result = $query->execute( array( $uid ))->fetchAll();
                        $displayName = trim($result[0]['displayname'], ' ');
                        if ( !empty($displayName) ) {