MediaWiki  1.23.8
DatabaseUpdater.php
Go to the documentation of this file.
1 <?php
24 require_once __DIR__ . '/../../maintenance/Maintenance.php';
25 
33 abstract class DatabaseUpdater {
34 
40  protected $updates = array();
41 
47  protected $updatesSkipped = array();
48 
53  protected $extensionUpdates = array();
54 
60  protected $db;
61 
62  protected $shared = false;
63 
69  'DeleteDefaultMessages',
70  'PopulateRevisionLength',
71  'PopulateRevisionSha1',
72  'PopulateImageSha1',
73  'FixExtLinksProtocolRelative',
74  'PopulateFilearchiveSha1',
75  );
76 
82  protected $fileHandle = null;
83 
89  protected $skipSchema = false;
90 
94  protected $holdContentHandlerUseDB = true;
95 
103  protected function __construct( DatabaseBase &$db, $shared, Maintenance $maintenance = null ) {
104  $this->db = $db;
105  $this->db->setFlag( DBO_DDLMODE ); // For Oracle's handling of schema files
106  $this->shared = $shared;
107  if ( $maintenance ) {
108  $this->maintenance = $maintenance;
109  $this->fileHandle = $maintenance->fileHandle;
110  } else {
111  $this->maintenance = new FakeMaintenance;
112  }
113  $this->maintenance->setDB( $db );
114  $this->initOldGlobals();
115  $this->loadExtensions();
116  wfRunHooks( 'LoadExtensionSchemaUpdates', array( $this ) );
117  }
118 
123  private function initOldGlobals() {
124  global $wgExtNewTables, $wgExtNewFields, $wgExtPGNewFields,
125  $wgExtPGAlteredFields, $wgExtNewIndexes, $wgExtModifiedFields;
126 
127  # For extensions only, should be populated via hooks
128  # $wgDBtype should be checked to specifiy the proper file
129  $wgExtNewTables = array(); // table, dir
130  $wgExtNewFields = array(); // table, column, dir
131  $wgExtPGNewFields = array(); // table, column, column attributes; for PostgreSQL
132  $wgExtPGAlteredFields = array(); // table, column, new type, conversion method; for PostgreSQL
133  $wgExtNewIndexes = array(); // table, index, dir
134  $wgExtModifiedFields = array(); // table, index, dir
135  }
136 
141  private function loadExtensions() {
142  if ( !defined( 'MEDIAWIKI_INSTALL' ) ) {
143  return; // already loaded
144  }
146  if ( !$vars ) {
147  return; // no LocalSettings found
148  }
149  if ( !isset( $vars['wgHooks'] ) || !isset( $vars['wgHooks']['LoadExtensionSchemaUpdates'] ) ) {
150  return;
151  }
153  $wgHooks['LoadExtensionSchemaUpdates'] = $vars['wgHooks']['LoadExtensionSchemaUpdates'];
154  $wgAutoloadClasses = $wgAutoloadClasses + $vars['wgAutoloadClasses'];
155  }
156 
165  public static function newForDB( &$db, $shared = false, $maintenance = null ) {
166  $type = $db->getType();
167  if ( in_array( $type, Installer::getDBTypes() ) ) {
168  $class = ucfirst( $type ) . 'Updater';
169 
170  return new $class( $db, $shared, $maintenance );
171  } else {
172  throw new MWException( __METHOD__ . ' called for unsupported $wgDBtype' );
173  }
174  }
175 
181  public function getDB() {
182  return $this->db;
183  }
184 
190  public function output( $str ) {
191  if ( $this->maintenance->isQuiet() ) {
192  return;
193  }
195  if ( !$wgCommandLineMode ) {
196  $str = htmlspecialchars( $str );
197  }
198  echo $str;
199  flush();
200  }
201 
215  public function addExtensionUpdate( array $update ) {
216  $this->extensionUpdates[] = $update;
217  }
218 
228  public function addExtensionTable( $tableName, $sqlPath ) {
229  $this->extensionUpdates[] = array( 'addTable', $tableName, $sqlPath, true );
230  }
231 
239  public function addExtensionIndex( $tableName, $indexName, $sqlPath ) {
240  $this->extensionUpdates[] = array( 'addIndex', $tableName, $indexName, $sqlPath, true );
241  }
242 
251  public function addExtensionField( $tableName, $columnName, $sqlPath ) {
252  $this->extensionUpdates[] = array( 'addField', $tableName, $columnName, $sqlPath, true );
253  }
254 
263  public function dropExtensionField( $tableName, $columnName, $sqlPath ) {
264  $this->extensionUpdates[] = array( 'dropField', $tableName, $columnName, $sqlPath, true );
265  }
266 
276  public function dropExtensionIndex( $tableName, $indexName, $sqlPath ) {
277  $this->extensionUpdates[] = array( 'dropIndex', $tableName, $indexName, $sqlPath, true );
278  }
279 
287  public function dropExtensionTable( $tableName, $sqlPath ) {
288  $this->extensionUpdates[] = array( 'dropTable', $tableName, $sqlPath, true );
289  }
290 
303  public function renameExtensionIndex( $tableName, $oldIndexName, $newIndexName,
304  $sqlPath, $skipBothIndexExistWarning = false
305  ) {
306  $this->extensionUpdates[] = array(
307  'renameIndex',
308  $tableName,
309  $oldIndexName,
310  $newIndexName,
311  $skipBothIndexExistWarning,
312  $sqlPath,
313  true
314  );
315  }
316 
324  public function modifyExtensionField( $tableName, $fieldName, $sqlPath ) {
325  $this->extensionUpdates[] = array( 'modifyField', $tableName, $fieldName, $sqlPath, true );
326  }
327 
335  public function tableExists( $tableName ) {
336  return ( $this->db->tableExists( $tableName, __METHOD__ ) );
337  }
338 
348  public function addPostDatabaseUpdateMaintenance( $class ) {
349  $this->postDatabaseUpdateMaintenance[] = $class;
350  }
351 
357  protected function getExtensionUpdates() {
359  }
360 
366  public function getPostDatabaseUpdateMaintenance() {
368  }
369 
375  private function writeSchemaUpdateFile( $schemaUpdate = array() ) {
377  $this->updatesSkipped = array();
378 
379  foreach ( $updates as $funcList ) {
380  $func = $funcList[0];
381  $arg = $funcList[1];
382  $origParams = $funcList[2];
383  call_user_func_array( $func, $arg );
384  flush();
385  $this->updatesSkipped[] = $origParams;
386  }
387  }
388 
394  public function doUpdates( $what = array( 'core', 'extensions', 'stats' ) ) {
395  global $wgVersion;
396 
397  $this->db->begin( __METHOD__ );
398  $what = array_flip( $what );
399  $this->skipSchema = isset( $what['noschema'] ) || $this->fileHandle !== null;
400  if ( isset( $what['core'] ) ) {
401  $this->runUpdates( $this->getCoreUpdateList(), false );
402  }
403  if ( isset( $what['extensions'] ) ) {
404  $this->runUpdates( $this->getOldGlobalUpdates(), false );
405  $this->runUpdates( $this->getExtensionUpdates(), true );
406  }
407 
408  if ( isset( $what['stats'] ) ) {
409  $this->checkStats();
410  }
411 
412  $this->setAppliedUpdates( $wgVersion, $this->updates );
413 
414  if ( $this->fileHandle ) {
415  $this->skipSchema = false;
416  $this->writeSchemaUpdateFile();
417  $this->setAppliedUpdates( "$wgVersion-schema", $this->updatesSkipped );
418  }
419 
420  $this->db->commit( __METHOD__ );
421  }
422 
430  private function runUpdates( array $updates, $passSelf ) {
431  $updatesDone = array();
433  foreach ( $updates as $params ) {
434  $origParams = $params;
435  $func = array_shift( $params );
436  if ( !is_array( $func ) && method_exists( $this, $func ) ) {
437  $func = array( $this, $func );
438  } elseif ( $passSelf ) {
439  array_unshift( $params, $this );
440  }
441  $ret = call_user_func_array( $func, $params );
442  flush();
443  if ( $ret !== false ) {
444  $updatesDone[] = $origParams;
445  } else {
446  $updatesSkipped[] = array( $func, $params, $origParams );
447  }
448  }
449  $this->updatesSkipped = array_merge( $this->updatesSkipped, $updatesSkipped );
450  $this->updates = array_merge( $this->updates, $updatesDone );
451  }
452 
457  protected function setAppliedUpdates( $version, $updates = array() ) {
458  $this->db->clearFlag( DBO_DDLMODE );
459  if ( !$this->canUseNewUpdatelog() ) {
460  return;
461  }
462  $key = "updatelist-$version-" . time();
463  $this->db->insert( 'updatelog',
464  array( 'ul_key' => $key, 'ul_value' => serialize( $updates ) ),
465  __METHOD__ );
466  $this->db->setFlag( DBO_DDLMODE );
467  }
468 
476  public function updateRowExists( $key ) {
477  $row = $this->db->selectRow(
478  'updatelog',
479  '1',
480  array( 'ul_key' => $key ),
481  __METHOD__
482  );
483 
484  return (bool)$row;
485  }
486 
494  public function insertUpdateRow( $key, $val = null ) {
495  $this->db->clearFlag( DBO_DDLMODE );
496  $values = array( 'ul_key' => $key );
497  if ( $val && $this->canUseNewUpdatelog() ) {
498  $values['ul_value'] = $val;
499  }
500  $this->db->insert( 'updatelog', $values, __METHOD__, 'IGNORE' );
501  $this->db->setFlag( DBO_DDLMODE );
502  }
503 
512  protected function canUseNewUpdatelog() {
513  return $this->db->tableExists( 'updatelog', __METHOD__ ) &&
514  $this->db->fieldExists( 'updatelog', 'ul_value', __METHOD__ );
515  }
516 
525  protected function doTable( $name ) {
526  global $wgSharedDB, $wgSharedTables;
527 
528  // Don't bother to check $wgSharedTables if there isn't a shared database
529  // or the user actually also wants to do updates on the shared database.
530  if ( $wgSharedDB === null || $this->shared ) {
531  return true;
532  }
533 
534  return !in_array( $name, $wgSharedTables );
535  }
536 
545  protected function getOldGlobalUpdates() {
546  global $wgExtNewFields, $wgExtNewTables, $wgExtModifiedFields,
547  $wgExtNewIndexes;
548 
549  $updates = array();
550 
551  foreach ( $wgExtNewTables as $tableRecord ) {
552  $updates[] = array(
553  'addTable', $tableRecord[0], $tableRecord[1], true
554  );
555  }
556 
557  foreach ( $wgExtNewFields as $fieldRecord ) {
558  $updates[] = array(
559  'addField', $fieldRecord[0], $fieldRecord[1],
560  $fieldRecord[2], true
561  );
562  }
563 
564  foreach ( $wgExtNewIndexes as $fieldRecord ) {
565  $updates[] = array(
566  'addIndex', $fieldRecord[0], $fieldRecord[1],
567  $fieldRecord[2], true
568  );
569  }
570 
571  foreach ( $wgExtModifiedFields as $fieldRecord ) {
572  $updates[] = array(
573  'modifyField', $fieldRecord[0], $fieldRecord[1],
574  $fieldRecord[2], true
575  );
576  }
577 
578  return $updates;
579  }
580 
589  abstract protected function getCoreUpdateList();
590 
596  public function copyFile( $filename ) {
597  $this->db->sourceFile( $filename, false, false, false,
598  array( $this, 'appendLine' )
599  );
600  }
601 
612  public function appendLine( $line ) {
613  $line = rtrim( $line ) . ";\n";
614  if ( fwrite( $this->fileHandle, $line ) === false ) {
615  throw new MWException( "trouble writing file" );
616  }
617 
618  return false;
619  }
620 
629  protected function applyPatch( $path, $isFullPath = false, $msg = null ) {
630  if ( $msg === null ) {
631  $msg = "Applying $path patch";
632  }
633  if ( $this->skipSchema ) {
634  $this->output( "...skipping schema change ($msg).\n" );
635 
636  return false;
637  }
638 
639  $this->output( "$msg ..." );
640 
641  if ( !$isFullPath ) {
642  $path = $this->db->patchPath( $path );
643  }
644  if ( $this->fileHandle !== null ) {
645  $this->copyFile( $path );
646  } else {
647  $this->db->sourceFile( $path );
648  }
649  $this->output( "done.\n" );
650 
651  return true;
652  }
653 
662  protected function addTable( $name, $patch, $fullpath = false ) {
663  if ( !$this->doTable( $name ) ) {
664  return true;
665  }
666 
667  if ( $this->db->tableExists( $name, __METHOD__ ) ) {
668  $this->output( "...$name table already exists.\n" );
669  } else {
670  return $this->applyPatch( $patch, $fullpath, "Creating $name table" );
671  }
672 
673  return true;
674  }
675 
685  protected function addField( $table, $field, $patch, $fullpath = false ) {
686  if ( !$this->doTable( $table ) ) {
687  return true;
688  }
689 
690  if ( !$this->db->tableExists( $table, __METHOD__ ) ) {
691  $this->output( "...$table table does not exist, skipping new field patch.\n" );
692  } elseif ( $this->db->fieldExists( $table, $field, __METHOD__ ) ) {
693  $this->output( "...have $field field in $table table.\n" );
694  } else {
695  return $this->applyPatch( $patch, $fullpath, "Adding $field field to table $table" );
696  }
697 
698  return true;
699  }
700 
710  protected function addIndex( $table, $index, $patch, $fullpath = false ) {
711  if ( !$this->doTable( $table ) ) {
712  return true;
713  }
714 
715  if ( !$this->db->tableExists( $table, __METHOD__ ) ) {
716  $this->output( "...skipping: '$table' table doesn't exist yet.\n" );
717  } elseif ( $this->db->indexExists( $table, $index, __METHOD__ ) ) {
718  $this->output( "...index $index already set on $table table.\n" );
719  } else {
720  return $this->applyPatch( $patch, $fullpath, "Adding index $index to table $table" );
721  }
722 
723  return true;
724  }
725 
735  protected function dropField( $table, $field, $patch, $fullpath = false ) {
736  if ( !$this->doTable( $table ) ) {
737  return true;
738  }
739 
740  if ( $this->db->fieldExists( $table, $field, __METHOD__ ) ) {
741  return $this->applyPatch( $patch, $fullpath, "Table $table contains $field field. Dropping" );
742  } else {
743  $this->output( "...$table table does not contain $field field.\n" );
744  }
745 
746  return true;
747  }
748 
758  protected function dropIndex( $table, $index, $patch, $fullpath = false ) {
759  if ( !$this->doTable( $table ) ) {
760  return true;
761  }
762 
763  if ( $this->db->indexExists( $table, $index, __METHOD__ ) ) {
764  return $this->applyPatch( $patch, $fullpath, "Dropping $index index from table $table" );
765  } else {
766  $this->output( "...$index key doesn't exist.\n" );
767  }
768 
769  return true;
770  }
771 
784  protected function renameIndex( $table, $oldIndex, $newIndex,
785  $skipBothIndexExistWarning, $patch, $fullpath = false
786  ) {
787  if ( !$this->doTable( $table ) ) {
788  return true;
789  }
790 
791  // First requirement: the table must exist
792  if ( !$this->db->tableExists( $table, __METHOD__ ) ) {
793  $this->output( "...skipping: '$table' table doesn't exist yet.\n" );
794 
795  return true;
796  }
797 
798  // Second requirement: the new index must be missing
799  if ( $this->db->indexExists( $table, $newIndex, __METHOD__ ) ) {
800  $this->output( "...index $newIndex already set on $table table.\n" );
801  if ( !$skipBothIndexExistWarning &&
802  $this->db->indexExists( $table, $oldIndex, __METHOD__ )
803  ) {
804  $this->output( "...WARNING: $oldIndex still exists, despite it has " .
805  "been renamed into $newIndex (which also exists).\n" .
806  " $oldIndex should be manually removed if not needed anymore.\n" );
807  }
808 
809  return true;
810  }
811 
812  // Third requirement: the old index must exist
813  if ( !$this->db->indexExists( $table, $oldIndex, __METHOD__ ) ) {
814  $this->output( "...skipping: index $oldIndex doesn't exist.\n" );
815 
816  return true;
817  }
818 
819  // Requirements have been satisfied, patch can be applied
820  return $this->applyPatch(
821  $patch,
822  $fullpath,
823  "Renaming index $oldIndex into $newIndex to table $table"
824  );
825  }
826 
838  public function dropTable( $table, $patch = false, $fullpath = false ) {
839  if ( !$this->doTable( $table ) ) {
840  return true;
841  }
842 
843  if ( $this->db->tableExists( $table, __METHOD__ ) ) {
844  $msg = "Dropping table $table";
845 
846  if ( $patch === false ) {
847  $this->output( "$msg ..." );
848  $this->db->dropTable( $table, __METHOD__ );
849  $this->output( "done.\n" );
850  } else {
851  return $this->applyPatch( $patch, $fullpath, $msg );
852  }
853  } else {
854  $this->output( "...$table doesn't exist.\n" );
855  }
856 
857  return true;
858  }
859 
869  public function modifyField( $table, $field, $patch, $fullpath = false ) {
870  if ( !$this->doTable( $table ) ) {
871  return true;
872  }
873 
874  $updateKey = "$table-$field-$patch";
875  if ( !$this->db->tableExists( $table, __METHOD__ ) ) {
876  $this->output( "...$table table does not exist, skipping modify field patch.\n" );
877  } elseif ( !$this->db->fieldExists( $table, $field, __METHOD__ ) ) {
878  $this->output( "...$field field does not exist in $table table, " .
879  "skipping modify field patch.\n" );
880  } elseif ( $this->updateRowExists( $updateKey ) ) {
881  $this->output( "...$field in table $table already modified by patch $patch.\n" );
882  } else {
883  $this->insertUpdateRow( $updateKey );
884 
885  return $this->applyPatch( $patch, $fullpath, "Modifying $field field of table $table" );
886  }
887 
888  return true;
889  }
890 
894  public function purgeCache() {
895  global $wgLocalisationCacheConf;
896  # We can't guarantee that the user will be able to use TRUNCATE,
897  # but we know that DELETE is available to us
898  $this->output( "Purging caches..." );
899  $this->db->delete( 'objectcache', '*', __METHOD__ );
900  if ( $wgLocalisationCacheConf['manualRecache'] ) {
901  $this->rebuildLocalisationCache();
902  }
904  $this->output( "done.\n" );
905  }
906 
910  protected function checkStats() {
911  $this->output( "...site_stats is populated..." );
912  $row = $this->db->selectRow( 'site_stats', '*', array( 'ss_row_id' => 1 ), __METHOD__ );
913  if ( $row === false ) {
914  $this->output( "data is missing! rebuilding...\n" );
915  } elseif ( isset( $row->site_stats ) && $row->ss_total_pages == -1 ) {
916  $this->output( "missing ss_total_pages, rebuilding...\n" );
917  } else {
918  $this->output( "done.\n" );
919 
920  return;
921  }
922  SiteStatsInit::doAllAndCommit( $this->db );
923  }
924 
925  # Common updater functions
926 
930  protected function doActiveUsersInit() {
931  $activeUsers = $this->db->selectField( 'site_stats', 'ss_active_users', false, __METHOD__ );
932  if ( $activeUsers == -1 ) {
933  $activeUsers = $this->db->selectField( 'recentchanges',
934  'COUNT( DISTINCT rc_user_text )',
935  array( 'rc_user != 0', 'rc_bot' => 0, "rc_log_type != 'newusers'" ), __METHOD__
936  );
937  $this->db->update( 'site_stats',
938  array( 'ss_active_users' => intval( $activeUsers ) ),
939  array( 'ss_row_id' => 1 ), __METHOD__, array( 'LIMIT' => 1 )
940  );
941  }
942  $this->output( "...ss_active_users user count set...\n" );
943  }
944 
948  protected function doLogUsertextPopulation() {
949  if ( !$this->updateRowExists( 'populate log_usertext' ) ) {
950  $this->output(
951  "Populating log_user_text field, printing progress markers. For large\n" .
952  "databases, you may want to hit Ctrl-C and do this manually with\n" .
953  "maintenance/populateLogUsertext.php.\n"
954  );
955 
956  $task = $this->maintenance->runChild( 'PopulateLogUsertext' );
957  $task->execute();
958  $this->output( "done.\n" );
959  }
960  }
961 
965  protected function doLogSearchPopulation() {
966  if ( !$this->updateRowExists( 'populate log_search' ) ) {
967  $this->output(
968  "Populating log_search table, printing progress markers. For large\n" .
969  "databases, you may want to hit Ctrl-C and do this manually with\n" .
970  "maintenance/populateLogSearch.php.\n" );
971 
972  $task = $this->maintenance->runChild( 'PopulateLogSearch' );
973  $task->execute();
974  $this->output( "done.\n" );
975  }
976  }
977 
981  protected function doUpdateTranscacheField() {
982  if ( $this->updateRowExists( 'convert transcache field' ) ) {
983  $this->output( "...transcache tc_time already converted.\n" );
984 
985  return true;
986  }
987 
988  return $this->applyPatch( 'patch-tc-timestamp.sql', false,
989  "Converting tc_time from UNIX epoch to MediaWiki timestamp" );
990  }
991 
995  protected function doCollationUpdate() {
996  global $wgCategoryCollation;
997  if ( $this->db->fieldExists( 'categorylinks', 'cl_collation', __METHOD__ ) ) {
998  if ( $this->db->selectField(
999  'categorylinks',
1000  'COUNT(*)',
1001  'cl_collation != ' . $this->db->addQuotes( $wgCategoryCollation ),
1002  __METHOD__
1003  ) == 0
1004  ) {
1005  $this->output( "...collations up-to-date.\n" );
1006 
1007  return;
1008  }
1009 
1010  $this->output( "Updating category collations..." );
1011  $task = $this->maintenance->runChild( 'UpdateCollation' );
1012  $task->execute();
1013  $this->output( "...done.\n" );
1014  }
1015  }
1016 
1020  protected function doMigrateUserOptions() {
1021  if ( $this->db->tableExists( 'user_properties' ) ) {
1022  $cl = $this->maintenance->runChild( 'ConvertUserOptions', 'convertUserOptions.php' );
1023  $cl->execute();
1024  $this->output( "done.\n" );
1025  }
1026  }
1027 
1031  protected function rebuildLocalisationCache() {
1035  $cl = $this->maintenance->runChild( 'RebuildLocalisationCache', 'rebuildLocalisationCache.php' );
1036  $this->output( "Rebuilding localisation cache...\n" );
1037  $cl->setForce();
1038  $cl->execute();
1039  $this->output( "done.\n" );
1040  }
1041 
1046  protected function disableContentHandlerUseDB() {
1047  global $wgContentHandlerUseDB;
1048 
1049  if ( $wgContentHandlerUseDB ) {
1050  $this->output( "Turning off Content Handler DB fields for this part of upgrade.\n" );
1051  $this->holdContentHandlerUseDB = $wgContentHandlerUseDB;
1052  $wgContentHandlerUseDB = false;
1053  }
1054  }
1055 
1059  protected function enableContentHandlerUseDB() {
1060  global $wgContentHandlerUseDB;
1061 
1062  if ( $this->holdContentHandlerUseDB ) {
1063  $this->output( "Content Handler DB fields should be usable now.\n" );
1064  $wgContentHandlerUseDB = $this->holdContentHandlerUseDB;
1065  }
1066  }
1067 }
DatabaseUpdater\output
output( $str)
Output some text.
Definition: DatabaseUpdater.php:184
DatabaseUpdater\dropIndex
dropIndex( $table, $index, $patch, $fullpath=false)
Drop an index from an existing table.
Definition: DatabaseUpdater.php:752
DatabaseUpdater\dropTable
dropTable( $table, $patch=false, $fullpath=false)
If the specified table exists, drop it, or execute the patch if one is provided.
Definition: DatabaseUpdater.php:832
DatabaseUpdater\copyFile
copyFile( $filename)
Append an SQL fragment to the open file handle.
Definition: DatabaseUpdater.php:590
DatabaseUpdater\$updatesSkipped
array $updatesSkipped
Array of updates that were skipped.
Definition: DatabaseUpdater.php:45
DatabaseUpdater\__construct
__construct(DatabaseBase &$db, $shared, Maintenance $maintenance=null)
Constructor.
Definition: DatabaseUpdater.php:97
DatabaseUpdater\applyPatch
applyPatch( $path, $isFullPath=false, $msg=null)
Applies a SQL patch.
Definition: DatabaseUpdater.php:623
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
DatabaseUpdater\doCollationUpdate
doCollationUpdate()
Update CategoryLinks collation.
Definition: DatabaseUpdater.php:989
DatabaseUpdater
Class for handling database updates.
Definition: DatabaseUpdater.php:33
$wgAutoloadClasses
global $wgAutoloadClasses
Definition: TestsAutoLoader.php:24
DatabaseUpdater\addPostDatabaseUpdateMaintenance
addPostDatabaseUpdateMaintenance( $class)
Add a maintenance script to be run after the database updates are complete.
Definition: DatabaseUpdater.php:342
DatabaseUpdater\checkStats
checkStats()
Check the site_stats table is not properly populated.
Definition: DatabaseUpdater.php:904
DatabaseUpdater\getCoreUpdateList
getCoreUpdateList()
Get an array of updates to perform on the database.
DatabaseUpdater\doMigrateUserOptions
doMigrateUserOptions()
Migrates user options from the user table blob to user_properties.
Definition: DatabaseUpdater.php:1014
DatabaseUpdater\writeSchemaUpdateFile
writeSchemaUpdateFile( $schemaUpdate=array())
Definition: DatabaseUpdater.php:369
$ret
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
Definition: hooks.txt:1530
DatabaseUpdater\dropField
dropField( $table, $field, $patch, $fullpath=false)
Drop a field from an existing table.
Definition: DatabaseUpdater.php:729
DatabaseUpdater\enableContentHandlerUseDB
enableContentHandlerUseDB()
Turns content handler fields back on.
Definition: DatabaseUpdater.php:1053
DatabaseUpdater\addField
addField( $table, $field, $patch, $fullpath=false)
Add a new field to an existing table.
Definition: DatabaseUpdater.php:679
DatabaseUpdater\doTable
doTable( $name)
Returns whether updates should be executed on the database table $name.
Definition: DatabaseUpdater.php:519
$params
$params
Definition: styleTest.css.php:40
DatabaseUpdater\getPostDatabaseUpdateMaintenance
getPostDatabaseUpdateMaintenance()
Definition: DatabaseUpdater.php:360
DatabaseUpdater\appendLine
appendLine( $line)
Append a line to the open filehandle.
Definition: DatabaseUpdater.php:606
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: maintenance.txt:39
$wgHooks
$wgHooks['ArticleShow'][]
Definition: hooks.txt:110
DatabaseUpdater\addExtensionIndex
addExtensionIndex( $tableName, $indexName, $sqlPath)
Definition: DatabaseUpdater.php:233
DatabaseUpdater\doActiveUsersInit
doActiveUsersInit()
Sets the number of active users in the site_stats table.
Definition: DatabaseUpdater.php:924
DatabaseUpdater\dropExtensionIndex
dropExtensionIndex( $tableName, $indexName, $sqlPath)
Drop an index from an extension table.
Definition: DatabaseUpdater.php:270
DatabaseUpdater\$updates
array $updates
Array of updates to perform on the database.
Definition: DatabaseUpdater.php:39
Maintenance\setDB
setDB(&$db)
Sets database object to be returned by getDB().
Definition: Maintenance.php:1020
SiteStatsInit\doAllAndCommit
static doAllAndCommit( $database, array $options=array())
Do all updates and commit them.
Definition: SiteStats.php:367
DatabaseUpdater\addExtensionUpdate
addExtensionUpdate(array $update)
Add a new update coming from an extension.
Definition: DatabaseUpdater.php:209
updates
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these updates(as a Java servelet could)
MWException
MediaWiki exception.
Definition: MWException.php:26
DatabaseUpdater\renameIndex
renameIndex( $table, $oldIndex, $newIndex, $skipBothIndexExistWarning, $patch, $fullpath=false)
Rename an index from an existing table.
Definition: DatabaseUpdater.php:778
DatabaseUpdater\getExtensionUpdates
getExtensionUpdates()
Get the list of extension-defined updates.
Definition: DatabaseUpdater.php:351
DBO_DDLMODE
const DBO_DDLMODE
Definition: Defines.php:46
DatabaseUpdater\newForDB
static newForDB(&$db, $shared=false, $maintenance=null)
Definition: DatabaseUpdater.php:159
$wgCommandLineMode
global $wgCommandLineMode
Definition: Setup.php:401
DatabaseBase\setFlag
setFlag( $flag)
Set a flag for this connection.
Definition: Database.php:619
DatabaseUpdater\modifyExtensionField
modifyExtensionField( $tableName, $fieldName, $sqlPath)
Definition: DatabaseUpdater.php:318
DatabaseUpdater\rebuildLocalisationCache
rebuildLocalisationCache()
Rebuilds the localisation cache.
Definition: DatabaseUpdater.php:1025
wfRunHooks
wfRunHooks( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in $wgHooks.
Definition: GlobalFunctions.php:4010
Installer\getExistingLocalSettings
static getExistingLocalSettings()
Determine if LocalSettings.php exists.
Definition: Installer.php:501
DatabaseUpdater\getDB
getDB()
Get a database connection to run updates.
Definition: DatabaseUpdater.php:175
DatabaseUpdater\$postDatabaseUpdateMaintenance
$postDatabaseUpdateMaintenance
Scripts to run after database update Should be a subclass of LoggedUpdateMaintenance.
Definition: DatabaseUpdater.php:64
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
DatabaseUpdater\runUpdates
runUpdates(array $updates, $passSelf)
Helper function for doUpdates()
Definition: DatabaseUpdater.php:424
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
FakeMaintenance
Fake maintenance wrapper, mostly used for the web installer/updater.
Definition: Maintenance.php:1198
DatabaseUpdater\doUpdates
doUpdates( $what=array( 'core', 'extensions', 'stats'))
Do all the updates.
Definition: DatabaseUpdater.php:388
DatabaseUpdater\updateRowExists
updateRowExists( $key)
Helper function: check if the given key is present in the updatelog table.
Definition: DatabaseUpdater.php:470
DatabaseType\getType
getType()
Get the type of the DBMS, as it appears in $wgDBtype.
DatabaseUpdater\disableContentHandlerUseDB
disableContentHandlerUseDB()
Turns off content handler fields during parts of the upgrade where they aren't available.
Definition: DatabaseUpdater.php:1040
DatabaseUpdater\doLogSearchPopulation
doLogSearchPopulation()
Migrate log params to new table and index for searching.
Definition: DatabaseUpdater.php:959
DatabaseUpdater\setAppliedUpdates
setAppliedUpdates( $version, $updates=array())
Definition: DatabaseUpdater.php:451
$line
$line
Definition: cdb.php:57
DatabaseUpdater\doUpdateTranscacheField
doUpdateTranscacheField()
Updates the timestamps in the transcache table.
Definition: DatabaseUpdater.php:975
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:336
DatabaseBase
Database abstraction object.
Definition: Database.php:219
DatabaseUpdater\canUseNewUpdatelog
canUseNewUpdatelog()
Updatelog was changed in 1.17 to have a ul_value column so we can record more information about what ...
Definition: DatabaseUpdater.php:506
DatabaseUpdater\$fileHandle
resource $fileHandle
File handle for SQL output.
Definition: DatabaseUpdater.php:77
$version
$version
Definition: parserTests.php:86
DatabaseUpdater\getOldGlobalUpdates
getOldGlobalUpdates()
Before 1.17, we used to handle updates via stuff like $wgExtNewTables/Fields/Indexes.
Definition: DatabaseUpdater.php:539
DatabaseUpdater\doLogUsertextPopulation
doLogUsertextPopulation()
Populates the log_user_text field in the logging table.
Definition: DatabaseUpdater.php:942
DatabaseUpdater\tableExists
tableExists( $tableName)
Definition: DatabaseUpdater.php:329
DatabaseUpdater\addExtensionField
addExtensionField( $tableName, $columnName, $sqlPath)
Definition: DatabaseUpdater.php:245
DatabaseUpdater\modifyField
modifyField( $table, $field, $patch, $fullpath=false)
Modify an existing field.
Definition: DatabaseUpdater.php:863
DatabaseUpdater\loadExtensions
loadExtensions()
Loads LocalSettings.php, if needed, and initialises everything needed for LoadExtensionSchemaUpdates ...
Definition: DatabaseUpdater.php:135
$path
$path
Definition: NoLocalSettings.php:35
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
DatabaseUpdater\renameExtensionIndex
renameExtensionIndex( $tableName, $oldIndexName, $newIndexName, $sqlPath, $skipBothIndexExistWarning=false)
Rename an index on an extension table.
Definition: DatabaseUpdater.php:297
DatabaseUpdater\addTable
addTable( $name, $patch, $fullpath=false)
Add a new table to the database.
Definition: DatabaseUpdater.php:656
DatabaseUpdater\$shared
$shared
Definition: DatabaseUpdater.php:58
DatabaseUpdater\dropExtensionField
dropExtensionField( $tableName, $columnName, $sqlPath)
Definition: DatabaseUpdater.php:257
DatabaseUpdater\purgeCache
purgeCache()
Purge the objectcache table.
Definition: DatabaseUpdater.php:888
DatabaseUpdater\$db
DatabaseBase $db
Handle to the database subclass.
Definition: DatabaseUpdater.php:56
DatabaseUpdater\$skipSchema
bool $skipSchema
Flag specifying whether or not to skip schema (e.g.
Definition: DatabaseUpdater.php:83
DatabaseUpdater\addExtensionTable
addExtensionTable( $tableName, $sqlPath)
Convenience wrapper for addExtensionUpdate() when adding a new table (which is the most common usage ...
Definition: DatabaseUpdater.php:222
Installer\getDBTypes
static getDBTypes()
Get a list of known DB types.
Definition: Installer.php:387
$vars
static configuration should be added through ResourceLoaderGetConfigVars instead & $vars
Definition: hooks.txt:1679
DatabaseUpdater\initOldGlobals
initOldGlobals()
Initialize all of the old globals.
Definition: DatabaseUpdater.php:117
DatabaseUpdater\addIndex
addIndex( $table, $index, $patch, $fullpath=false)
Add a new index to an existing table.
Definition: DatabaseUpdater.php:704
$maintenance
if(!defined( 'RUN_MAINTENANCE_IF_MAIN')) if(!Maintenance::shouldExecute() && $maintClass !='CommandLineInc') if(! $maintClass||!class_exists( $maintClass)) $maintenance
Definition: doMaintenance.php:47
DatabaseUpdater\$extensionUpdates
array $extensionUpdates
List of extension-provided database updates.
Definition: DatabaseUpdater.php:50
DatabaseUpdater\insertUpdateRow
insertUpdateRow( $key, $val=null)
Helper function: Add a key to the updatelog table Obviously, only use this for updates that occur aft...
Definition: DatabaseUpdater.php:488
DatabaseUpdater\dropExtensionTable
dropExtensionTable( $tableName, $sqlPath)
Definition: DatabaseUpdater.php:281
MessageBlobStore\clear
static clear()
Definition: MessageBlobStore.php:243
DatabaseUpdater\$holdContentHandlerUseDB
$holdContentHandlerUseDB
Hold the value of $wgContentHandlerUseDB during the upgrade.
Definition: DatabaseUpdater.php:88
$type
$type
Definition: testCompression.php:46