Stop using $wgProfileToDatabase
[lhc/web/wiklou.git] / includes / installer / DatabaseUpdater.php
index 427ded4..a5540db 100644 (file)
@@ -31,6 +31,7 @@ require_once __DIR__ . '/../../maintenance/Maintenance.php';
  * @since 1.17
  */
 abstract class DatabaseUpdater {
+       protected static $updateCounter = 0;
 
        /**
         * Array of updates to perform on the database
@@ -460,7 +461,8 @@ abstract class DatabaseUpdater {
                if ( !$this->canUseNewUpdatelog() ) {
                        return;
                }
-               $key = "updatelist-$version-" . time();
+               $key = "updatelist-$version-" . time() . self::$updateCounter;
+               self::$updateCounter++;
                $this->db->insert( 'updatelog',
                        array( 'ul_key' => $key, 'ul_value' => serialize( $updates ) ),
                        __METHOD__ );
@@ -895,6 +897,29 @@ abstract class DatabaseUpdater {
                return true;
        }
 
+       /**
+        * Set any .htaccess files or equivilent for storage repos
+        *
+        * Some zones (e.g. "temp") used to be public and may have been initialized as such
+        */
+       public function setFileAccess() {
+               $repo = RepoGroup::singleton()->getLocalRepo();
+               $zonePath = $repo->getZonePath( 'temp' );
+               if ( $repo->getBackend()->directoryExists( array( 'dir' => $zonePath ) ) ) {
+                       // If the directory was never made, then it will have the right ACLs when it is made
+                       $status = $repo->getBackend()->secure( array(
+                               'dir' => $zonePath,
+                               'noAccess' => true,
+                               'noListing' => true
+                       ) );
+                       if ( $status->isOK() ) {
+                               $this->output( "Set the local repo temp zone container to be private.\n" );
+                       } else {
+                               $this->output( "Failed to set the local repo temp zone container to be private.\n" );
+                       }
+               }
+       }
+
        /**
         * Purge the objectcache table
         */
@@ -907,7 +932,7 @@ abstract class DatabaseUpdater {
                if ( $wgLocalisationCacheConf['manualRecache'] ) {
                        $this->rebuildLocalisationCache();
                }
-               MessageBlobStore::clear();
+               MessageBlobStore::getInstance()->clear();
                $this->output( "done.\n" );
        }
 
@@ -984,6 +1009,7 @@ abstract class DatabaseUpdater {
 
        /**
         * Updates the timestamps in the transcache table
+        * @return bool
         */
        protected function doUpdateTranscacheField() {
                if ( $this->updateRowExists( 'convert transcache field' ) ) {
@@ -1032,6 +1058,31 @@ abstract class DatabaseUpdater {
                }
        }
 
+       /**
+        * Enable profiling table when it's turned on
+        */
+       protected function doEnableProfiling() {
+               global $wgProfiler;
+
+               if ( !$this->doTable( 'profiling' ) ) {
+                       return true;
+               }
+
+               $profileToDb = false;
+               if ( isset( $wgProfiler['output'] ) ) {
+                       $out = $wgProfiler['output'];
+                       if ( $out === 'db' ) {
+                               $profileToDb = true;
+                       } elseif( is_array( $out ) && in_array( 'db', $out ) ) {
+                               $profileToDb = true;
+                       }
+               }
+
+               if ( $profileToDb && !$this->db->tableExists( 'profiling', __METHOD__ ) ) {
+                       $this->applyPatch( 'patch-profiling.sql', false, 'Add profiling table' );
+               }
+       }
+
        /**
         * Rebuilds the localisation cache
         */