MediaWiki  1.32.0
DatabaseUpdater.php
Go to the documentation of this file.
1 <?php
26 
27 require_once __DIR__ . '/../../maintenance/Maintenance.php';
28 
36 abstract class DatabaseUpdater {
38 
44  protected $updates = [];
45 
51  protected $updatesSkipped = [];
52 
57  protected $extensionUpdates = [];
58 
64  protected $db;
65 
69  protected $maintenance;
70 
71  protected $shared = false;
72 
90  ];
91 
97  protected $fileHandle = null;
98 
104  protected $skipSchema = false;
105 
109  protected $holdContentHandlerUseDB = true;
110 
116  protected function __construct( Database &$db, $shared, Maintenance $maintenance = null ) {
117  $this->db = $db;
118  $this->db->setFlag( DBO_DDLMODE ); // For Oracle's handling of schema files
119  $this->shared = $shared;
120  if ( $maintenance ) {
121  $this->maintenance = $maintenance;
122  $this->fileHandle = $maintenance->fileHandle;
123  } else {
124  $this->maintenance = new FakeMaintenance;
125  }
126  $this->maintenance->setDB( $db );
127  $this->initOldGlobals();
128  $this->loadExtensions();
129  Hooks::run( 'LoadExtensionSchemaUpdates', [ $this ] );
130  }
131 
136  private function initOldGlobals() {
137  global $wgExtNewTables, $wgExtNewFields, $wgExtPGNewFields,
138  $wgExtPGAlteredFields, $wgExtNewIndexes, $wgExtModifiedFields;
139 
140  # For extensions only, should be populated via hooks
141  # $wgDBtype should be checked to specify the proper file
142  $wgExtNewTables = []; // table, dir
143  $wgExtNewFields = []; // table, column, dir
144  $wgExtPGNewFields = []; // table, column, column attributes; for PostgreSQL
145  $wgExtPGAlteredFields = []; // table, column, new type, conversion method; for PostgreSQL
146  $wgExtNewIndexes = []; // table, index, dir
147  $wgExtModifiedFields = []; // table, index, dir
148  }
149 
154  private function loadExtensions() {
155  if ( !defined( 'MEDIAWIKI_INSTALL' ) || defined( 'MW_EXTENSIONS_LOADED' ) ) {
156  return; // already loaded
157  }
159 
160  $registry = ExtensionRegistry::getInstance();
161  $queue = $registry->getQueue();
162  // Don't accidentally load extensions in the future
163  $registry->clearQueue();
164 
165  // This will automatically add "AutoloadClasses" to $wgAutoloadClasses
166  $data = $registry->readFromQueue( $queue );
167  $hooks = [];
168  if ( isset( $data['globals']['wgHooks']['LoadExtensionSchemaUpdates'] ) ) {
169  $hooks = $data['globals']['wgHooks']['LoadExtensionSchemaUpdates'];
170  }
171  if ( $vars && isset( $vars['wgHooks']['LoadExtensionSchemaUpdates'] ) ) {
172  $hooks = array_merge_recursive( $hooks, $vars['wgHooks']['LoadExtensionSchemaUpdates'] );
173  }
175  $wgHooks['LoadExtensionSchemaUpdates'] = $hooks;
176  if ( $vars && isset( $vars['wgAutoloadClasses'] ) ) {
177  $wgAutoloadClasses += $vars['wgAutoloadClasses'];
178  }
179  }
180 
189  public static function newForDB( Database $db, $shared = false, Maintenance $maintenance = null ) {
190  $type = $db->getType();
191  if ( in_array( $type, Installer::getDBTypes() ) ) {
192  $class = ucfirst( $type ) . 'Updater';
193 
194  return new $class( $db, $shared, $maintenance );
195  } else {
196  throw new MWException( __METHOD__ . ' called for unsupported $wgDBtype' );
197  }
198  }
199 
205  public function getDB() {
206  return $this->db;
207  }
208 
215  public function output( $str ) {
216  if ( $this->maintenance->isQuiet() ) {
217  return;
218  }
219  global $wgCommandLineMode;
220  if ( !$wgCommandLineMode ) {
221  $str = htmlspecialchars( $str );
222  }
223  echo $str;
224  flush();
225  }
226 
239  public function addExtensionUpdate( array $update ) {
240  $this->extensionUpdates[] = $update;
241  }
242 
252  public function addExtensionTable( $tableName, $sqlPath ) {
253  $this->extensionUpdates[] = [ 'addTable', $tableName, $sqlPath, true ];
254  }
255 
263  public function addExtensionIndex( $tableName, $indexName, $sqlPath ) {
264  $this->extensionUpdates[] = [ 'addIndex', $tableName, $indexName, $sqlPath, true ];
265  }
266 
275  public function addExtensionField( $tableName, $columnName, $sqlPath ) {
276  $this->extensionUpdates[] = [ 'addField', $tableName, $columnName, $sqlPath, true ];
277  }
278 
287  public function dropExtensionField( $tableName, $columnName, $sqlPath ) {
288  $this->extensionUpdates[] = [ 'dropField', $tableName, $columnName, $sqlPath, true ];
289  }
290 
300  public function dropExtensionIndex( $tableName, $indexName, $sqlPath ) {
301  $this->extensionUpdates[] = [ 'dropIndex', $tableName, $indexName, $sqlPath, true ];
302  }
303 
311  public function dropExtensionTable( $tableName, $sqlPath ) {
312  $this->extensionUpdates[] = [ 'dropTable', $tableName, $sqlPath, true ];
313  }
314 
327  public function renameExtensionIndex( $tableName, $oldIndexName, $newIndexName,
328  $sqlPath, $skipBothIndexExistWarning = false
329  ) {
330  $this->extensionUpdates[] = [
331  'renameIndex',
332  $tableName,
333  $oldIndexName,
334  $newIndexName,
335  $skipBothIndexExistWarning,
336  $sqlPath,
337  true
338  ];
339  }
340 
348  public function modifyExtensionField( $tableName, $fieldName, $sqlPath ) {
349  $this->extensionUpdates[] = [ 'modifyField', $tableName, $fieldName, $sqlPath, true ];
350  }
351 
358  public function modifyExtensionTable( $tableName, $sqlPath ) {
359  $this->extensionUpdates[] = [ 'modifyTable', $tableName, $sqlPath, true ];
360  }
361 
369  public function tableExists( $tableName ) {
370  return ( $this->db->tableExists( $tableName, __METHOD__ ) );
371  }
372 
382  public function addPostDatabaseUpdateMaintenance( $class ) {
383  $this->postDatabaseUpdateMaintenance[] = $class;
384  }
385 
391  protected function getExtensionUpdates() {
393  }
394 
402  }
403 
410  private function writeSchemaUpdateFile( array $schemaUpdate = [] ) {
412  $this->updatesSkipped = [];
413 
414  foreach ( $updates as $funcList ) {
415  $func = $funcList[0];
416  $args = $funcList[1];
417  $origParams = $funcList[2];
418  $func( ...$args );
419  flush();
420  $this->updatesSkipped[] = $origParams;
421  }
422  }
423 
434  public function getSchemaVars() {
435  return []; // DB-type specific
436  }
437 
443  public function doUpdates( array $what = [ 'core', 'extensions', 'stats' ] ) {
444  $this->db->setSchemaVars( $this->getSchemaVars() );
445 
446  $what = array_flip( $what );
447  $this->skipSchema = isset( $what['noschema'] ) || $this->fileHandle !== null;
448  if ( isset( $what['core'] ) ) {
449  $this->runUpdates( $this->getCoreUpdateList(), false );
450  }
451  if ( isset( $what['extensions'] ) ) {
452  $this->runUpdates( $this->getOldGlobalUpdates(), false );
453  $this->runUpdates( $this->getExtensionUpdates(), true );
454  }
455 
456  if ( isset( $what['stats'] ) ) {
457  $this->checkStats();
458  }
459 
460  if ( $this->fileHandle ) {
461  $this->skipSchema = false;
462  $this->writeSchemaUpdateFile();
463  }
464  }
465 
472  private function runUpdates( array $updates, $passSelf ) {
473  $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
474 
475  $updatesDone = [];
476  $updatesSkipped = [];
477  foreach ( $updates as $params ) {
478  $origParams = $params;
479  $func = array_shift( $params );
480  if ( !is_array( $func ) && method_exists( $this, $func ) ) {
481  $func = [ $this, $func ];
482  } elseif ( $passSelf ) {
483  array_unshift( $params, $this );
484  }
485  $ret = $func( ...$params );
486  flush();
487  if ( $ret !== false ) {
488  $updatesDone[] = $origParams;
489  $lbFactory->waitForReplication( [ 'timeout' => self::REPLICATION_WAIT_TIMEOUT ] );
490  } else {
491  $updatesSkipped[] = [ $func, $params, $origParams ];
492  }
493  }
494  $this->updatesSkipped = array_merge( $this->updatesSkipped, $updatesSkipped );
495  $this->updates = array_merge( $this->updates, $updatesDone );
496  }
497 
505  public function updateRowExists( $key ) {
506  $row = $this->db->selectRow(
507  'updatelog',
508  # T67813
509  '1 AS X',
510  [ 'ul_key' => $key ],
511  __METHOD__
512  );
513 
514  return (bool)$row;
515  }
516 
524  public function insertUpdateRow( $key, $val = null ) {
525  $this->db->clearFlag( DBO_DDLMODE );
526  $values = [ 'ul_key' => $key ];
527  if ( $val && $this->canUseNewUpdatelog() ) {
528  $values['ul_value'] = $val;
529  }
530  $this->db->insert( 'updatelog', $values, __METHOD__, 'IGNORE' );
531  $this->db->setFlag( DBO_DDLMODE );
532  }
533 
542  protected function canUseNewUpdatelog() {
543  return $this->db->tableExists( 'updatelog', __METHOD__ ) &&
544  $this->db->fieldExists( 'updatelog', 'ul_value', __METHOD__ );
545  }
546 
555  protected function doTable( $name ) {
557 
558  // Don't bother to check $wgSharedTables if there isn't a shared database
559  // or the user actually also wants to do updates on the shared database.
560  if ( $wgSharedDB === null || $this->shared ) {
561  return true;
562  }
563 
564  if ( in_array( $name, $wgSharedTables ) ) {
565  $this->output( "...skipping update to shared table $name.\n" );
566  return false;
567  } else {
568  return true;
569  }
570  }
571 
580  protected function getOldGlobalUpdates() {
581  global $wgExtNewFields, $wgExtNewTables, $wgExtModifiedFields,
582  $wgExtNewIndexes;
583 
584  $updates = [];
585 
586  foreach ( $wgExtNewTables as $tableRecord ) {
587  $updates[] = [
588  'addTable', $tableRecord[0], $tableRecord[1], true
589  ];
590  }
591 
592  foreach ( $wgExtNewFields as $fieldRecord ) {
593  $updates[] = [
594  'addField', $fieldRecord[0], $fieldRecord[1],
595  $fieldRecord[2], true
596  ];
597  }
598 
599  foreach ( $wgExtNewIndexes as $fieldRecord ) {
600  $updates[] = [
601  'addIndex', $fieldRecord[0], $fieldRecord[1],
602  $fieldRecord[2], true
603  ];
604  }
605 
606  foreach ( $wgExtModifiedFields as $fieldRecord ) {
607  $updates[] = [
608  'modifyField', $fieldRecord[0], $fieldRecord[1],
609  $fieldRecord[2], true
610  ];
611  }
612 
613  return $updates;
614  }
615 
624  abstract protected function getCoreUpdateList();
625 
631  public function copyFile( $filename ) {
632  $this->db->sourceFile(
633  $filename,
634  null,
635  null,
636  __METHOD__,
637  [ $this, 'appendLine' ]
638  );
639  }
640 
651  public function appendLine( $line ) {
652  $line = rtrim( $line ) . ";\n";
653  if ( fwrite( $this->fileHandle, $line ) === false ) {
654  throw new MWException( "trouble writing file" );
655  }
656 
657  return false;
658  }
659 
668  protected function applyPatch( $path, $isFullPath = false, $msg = null ) {
669  if ( $msg === null ) {
670  $msg = "Applying $path patch";
671  }
672  if ( $this->skipSchema ) {
673  $this->output( "...skipping schema change ($msg).\n" );
674 
675  return false;
676  }
677 
678  $this->output( "$msg ..." );
679 
680  if ( !$isFullPath ) {
681  $path = $this->patchPath( $this->db, $path );
682  }
683  if ( $this->fileHandle !== null ) {
684  $this->copyFile( $path );
685  } else {
686  $this->db->sourceFile( $path );
687  }
688  $this->output( "done.\n" );
689 
690  return true;
691  }
692 
702  public function patchPath( IDatabase $db, $patch ) {
703  global $IP;
704 
705  $dbType = $db->getType();
706  if ( file_exists( "$IP/maintenance/$dbType/archives/$patch" ) ) {
707  return "$IP/maintenance/$dbType/archives/$patch";
708  } else {
709  return "$IP/maintenance/archives/$patch";
710  }
711  }
712 
721  protected function addTable( $name, $patch, $fullpath = false ) {
722  if ( !$this->doTable( $name ) ) {
723  return true;
724  }
725 
726  if ( $this->db->tableExists( $name, __METHOD__ ) ) {
727  $this->output( "...$name table already exists.\n" );
728  } else {
729  return $this->applyPatch( $patch, $fullpath, "Creating $name table" );
730  }
731 
732  return true;
733  }
734 
744  protected function addField( $table, $field, $patch, $fullpath = false ) {
745  if ( !$this->doTable( $table ) ) {
746  return true;
747  }
748 
749  if ( !$this->db->tableExists( $table, __METHOD__ ) ) {
750  $this->output( "...$table table does not exist, skipping new field patch.\n" );
751  } elseif ( $this->db->fieldExists( $table, $field, __METHOD__ ) ) {
752  $this->output( "...have $field field in $table table.\n" );
753  } else {
754  return $this->applyPatch( $patch, $fullpath, "Adding $field field to table $table" );
755  }
756 
757  return true;
758  }
759 
769  protected function addIndex( $table, $index, $patch, $fullpath = false ) {
770  if ( !$this->doTable( $table ) ) {
771  return true;
772  }
773 
774  if ( !$this->db->tableExists( $table, __METHOD__ ) ) {
775  $this->output( "...skipping: '$table' table doesn't exist yet.\n" );
776  } elseif ( $this->db->indexExists( $table, $index, __METHOD__ ) ) {
777  $this->output( "...index $index already set on $table table.\n" );
778  } else {
779  return $this->applyPatch( $patch, $fullpath, "Adding index $index to table $table" );
780  }
781 
782  return true;
783  }
784 
795  protected function addIndexIfNoneExist( $table, $indexes, $patch, $fullpath = false ) {
796  if ( !$this->doTable( $table ) ) {
797  return true;
798  }
799 
800  if ( !$this->db->tableExists( $table, __METHOD__ ) ) {
801  $this->output( "...skipping: '$table' table doesn't exist yet.\n" );
802  return true;
803  }
804 
805  $newIndex = $indexes[0];
806  foreach ( $indexes as $index ) {
807  if ( $this->db->indexExists( $table, $index, __METHOD__ ) ) {
808  $this->output(
809  "...skipping index $newIndex because index $index already set on $table table.\n"
810  );
811  return true;
812  }
813  }
814 
815  return $this->applyPatch( $patch, $fullpath, "Adding index $index to table $table" );
816  }
817 
827  protected function dropField( $table, $field, $patch, $fullpath = false ) {
828  if ( !$this->doTable( $table ) ) {
829  return true;
830  }
831 
832  if ( $this->db->fieldExists( $table, $field, __METHOD__ ) ) {
833  return $this->applyPatch( $patch, $fullpath, "Table $table contains $field field. Dropping" );
834  } else {
835  $this->output( "...$table table does not contain $field field.\n" );
836  }
837 
838  return true;
839  }
840 
850  protected function dropIndex( $table, $index, $patch, $fullpath = false ) {
851  if ( !$this->doTable( $table ) ) {
852  return true;
853  }
854 
855  if ( $this->db->indexExists( $table, $index, __METHOD__ ) ) {
856  return $this->applyPatch( $patch, $fullpath, "Dropping $index index from table $table" );
857  } else {
858  $this->output( "...$index key doesn't exist.\n" );
859  }
860 
861  return true;
862  }
863 
876  protected function renameIndex( $table, $oldIndex, $newIndex,
877  $skipBothIndexExistWarning, $patch, $fullpath = false
878  ) {
879  if ( !$this->doTable( $table ) ) {
880  return true;
881  }
882 
883  // First requirement: the table must exist
884  if ( !$this->db->tableExists( $table, __METHOD__ ) ) {
885  $this->output( "...skipping: '$table' table doesn't exist yet.\n" );
886 
887  return true;
888  }
889 
890  // Second requirement: the new index must be missing
891  if ( $this->db->indexExists( $table, $newIndex, __METHOD__ ) ) {
892  $this->output( "...index $newIndex already set on $table table.\n" );
893  if ( !$skipBothIndexExistWarning &&
894  $this->db->indexExists( $table, $oldIndex, __METHOD__ )
895  ) {
896  $this->output( "...WARNING: $oldIndex still exists, despite it has " .
897  "been renamed into $newIndex (which also exists).\n" .
898  " $oldIndex should be manually removed if not needed anymore.\n" );
899  }
900 
901  return true;
902  }
903 
904  // Third requirement: the old index must exist
905  if ( !$this->db->indexExists( $table, $oldIndex, __METHOD__ ) ) {
906  $this->output( "...skipping: index $oldIndex doesn't exist.\n" );
907 
908  return true;
909  }
910 
911  // Requirements have been satisfied, patch can be applied
912  return $this->applyPatch(
913  $patch,
914  $fullpath,
915  "Renaming index $oldIndex into $newIndex to table $table"
916  );
917  }
918 
930  public function dropTable( $table, $patch = false, $fullpath = false ) {
931  if ( !$this->doTable( $table ) ) {
932  return true;
933  }
934 
935  if ( $this->db->tableExists( $table, __METHOD__ ) ) {
936  $msg = "Dropping table $table";
937 
938  if ( $patch === false ) {
939  $this->output( "$msg ..." );
940  $this->db->dropTable( $table, __METHOD__ );
941  $this->output( "done.\n" );
942  } else {
943  return $this->applyPatch( $patch, $fullpath, $msg );
944  }
945  } else {
946  $this->output( "...$table doesn't exist.\n" );
947  }
948 
949  return true;
950  }
951 
961  public function modifyField( $table, $field, $patch, $fullpath = false ) {
962  if ( !$this->doTable( $table ) ) {
963  return true;
964  }
965 
966  $updateKey = "$table-$field-$patch";
967  if ( !$this->db->tableExists( $table, __METHOD__ ) ) {
968  $this->output( "...$table table does not exist, skipping modify field patch.\n" );
969  } elseif ( !$this->db->fieldExists( $table, $field, __METHOD__ ) ) {
970  $this->output( "...$field field does not exist in $table table, " .
971  "skipping modify field patch.\n" );
972  } elseif ( $this->updateRowExists( $updateKey ) ) {
973  $this->output( "...$field in table $table already modified by patch $patch.\n" );
974  } else {
975  $apply = $this->applyPatch( $patch, $fullpath, "Modifying $field field of table $table" );
976  if ( $apply ) {
977  $this->insertUpdateRow( $updateKey );
978  }
979  return $apply;
980  }
981  return true;
982  }
983 
993  public function modifyTable( $table, $patch, $fullpath = false ) {
994  if ( !$this->doTable( $table ) ) {
995  return true;
996  }
997 
998  $updateKey = "$table-$patch";
999  if ( !$this->db->tableExists( $table, __METHOD__ ) ) {
1000  $this->output( "...$table table does not exist, skipping modify table patch.\n" );
1001  } elseif ( $this->updateRowExists( $updateKey ) ) {
1002  $this->output( "...table $table already modified by patch $patch.\n" );
1003  } else {
1004  $apply = $this->applyPatch( $patch, $fullpath, "Modifying table $table" );
1005  if ( $apply ) {
1006  $this->insertUpdateRow( $updateKey );
1007  }
1008  return $apply;
1009  }
1010  return true;
1011  }
1012 
1028  public function runMaintenance( $class, $script ) {
1029  $this->output( "Running $script...\n" );
1030  $task = $this->maintenance->runChild( $class );
1031  $ok = $task->execute();
1032  if ( !$ok ) {
1033  throw new RuntimeException( "Execution of $script did not complete successfully." );
1034  }
1035  $this->output( "done.\n" );
1036  }
1037 
1043  public function setFileAccess() {
1044  $repo = RepoGroup::singleton()->getLocalRepo();
1045  $zonePath = $repo->getZonePath( 'temp' );
1046  if ( $repo->getBackend()->directoryExists( [ 'dir' => $zonePath ] ) ) {
1047  // If the directory was never made, then it will have the right ACLs when it is made
1048  $status = $repo->getBackend()->secure( [
1049  'dir' => $zonePath,
1050  'noAccess' => true,
1051  'noListing' => true
1052  ] );
1053  if ( $status->isOK() ) {
1054  $this->output( "Set the local repo temp zone container to be private.\n" );
1055  } else {
1056  $this->output( "Failed to set the local repo temp zone container to be private.\n" );
1057  }
1058  }
1059  }
1060 
1064  public function purgeCache() {
1065  global $wgLocalisationCacheConf;
1066  // We can't guarantee that the user will be able to use TRUNCATE,
1067  // but we know that DELETE is available to us
1068  $this->output( "Purging caches..." );
1069 
1070  // ObjectCache
1071  $this->db->delete( 'objectcache', '*', __METHOD__ );
1072 
1073  // LocalisationCache
1074  if ( $wgLocalisationCacheConf['manualRecache'] ) {
1075  $this->rebuildLocalisationCache();
1076  }
1077 
1078  // ResourceLoader: Message cache
1079  $blobStore = new MessageBlobStore();
1080  $blobStore->clear();
1081 
1082  // ResourceLoader: File-dependency cache
1083  $this->db->delete( 'module_deps', '*', __METHOD__ );
1084  $this->output( "done.\n" );
1085  }
1086 
1090  protected function checkStats() {
1091  $this->output( "...site_stats is populated..." );
1092  $row = $this->db->selectRow( 'site_stats', '*', [ 'ss_row_id' => 1 ], __METHOD__ );
1093  if ( $row === false ) {
1094  $this->output( "data is missing! rebuilding...\n" );
1095  } elseif ( isset( $row->site_stats ) && $row->ss_total_pages == -1 ) {
1096  $this->output( "missing ss_total_pages, rebuilding...\n" );
1097  } else {
1098  $this->output( "done.\n" );
1099 
1100  return;
1101  }
1102  SiteStatsInit::doAllAndCommit( $this->db );
1103  }
1104 
1105  # Common updater functions
1106 
1110  protected function doActiveUsersInit() {
1111  $activeUsers = $this->db->selectField( 'site_stats', 'ss_active_users', '', __METHOD__ );
1112  if ( $activeUsers == -1 ) {
1113  $activeUsers = $this->db->selectField( 'recentchanges',
1114  'COUNT( DISTINCT rc_user_text )',
1115  [ 'rc_user != 0', 'rc_bot' => 0, "rc_log_type != 'newusers'" ], __METHOD__
1116  );
1117  $this->db->update( 'site_stats',
1118  [ 'ss_active_users' => intval( $activeUsers ) ],
1119  [ 'ss_row_id' => 1 ], __METHOD__, [ 'LIMIT' => 1 ]
1120  );
1121  }
1122  $this->output( "...ss_active_users user count set...\n" );
1123  }
1124 
1128  protected function doLogUsertextPopulation() {
1129  if ( !$this->updateRowExists( 'populate log_usertext' ) ) {
1130  $this->output(
1131  "Populating log_user_text field, printing progress markers. For large\n" .
1132  "databases, you may want to hit Ctrl-C and do this manually with\n" .
1133  "maintenance/populateLogUsertext.php.\n"
1134  );
1135 
1136  $task = $this->maintenance->runChild( PopulateLogUsertext::class );
1137  $task->execute();
1138  $this->output( "done.\n" );
1139  }
1140  }
1141 
1145  protected function doLogSearchPopulation() {
1146  if ( !$this->updateRowExists( 'populate log_search' ) ) {
1147  $this->output(
1148  "Populating log_search table, printing progress markers. For large\n" .
1149  "databases, you may want to hit Ctrl-C and do this manually with\n" .
1150  "maintenance/populateLogSearch.php.\n" );
1151 
1152  $task = $this->maintenance->runChild( PopulateLogSearch::class );
1153  $task->execute();
1154  $this->output( "done.\n" );
1155  }
1156  }
1157 
1161  protected function doCollationUpdate() {
1162  global $wgCategoryCollation;
1163  if ( $this->db->fieldExists( 'categorylinks', 'cl_collation', __METHOD__ ) ) {
1164  if ( $this->db->selectField(
1165  'categorylinks',
1166  'COUNT(*)',
1167  'cl_collation != ' . $this->db->addQuotes( $wgCategoryCollation ),
1168  __METHOD__
1169  ) == 0
1170  ) {
1171  $this->output( "...collations up-to-date.\n" );
1172 
1173  return;
1174  }
1175 
1176  $this->output( "Updating category collations..." );
1177  $task = $this->maintenance->runChild( UpdateCollation::class );
1178  $task->execute();
1179  $this->output( "...done.\n" );
1180  }
1181  }
1182 
1186  protected function doMigrateUserOptions() {
1187  if ( $this->db->tableExists( 'user_properties' ) ) {
1188  $cl = $this->maintenance->runChild( ConvertUserOptions::class, 'convertUserOptions.php' );
1189  $cl->execute();
1190  $this->output( "done.\n" );
1191  }
1192  }
1193 
1197  protected function doEnableProfiling() {
1198  global $wgProfiler;
1199 
1200  if ( !$this->doTable( 'profiling' ) ) {
1201  return;
1202  }
1203 
1204  $profileToDb = false;
1205  if ( isset( $wgProfiler['output'] ) ) {
1206  $out = $wgProfiler['output'];
1207  if ( $out === 'db' ) {
1208  $profileToDb = true;
1209  } elseif ( is_array( $out ) && in_array( 'db', $out ) ) {
1210  $profileToDb = true;
1211  }
1212  }
1213 
1214  if ( $profileToDb && !$this->db->tableExists( 'profiling', __METHOD__ ) ) {
1215  $this->applyPatch( 'patch-profiling.sql', false, 'Add profiling table' );
1216  }
1217  }
1218 
1222  protected function rebuildLocalisationCache() {
1226  $cl = $this->maintenance->runChild(
1227  RebuildLocalisationCache::class, 'rebuildLocalisationCache.php'
1228  );
1229  $this->output( "Rebuilding localisation cache...\n" );
1230  $cl->setForce();
1231  $cl->execute();
1232  $this->output( "done.\n" );
1233  }
1234 
1239  protected function disableContentHandlerUseDB() {
1240  global $wgContentHandlerUseDB;
1241 
1242  if ( $wgContentHandlerUseDB ) {
1243  $this->output( "Turning off Content Handler DB fields for this part of upgrade.\n" );
1244  $this->holdContentHandlerUseDB = $wgContentHandlerUseDB;
1245  $wgContentHandlerUseDB = false;
1246  }
1247  }
1248 
1252  protected function enableContentHandlerUseDB() {
1253  global $wgContentHandlerUseDB;
1254 
1255  if ( $this->holdContentHandlerUseDB ) {
1256  $this->output( "Content Handler DB fields should be usable now.\n" );
1257  $wgContentHandlerUseDB = $this->holdContentHandlerUseDB;
1258  }
1259  }
1260 
1265  protected function migrateComments() {
1268  !$this->updateRowExists( 'MigrateComments' )
1269  ) {
1270  $this->output(
1271  "Migrating comments to the 'comments' table, printing progress markers. For large\n" .
1272  "databases, you may want to hit Ctrl-C and do this manually with\n" .
1273  "maintenance/migrateComments.php.\n"
1274  );
1275  $task = $this->maintenance->runChild( MigrateComments::class, 'migrateComments.php' );
1276  $ok = $task->execute();
1277  $this->output( $ok ? "done.\n" : "errors were encountered.\n" );
1278  }
1279  }
1280 
1285  protected function migrateImageCommentTemp() {
1287 
1288  if ( $this->tableExists( 'image_comment_temp' ) ) {
1289  if ( $wgCommentTableSchemaMigrationStage > MIGRATION_OLD ) {
1290  $this->output( "Merging image_comment_temp into the image table\n" );
1291  $task = $this->maintenance->runChild(
1292  MigrateImageCommentTemp::class, 'migrateImageCommentTemp.php'
1293  );
1294  $task->setForce();
1295  $ok = $task->execute();
1296  $this->output( $ok ? "done.\n" : "errors were encountered.\n" );
1297  } else {
1298  $ok = true;
1299  }
1300  if ( $ok ) {
1301  $this->dropTable( 'image_comment_temp' );
1302  }
1303  }
1304  }
1305 
1310  protected function migrateActors() {
1313  !$this->updateRowExists( 'MigrateActors' )
1314  ) {
1315  $this->output(
1316  "Migrating actors to the 'actor' table, printing progress markers. For large\n" .
1317  "databases, you may want to hit Ctrl-C and do this manually with\n" .
1318  "maintenance/migrateActors.php.\n"
1319  );
1320  $task = $this->maintenance->runChild( 'MigrateActors', 'migrateActors.php' );
1321  $ok = $task->execute();
1322  $this->output( $ok ? "done.\n" : "errors were encountered.\n" );
1323  }
1324  }
1325 
1330  protected function migrateArchiveText() {
1331  if ( $this->db->fieldExists( 'archive', 'ar_text', __METHOD__ ) ) {
1332  $this->output( "Migrating archive ar_text to modern storage.\n" );
1333  $task = $this->maintenance->runChild( MigrateArchiveText::class, 'migrateArchiveText.php' );
1334  $task->setForce();
1335  if ( $task->execute() ) {
1336  $this->applyPatch( 'patch-drop-ar_text.sql', false,
1337  'Dropping ar_text and ar_flags columns' );
1338  }
1339  }
1340  }
1341 
1346  protected function populateArchiveRevId() {
1347  $info = $this->db->fieldInfo( 'archive', 'ar_rev_id', __METHOD__ );
1348  if ( !$info ) {
1349  throw new MWException( 'Missing ar_rev_id field of archive table. Should not happen.' );
1350  }
1351  if ( $info->isNullable() ) {
1352  $this->output( "Populating ar_rev_id.\n" );
1353  $task = $this->maintenance->runChild( 'PopulateArchiveRevId', 'populateArchiveRevId.php' );
1354  if ( $task->execute() ) {
1355  $this->applyPatch( 'patch-ar_rev_id-not-null.sql', false,
1356  'Making ar_rev_id not nullable' );
1357  }
1358  }
1359  }
1360 
1365  protected function populateExternallinksIndex60() {
1366  if ( !$this->updateRowExists( 'populate externallinks.el_index_60' ) ) {
1367  $this->output(
1368  "Populating el_index_60 field, printing progress markers. For large\n" .
1369  "databases, you may want to hit Ctrl-C and do this manually with\n" .
1370  "maintenance/populateExternallinksIndex60.php.\n"
1371  );
1372  $task = $this->maintenance->runChild( 'PopulateExternallinksIndex60',
1373  'populateExternallinksIndex60.php' );
1374  $task->execute();
1375  $this->output( "done.\n" );
1376  }
1377  }
1378 
1383  protected function populateContentTables() {
1386  !$this->updateRowExists( 'PopulateContentTables' )
1387  ) {
1388  $this->output(
1389  "Migrating revision data to the MCR 'slot' and 'content' tables, printing progress markers.\n" .
1390  "For large databases, you may want to hit Ctrl-C and do this manually with\n" .
1391  "maintenance/populateContentTables.php.\n"
1392  );
1393  $task = $this->maintenance->runChild(
1394  PopulateContentTables::class, 'populateContentTables.php'
1395  );
1396  $ok = $task->execute();
1397  $this->output( $ok ? "done.\n" : "errors were encountered.\n" );
1398  if ( $ok ) {
1399  $this->insertUpdateRow( 'PopulateContentTables' );
1400  }
1401  }
1402  }
1403 }
DatabaseUpdater\output
output( $str)
Output some text.
Definition: DatabaseUpdater.php:215
DatabaseUpdater\dropIndex
dropIndex( $table, $index, $patch, $fullpath=false)
Drop an index from an existing table.
Definition: DatabaseUpdater.php:850
DatabaseUpdater\modifyExtensionTable
modifyExtensionTable( $tableName, $sqlPath)
Definition: DatabaseUpdater.php:358
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:930
$status
Status::newGood()` to allow deletion, and then `return false` from the hook function. Ensure you consume the 'ChangeTagAfterDelete' hook to carry out custom deletion actions. $tag:name of the tag $user:user initiating the action & $status:Status object. See above. 'ChangeTagsListActive':Allows you to nominate which of the tags your extension uses are in active use. & $tags:list of all active tags. Append to this array. 'ChangeTagsAfterUpdateTags':Called after tags have been updated with the ChangeTags::updateTags function. Params:$addedTags:tags effectively added in the update $removedTags:tags effectively removed in the update $prevTags:tags that were present prior to the update $rc_id:recentchanges table id $rev_id:revision table id $log_id:logging table id $params:tag params $rc:RecentChange being tagged when the tagging accompanies the action, or null $user:User who performed the tagging when the tagging is subsequent to the action, or null 'ChangeTagsAllowedAdd':Called when checking if a user can add tags to a change. & $allowedTags:List of all the tags the user is allowed to add. Any tags the user wants to add( $addTags) that are not in this array will cause it to fail. You may add or remove tags to this array as required. $addTags:List of tags user intends to add. $user:User who is adding the tags. 'ChangeUserGroups':Called before user groups are changed. $performer:The User who will perform the change $user:The User whose groups will be changed & $add:The groups that will be added & $remove:The groups that will be removed 'Collation::factory':Called if $wgCategoryCollation is an unknown collation. $collationName:Name of the collation in question & $collationObject:Null. Replace with a subclass of the Collation class that implements the collation given in $collationName. 'ConfirmEmailComplete':Called after a user 's email has been confirmed successfully. $user:user(object) whose email is being confirmed 'ContentAlterParserOutput':Modify parser output for a given content object. Called by Content::getParserOutput after parsing has finished. Can be used for changes that depend on the result of the parsing but have to be done before LinksUpdate is called(such as adding tracking categories based on the rendered HTML). $content:The Content to render $title:Title of the page, as context $parserOutput:ParserOutput to manipulate 'ContentGetParserOutput':Customize parser output for a given content object, called by AbstractContent::getParserOutput. May be used to override the normal model-specific rendering of page content. $content:The Content to render $title:Title of the page, as context $revId:The revision ID, as context $options:ParserOptions for rendering. To avoid confusing the parser cache, the output can only depend on parameters provided to this hook function, not on global state. $generateHtml:boolean, indicating whether full HTML should be generated. If false, generation of HTML may be skipped, but other information should still be present in the ParserOutput object. & $output:ParserOutput, to manipulate or replace 'ContentHandlerDefaultModelFor':Called when the default content model is determined for a given title. May be used to assign a different model for that title. $title:the Title in question & $model:the model name. Use with CONTENT_MODEL_XXX constants. 'ContentHandlerForModelID':Called when a ContentHandler is requested for a given content model name, but no entry for that model exists in $wgContentHandlers. Note:if your extension implements additional models via this hook, please use GetContentModels hook to make them known to core. $modeName:the requested content model name & $handler:set this to a ContentHandler object, if desired. 'ContentModelCanBeUsedOn':Called to determine whether that content model can be used on a given page. This is especially useful to prevent some content models to be used in some special location. $contentModel:ID of the content model in question $title:the Title in question. & $ok:Output parameter, whether it is OK to use $contentModel on $title. Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok. 'ContribsPager::getQueryInfo':Before the contributions query is about to run & $pager:Pager object for contributions & $queryInfo:The query for the contribs Pager 'ContribsPager::reallyDoQuery':Called before really executing the query for My Contributions & $data:an array of results of all contribs queries $pager:The ContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'ContributionsLineEnding':Called before a contributions HTML line is finished $page:SpecialPage object for contributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'ContributionsToolLinks':Change tool links above Special:Contributions $id:User identifier $title:User page title & $tools:Array of tool links $specialPage:SpecialPage instance for context and services. Can be either SpecialContributions or DeletedContributionsPage. Extensions should type hint against a generic SpecialPage though. 'ConvertContent':Called by AbstractContent::convert when a conversion to another content model is requested. Handler functions that modify $result should generally return false to disable further attempts at conversion. $content:The Content object to be converted. $toModel:The ID of the content model to convert to. $lossy:boolean indicating whether lossy conversion is allowed. & $result:Output parameter, in case the handler function wants to provide a converted Content object. Note that $result->getContentModel() must return $toModel. 'ContentSecurityPolicyDefaultSource':Modify the allowed CSP load sources. This affects all directives except for the script directive. If you want to add a script source, see ContentSecurityPolicyScriptSource hook. & $defaultSrc:Array of Content-Security-Policy allowed sources $policyConfig:Current configuration for the Content-Security-Policy header $mode:ContentSecurityPolicy::REPORT_ONLY_MODE or ContentSecurityPolicy::FULL_MODE depending on type of header 'ContentSecurityPolicyDirectives':Modify the content security policy directives. Use this only if ContentSecurityPolicyDefaultSource and ContentSecurityPolicyScriptSource do not meet your needs. & $directives:Array of CSP directives $policyConfig:Current configuration for the CSP header $mode:ContentSecurityPolicy::REPORT_ONLY_MODE or ContentSecurityPolicy::FULL_MODE depending on type of header 'ContentSecurityPolicyScriptSource':Modify the allowed CSP script sources. Note that you also have to use ContentSecurityPolicyDefaultSource if you want non-script sources to be loaded from whatever you add. & $scriptSrc:Array of CSP directives $policyConfig:Current configuration for the CSP header $mode:ContentSecurityPolicy::REPORT_ONLY_MODE or ContentSecurityPolicy::FULL_MODE depending on type of header 'CustomEditor':When invoking the page editor Return true to allow the normal editor to be used, or false if implementing a custom editor, e.g. for a special namespace, etc. $article:Article being edited $user:User performing the edit 'DatabaseOraclePostInit':Called after initialising an Oracle database $db:the DatabaseOracle object 'DeletedContribsPager::reallyDoQuery':Called before really executing the query for Special:DeletedContributions Similar to ContribsPager::reallyDoQuery & $data:an array of results of all contribs queries $pager:The DeletedContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'DeletedContributionsLineEnding':Called before a DeletedContributions HTML line is finished. Similar to ContributionsLineEnding $page:SpecialPage object for DeletedContributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'DeleteUnknownPreferences':Called by the cleanupPreferences.php maintenance script to build a WHERE clause with which to delete preferences that are not known about. This hook is used by extensions that have dynamically-named preferences that should not be deleted in the usual cleanup process. For example, the Gadgets extension creates preferences prefixed with 'gadget-', and so anything with that prefix is excluded from the deletion. &where:An array that will be passed as the $cond parameter to IDatabase::select() to determine what will be deleted from the user_properties table. $db:The IDatabase object, useful for accessing $db->buildLike() etc. 'DifferenceEngineAfterLoadNewText':called in DifferenceEngine::loadNewText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before returning true from this function. $differenceEngine:DifferenceEngine object 'DifferenceEngineLoadTextAfterNewContentIsLoaded':called in DifferenceEngine::loadText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before checking if the variable 's value is null. This hook can be used to inject content into said class member variable. $differenceEngine:DifferenceEngine object 'DifferenceEngineMarkPatrolledLink':Allows extensions to change the "mark as patrolled" link which is shown both on the diff header as well as on the bottom of a page, usually wrapped in a span element which has class="patrollink". $differenceEngine:DifferenceEngine object & $markAsPatrolledLink:The "mark as patrolled" link HTML(string) $rcid:Recent change ID(rc_id) for this change(int) 'DifferenceEngineMarkPatrolledRCID':Allows extensions to possibly change the rcid parameter. For example the rcid might be set to zero due to the user being the same as the performer of the change but an extension might still want to show it under certain conditions. & $rcid:rc_id(int) of the change or 0 $differenceEngine:DifferenceEngine object $change:RecentChange object $user:User object representing the current user 'DifferenceEngineNewHeader':Allows extensions to change the $newHeader variable, which contains information about the new revision, such as the revision 's author, whether the revision was marked as a minor edit or not, etc. $differenceEngine:DifferenceEngine object & $newHeader:The string containing the various #mw-diff-otitle[1-5] divs, which include things like revision author info, revision comment, RevisionDelete link and more $formattedRevisionTools:Array containing revision tools, some of which may have been injected with the DiffRevisionTools hook $nextlink:String containing the link to the next revision(if any) $status
Definition: hooks.txt:1305
DatabaseUpdater\copyFile
copyFile( $filename)
Append an SQL fragment to the open file handle.
Definition: DatabaseUpdater.php:631
DatabaseUpdater\$updatesSkipped
array $updatesSkipped
Array of updates that were skipped.
Definition: DatabaseUpdater.php:51
Wikimedia\Rdbms\Database
Relational database abstraction object.
Definition: Database.php:48
RepoGroup\singleton
static singleton()
Get a RepoGroup instance.
Definition: RepoGroup.php:59
DatabaseUpdater\applyPatch
applyPatch( $path, $isFullPath=false, $msg=null)
Applies a SQL patch.
Definition: DatabaseUpdater.php:668
DatabaseUpdater\doCollationUpdate
doCollationUpdate()
Update CategoryLinks collation.
Definition: DatabaseUpdater.php:1161
SiteStatsInit\doAllAndCommit
static doAllAndCommit( $database, array $options=[])
Do all updates and commit them.
Definition: SiteStatsInit.php:134
$wgSharedTables
$wgSharedTables
Definition: DefaultSettings.php:1996
DatabaseUpdater
Class for handling database updates.
Definition: DatabaseUpdater.php:36
DatabaseUpdater\populateExternallinksIndex60
populateExternallinksIndex60()
Populates the externallinks.el_index_60 field.
Definition: DatabaseUpdater.php:1365
$wgAutoloadClasses
$wgAutoloadClasses['ReplaceTextHooks']
Definition: ReplaceText.php:61
DatabaseUpdater\addPostDatabaseUpdateMaintenance
addPostDatabaseUpdateMaintenance( $class)
Add a maintenance script to be run after the database updates are complete.
Definition: DatabaseUpdater.php:382
DatabaseUpdater\checkStats
checkStats()
Check the site_stats table is not properly populated.
Definition: DatabaseUpdater.php:1090
$wgCommentTableSchemaMigrationStage
int $wgCommentTableSchemaMigrationStage
Comment table schema migration stage.
Definition: DefaultSettings.php:8967
$wgSharedDB
$wgSharedDB
Shared database for multiple wikis.
Definition: DefaultSettings.php:1986
DatabaseUpdater\getCoreUpdateList
getCoreUpdateList()
Get an array of updates to perform on the database.
DatabaseUpdater\migrateImageCommentTemp
migrateImageCommentTemp()
Merge image_comment_temp into the image table.
Definition: DatabaseUpdater.php:1285
DatabaseUpdater\doMigrateUserOptions
doMigrateUserOptions()
Migrates user options from the user table blob to user_properties.
Definition: DatabaseUpdater.php:1186
DatabaseUpdater\populateContentTables
populateContentTables()
Populates the MCR content tables.
Definition: DatabaseUpdater.php:1383
DatabaseUpdater\dropField
dropField( $table, $field, $patch, $fullpath=false)
Drop a field from an existing table.
Definition: DatabaseUpdater.php:827
DatabaseUpdater\enableContentHandlerUseDB
enableContentHandlerUseDB()
Turns content handler fields back on.
Definition: DatabaseUpdater.php:1252
DatabaseUpdater\addField
addField( $table, $field, $patch, $fullpath=false)
Add a new field to an existing table.
Definition: DatabaseUpdater.php:744
DatabaseUpdater\doTable
doTable( $name)
Returns whether updates should be executed on the database table $name.
Definition: DatabaseUpdater.php:555
$params
$params
Definition: styleTest.css.php:44
$wgMultiContentRevisionSchemaMigrationStage
int $wgMultiContentRevisionSchemaMigrationStage
RevisionStore table schema migration stage (content, slots, content_models & slot_roles tables).
Definition: DefaultSettings.php:8988
DatabaseUpdater\getPostDatabaseUpdateMaintenance
getPostDatabaseUpdateMaintenance()
Definition: DatabaseUpdater.php:400
Maintenance\setDB
setDB(IDatabase $db)
Sets database object to be returned by getDB().
Definition: Maintenance.php:1364
DatabaseUpdater\appendLine
appendLine( $line)
Append a line to the open filehandle.
Definition: DatabaseUpdater.php:651
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: maintenance.txt:39
DatabaseUpdater\patchPath
patchPath(IDatabase $db, $patch)
Get the full path of a patch file.
Definition: DatabaseUpdater.php:702
DatabaseUpdater\getSchemaVars
getSchemaVars()
Get appropriate schema variables in the current database connection.
Definition: DatabaseUpdater.php:434
DatabaseUpdater\REPLICATION_WAIT_TIMEOUT
const REPLICATION_WAIT_TIMEOUT
Definition: DatabaseUpdater.php:37
DatabaseUpdater\addExtensionIndex
addExtensionIndex( $tableName, $indexName, $sqlPath)
Definition: DatabaseUpdater.php:263
$wgContentHandlerUseDB
$wgContentHandlerUseDB
Set to false to disable use of the database fields introduced by the ContentHandler facility.
Definition: DefaultSettings.php:8624
DatabaseUpdater\$db
Database $db
Handle to the database subclass.
Definition: DatabaseUpdater.php:64
DatabaseUpdater\migrateComments
migrateComments()
Migrate comments to the new 'comment' table.
Definition: DatabaseUpdater.php:1265
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:38
DatabaseUpdater\doActiveUsersInit
doActiveUsersInit()
Sets the number of active users in the site_stats table.
Definition: DatabaseUpdater.php:1110
MIGRATION_WRITE_NEW
const MIGRATION_WRITE_NEW
Definition: Defines.php:317
DatabaseUpdater\dropExtensionIndex
dropExtensionIndex( $tableName, $indexName, $sqlPath)
Drop an index from an extension table.
Definition: DatabaseUpdater.php:300
DatabaseUpdater\$updates
array $updates
Array of updates to perform on the database.
Definition: DatabaseUpdater.php:44
DatabaseUpdater\doEnableProfiling
doEnableProfiling()
Enable profiling table when it's turned on.
Definition: DatabaseUpdater.php:1197
ExtensionRegistry\getInstance
static getInstance()
Definition: ExtensionRegistry.php:88
DatabaseUpdater\addExtensionUpdate
addExtensionUpdate(array $update)
Add a new update coming from an extension.
Definition: DatabaseUpdater.php:239
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)
DatabaseUpdater\setFileAccess
setFileAccess()
Set any .htaccess files or equivilent for storage repos.
Definition: DatabaseUpdater.php:1043
MWException
MediaWiki exception.
Definition: MWException.php:26
$wgProfiler
$wgProfiler
Profiler configuration.
Definition: DefaultSettings.php:6416
DatabaseUpdater\renameIndex
renameIndex( $table, $oldIndex, $newIndex, $skipBothIndexExistWarning, $patch, $fullpath=false)
Rename an index from an existing table.
Definition: DatabaseUpdater.php:876
DatabaseUpdater\getExtensionUpdates
getExtensionUpdates()
Get the list of extension-defined updates.
Definition: DatabaseUpdater.php:391
DatabaseUpdater\migrateArchiveText
migrateArchiveText()
Migrate ar_text to modern storage.
Definition: DatabaseUpdater.php:1330
DatabaseUpdater\$maintenance
Maintenance $maintenance
Definition: DatabaseUpdater.php:69
DatabaseUpdater\modifyTable
modifyTable( $table, $patch, $fullpath=false)
Modify an existing table, similar to modifyField.
Definition: DatabaseUpdater.php:993
Wikimedia\Rdbms\Database\setFlag
setFlag( $flag, $remember=self::REMEMBER_NOTHING)
Set a flag for this connection.
Definition: Database.php:779
$wgCommandLineMode
global $wgCommandLineMode
Definition: DevelopmentSettings.php:27
$IP
$IP
Definition: update.php:3
DatabaseUpdater\modifyExtensionField
modifyExtensionField( $tableName, $fieldName, $sqlPath)
Definition: DatabaseUpdater.php:348
DatabaseUpdater\rebuildLocalisationCache
rebuildLocalisationCache()
Rebuilds the localisation cache.
Definition: DatabaseUpdater.php:1222
$queue
$queue
Definition: mergeMessageFileList.php:160
Installer\getExistingLocalSettings
static getExistingLocalSettings()
Determine if LocalSettings.php exists.
Definition: Installer.php:594
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
DatabaseUpdater\getDB
getDB()
Get a database connection to run updates.
Definition: DatabaseUpdater.php:205
$wgLocalisationCacheConf
$wgLocalisationCacheConf
Localisation cache configuration.
Definition: DefaultSettings.php:2600
DatabaseUpdater\runUpdates
runUpdates(array $updates, $passSelf)
Helper function for doUpdates()
Definition: DatabaseUpdater.php:472
DatabaseUpdater\doUpdates
doUpdates(array $what=[ 'core', 'extensions', 'stats'])
Do all the updates.
Definition: DatabaseUpdater.php:443
$vars
static configuration should be added through ResourceLoaderGetConfigVars instead & $vars
Definition: hooks.txt:2270
FakeMaintenance
Fake maintenance wrapper, mostly used for the web installer/updater.
Definition: Maintenance.php:1668
array
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
DatabaseUpdater\updateRowExists
updateRowExists( $key)
Helper function: check if the given key is present in the updatelog table.
Definition: DatabaseUpdater.php:505
DatabaseUpdater\disableContentHandlerUseDB
disableContentHandlerUseDB()
Turns off content handler fields during parts of the upgrade where they aren't available.
Definition: DatabaseUpdater.php:1239
DatabaseUpdater\doLogSearchPopulation
doLogSearchPopulation()
Migrate log params to new table and index for searching.
Definition: DatabaseUpdater.php:1145
MIGRATION_OLD
const MIGRATION_OLD
Definition: Defines.php:315
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:302
$line
$line
Definition: cdb.php:59
DBO_DDLMODE
const DBO_DDLMODE
Definition: defines.php:16
DatabaseUpdater\__construct
__construct(Database &$db, $shared, Maintenance $maintenance=null)
Definition: DatabaseUpdater.php:116
DatabaseUpdater\populateArchiveRevId
populateArchiveRevId()
Populate ar_rev_id, then make it not nullable.
Definition: DatabaseUpdater.php:1346
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:542
DatabaseUpdater\runMaintenance
runMaintenance( $class, $script)
Run a maintenance script.
Definition: DatabaseUpdater.php:1028
DatabaseUpdater\$fileHandle
resource $fileHandle
File handle for SQL output.
Definition: DatabaseUpdater.php:97
SCHEMA_COMPAT_WRITE_NEW
const SCHEMA_COMPAT_WRITE_NEW
Definition: Defines.php:286
$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:2036
DatabaseUpdater\getOldGlobalUpdates
getOldGlobalUpdates()
Before 1.17, we used to handle updates via stuff like $wgExtNewTables/Fields/Indexes.
Definition: DatabaseUpdater.php:580
DatabaseUpdater\doLogUsertextPopulation
doLogUsertextPopulation()
Populates the log_user_text field in the logging table.
Definition: DatabaseUpdater.php:1128
DatabaseUpdater\newForDB
static newForDB(Database $db, $shared=false, Maintenance $maintenance=null)
Definition: DatabaseUpdater.php:189
DatabaseUpdater\tableExists
tableExists( $tableName)
Definition: DatabaseUpdater.php:369
DatabaseUpdater\addExtensionField
addExtensionField( $tableName, $columnName, $sqlPath)
Definition: DatabaseUpdater.php:275
$args
if( $line===false) $args
Definition: cdb.php:64
DatabaseUpdater\modifyField
modifyField( $table, $field, $patch, $fullpath=false)
Modify an existing field.
Definition: DatabaseUpdater.php:961
DatabaseUpdater\writeSchemaUpdateFile
writeSchemaUpdateFile(array $schemaUpdate=[])
Definition: DatabaseUpdater.php:410
DatabaseUpdater\addIndexIfNoneExist
addIndexIfNoneExist( $table, $indexes, $patch, $fullpath=false)
Add a new index to an existing table if none of the given indexes exist.
Definition: DatabaseUpdater.php:795
$wgHooks
$wgHooks['ArticleShow'][]
Definition: hooks.txt:108
DatabaseUpdater\loadExtensions
loadExtensions()
Loads LocalSettings.php, if needed, and initialises everything needed for LoadExtensionSchemaUpdates ...
Definition: DatabaseUpdater.php:154
$path
$path
Definition: NoLocalSettings.php:25
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:327
DatabaseUpdater\addTable
addTable( $name, $patch, $fullpath=false)
Add a new table to the database.
Definition: DatabaseUpdater.php:721
DatabaseUpdater\$shared
$shared
Definition: DatabaseUpdater.php:71
MessageBlobStore
This class generates message blobs for use by ResourceLoader modules.
Definition: MessageBlobStore.php:37
Wikimedia\Rdbms\IDatabase\getType
getType()
Get the type of the DBMS, as it appears in $wgDBtype.
DatabaseUpdater\migrateActors
migrateActors()
Migrate actors to the new 'actor' table.
Definition: DatabaseUpdater.php:1310
DatabaseUpdater\dropExtensionField
dropExtensionField( $tableName, $columnName, $sqlPath)
Definition: DatabaseUpdater.php:287
DatabaseUpdater\purgeCache
purgeCache()
Purge various database caches.
Definition: DatabaseUpdater.php:1064
true
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 just before the function returns a value If you return true
Definition: hooks.txt:2036
$wgCategoryCollation
$wgCategoryCollation
Specify how category names should be sorted, when listed on a category page.
Definition: DefaultSettings.php:7692
DatabaseUpdater\$skipSchema
bool $skipSchema
Flag specifying whether or not to skip schema (e.g.
Definition: DatabaseUpdater.php:104
class
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52
DatabaseUpdater\addExtensionTable
addExtensionTable( $tableName, $sqlPath)
Convenience wrapper for addExtensionUpdate() when adding a new table (which is the most common usage ...
Definition: DatabaseUpdater.php:252
Installer\getDBTypes
static getDBTypes()
Get a list of known DB types.
Definition: Installer.php:467
MediaWikiServices
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
Definition: injection.txt:23
DatabaseUpdater\initOldGlobals
initOldGlobals()
Initialize all of the old globals.
Definition: DatabaseUpdater.php:136
DatabaseUpdater\addIndex
addIndex( $table, $index, $patch, $fullpath=false)
Add a new index to an existing table.
Definition: DatabaseUpdater.php:769
DatabaseUpdater\$extensionUpdates
array $extensionUpdates
List of extension-provided database updates.
Definition: DatabaseUpdater.php:57
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:524
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:200
DatabaseUpdater\$postDatabaseUpdateMaintenance
string[] $postDatabaseUpdateMaintenance
Scripts to run after database update Should be a subclass of LoggedUpdateMaintenance.
Definition: DatabaseUpdater.php:77
DatabaseUpdater\dropExtensionTable
dropExtensionTable( $tableName, $sqlPath)
Definition: DatabaseUpdater.php:311
DatabaseUpdater\$holdContentHandlerUseDB
$holdContentHandlerUseDB
Hold the value of $wgContentHandlerUseDB during the upgrade.
Definition: DatabaseUpdater.php:109
$out
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Definition: hooks.txt:813
$type
$type
Definition: testCompression.php:48
$wgActorTableSchemaMigrationStage
int $wgActorTableSchemaMigrationStage
Actor table schema migration stage.
Definition: DefaultSettings.php:9006