]> source.dussan.org Git - nextcloud-server.git/commitdiff
Disable prepared query caching while doing an upgrade
authorRobin Appelman <icewind@owncloud.com>
Tue, 26 Feb 2013 21:41:48 +0000 (22:41 +0100)
committerRobin Appelman <icewind@owncloud.com>
Tue, 26 Feb 2013 21:41:48 +0000 (22:41 +0100)
core/ajax/update.php
lib/db.php

index 20ab045c89243b09f433dac2900caba7acb57b17..b112cf6266b59d41698e0f8655adcbd8ee69f578 100644 (file)
@@ -4,6 +4,7 @@ $RUNTIME_NOAPPS = true;
 require_once '../../lib/base.php';
 
 if (OC::checkUpgrade(false)) {
+       \OC_DB::enableCaching(false);
        $updateEventSource = new OC_EventSource();
        $watcher = new UpdateWatcher($updateEventSource);
        OC_Hook::connect('update', 'success', $watcher, 'success');
@@ -64,4 +65,4 @@ class UpdateWatcher {
                $this->eventSource->close();
        }
 
-}
\ No newline at end of file
+}
index fb2c027cdb9bff024ba8d313520e1b3c0a11905e..1fd852b370f6527d3e009830c56855563e42c226 100644 (file)
@@ -42,6 +42,7 @@ class OC_DB {
        const BACKEND_MDB2=1;
 
        static private $preparedQueries = array();
+       static private $cachingEnabled = true;
 
        /**
         * @var MDB2_Driver_Common
@@ -356,7 +357,7 @@ class OC_DB {
                                }
                        }
                } else {
-                       if (isset(self::$preparedQueries[$query])) {
+                       if (isset(self::$preparedQueries[$query]) and self::$cachingEnabled) {
                                return self::$preparedQueries[$query];
                        }
                }
@@ -382,7 +383,7 @@ class OC_DB {
                        }
                        $result=new PDOStatementWrapper($result);
                }
-               if (is_null($limit) || $limit == -1) {
+               if ((is_null($limit) || $limit == -1) and self::$cachingEnabled ) {
                        self::$preparedQueries[$rawQuery] = $result;
                }
                return $result;
@@ -915,6 +916,16 @@ class OC_DB {
                }
                return $msg;
        }
+
+       /**
+        * @param bool $enabled
+        */
+       static public function enableCaching($enabled) {
+               if (!$enabled) {
+                       self::$preparedQueries = array();
+               }
+               self::$cachingEnabled = $enabled;
+       }
 }
 
 /**