]> source.dussan.org Git - nextcloud-server.git/commitdiff
Added PostgreSQL version warning on upgrade
authorVincent Petry <pvince81@owncloud.com>
Sat, 15 Mar 2014 12:28:20 +0000 (13:28 +0100)
committerVincent Petry <pvince81@owncloud.com>
Mon, 17 Mar 2014 17:58:00 +0000 (18:58 +0100)
lib/private/util.php

index fc78566e45652615091210b7f159d6f7c7e3dcfa..54e04ce4d7a5486883a38cf8cc7c39f05dc61e71 100755 (executable)
@@ -485,12 +485,46 @@ class OC_Util {
                        );
                }
 
+               $errors = array_merge($errors, self::checkDatabaseVersion());
+
                // Cache the result of this function
                \OC::$session->set('checkServer_suceeded', count($errors) == 0);
 
                return $errors;
        }
 
+       /**
+        * Check the database version
+        * @return array errors array
+        */
+       public static function checkDatabaseVersion() {
+               $errors = array();
+               $dbType = \OC_Config::getValue('dbtype', 'sqlite');
+               if ($dbType === 'pgsql') {
+                       // check PostgreSQL version
+                       try {
+                               $result = \OC_DB::executeAudited('SHOW SERVER_VERSION');
+                               $data = $result->fetchRow();
+                               if (isset($data['server_version'])) {
+                                       $version = $data['server_version'];
+                                       if (version_compare($version, '9.0.0', '<')) {
+                                               $errors[] = array(
+                                                       'error' => 'PostgreSQL >= 9 required',
+                                                       'hint' => 'Please upgrade your database version'
+                                               );
+                                       }
+                               }
+                       }
+                       catch (\Doctrine\DBAL\DBALException $e){
+                               $errors[] = array(
+                                       'error' => 'PostgreSQL >= 9 required'
+                               );
+                       }
+               }
+               return $errors;
+       }
+
+
        /**
         * @brief check if there are still some encrypted files stored
         * @return boolean