MediaWiki  1.32.5
SqliteUpdater.php
Go to the documentation of this file.
1 <?php
25 
33 
34  protected function getCoreUpdateList() {
35  return [
36  [ 'disableContentHandlerUseDB' ],
37 
38  // 1.14
39  [ 'addField', 'site_stats', 'ss_active_users', 'patch-ss_active_users.sql' ],
40  [ 'doActiveUsersInit' ],
41  [ 'addField', 'ipblocks', 'ipb_allow_usertalk', 'patch-ipb_allow_usertalk.sql' ],
42  [ 'sqliteInitialIndexes' ],
43 
44  // 1.15
45  [ 'addTable', 'change_tag', 'patch-change_tag.sql' ],
46  [ 'addTable', 'tag_summary', 'patch-tag_summary.sql' ],
47  [ 'addTable', 'valid_tag', 'patch-valid_tag.sql' ],
48 
49  // 1.16
50  [ 'addTable', 'user_properties', 'patch-user_properties.sql' ],
51  [ 'addTable', 'log_search', 'patch-log_search.sql' ],
52  [ 'addField', 'logging', 'log_user_text', 'patch-log_user_text.sql' ],
53  # listed separately from the previous update because 1.16 was released without this update
54  [ 'doLogUsertextPopulation' ],
55  [ 'doLogSearchPopulation' ],
56  [ 'addTable', 'l10n_cache', 'patch-l10n_cache.sql' ],
57  [ 'addIndex', 'tag_summary', 'tag_summary_rc_id', 'patch-change_tag-indexes.sql' ],
58  [ 'addField', 'redirect', 'rd_interwiki', 'patch-rd_interwiki.sql' ],
59  [ 'sqliteSetupSearchindex' ],
60 
61  // 1.17
62  [ 'addTable', 'iwlinks', 'patch-iwlinks.sql' ],
63  [ 'addIndex', 'iwlinks', 'iwl_prefix_title_from', 'patch-rename-iwl_prefix.sql' ],
64  [ 'addField', 'updatelog', 'ul_value', 'patch-ul_value.sql' ],
65  [ 'addField', 'interwiki', 'iw_api', 'patch-iw_api_and_wikiid.sql' ],
66  [ 'dropIndex', 'iwlinks', 'iwl_prefix', 'patch-kill-iwl_prefix.sql' ],
67  [ 'addField', 'categorylinks', 'cl_collation', 'patch-categorylinks-better-collation.sql' ],
68  [ 'addTable', 'module_deps', 'patch-module_deps.sql' ],
69  [ 'dropIndex', 'archive', 'ar_page_revid', 'patch-archive_kill_ar_page_revid.sql' ],
70  [ 'addIndexIfNoneExist',
71  'archive', [ 'ar_revid', 'ar_revid_uniq' ], 'patch-archive_ar_revid.sql' ],
72 
73  // 1.18
74  [ 'addIndex', 'user', 'user_email', 'patch-user_email_index.sql' ],
75  [ 'addTable', 'uploadstash', 'patch-uploadstash.sql' ],
76  [ 'addTable', 'user_former_groups', 'patch-user_former_groups.sql' ],
77 
78  // 1.19
79  [ 'doMigrateUserOptions' ],
80  [ 'dropField', 'user', 'user_options', 'patch-drop-user_options.sql' ],
81  [ 'addField', 'revision', 'rev_sha1', 'patch-rev_sha1.sql' ],
82  [ 'addField', 'archive', 'ar_sha1', 'patch-ar_sha1.sql' ],
83  [ 'addIndex', 'page', 'page_redirect_namespace_len',
84  'patch-page_redirect_namespace_len.sql' ],
85  [ 'addField', 'uploadstash', 'us_chunk_inx', 'patch-uploadstash_chunk.sql' ],
86  [ 'addfield', 'job', 'job_timestamp', 'patch-jobs-add-timestamp.sql' ],
87 
88  // 1.20
89  [ 'addIndex', 'revision', 'page_user_timestamp', 'patch-revision-user-page-index.sql' ],
90  [ 'addField', 'ipblocks', 'ipb_parent_block_id', 'patch-ipb-parent-block-id.sql' ],
91  [ 'addIndex', 'ipblocks', 'ipb_parent_block_id', 'patch-ipb-parent-block-id-index.sql' ],
92  [ 'dropField', 'category', 'cat_hidden', 'patch-cat_hidden.sql' ],
93 
94  // 1.21
95  [ 'addField', 'revision', 'rev_content_format', 'patch-revision-rev_content_format.sql' ],
96  [ 'addField', 'revision', 'rev_content_model', 'patch-revision-rev_content_model.sql' ],
97  [ 'addField', 'archive', 'ar_content_format', 'patch-archive-ar_content_format.sql' ],
98  [ 'addField', 'archive', 'ar_content_model', 'patch-archive-ar_content_model.sql' ],
99  [ 'addField', 'page', 'page_content_model', 'patch-page-page_content_model.sql' ],
100  [ 'enableContentHandlerUseDB' ],
101 
102  [ 'dropField', 'site_stats', 'ss_admins', 'patch-drop-ss_admins.sql' ],
103  [ 'dropField', 'recentchanges', 'rc_moved_to_title', 'patch-rc_moved.sql' ],
104  [ 'addTable', 'sites', 'patch-sites.sql' ],
105  [ 'addField', 'filearchive', 'fa_sha1', 'patch-fa_sha1.sql' ],
106  [ 'addField', 'job', 'job_token', 'patch-job_token.sql' ],
107  [ 'addField', 'job', 'job_attempts', 'patch-job_attempts.sql' ],
108  [ 'doEnableProfiling' ],
109  [ 'addField', 'uploadstash', 'us_props', 'patch-uploadstash-us_props.sql' ],
110  [ 'modifyField', 'user_groups', 'ug_group', 'patch-ug_group-length-increase-255.sql' ],
111  [ 'modifyField', 'user_former_groups', 'ufg_group',
112  'patch-ufg_group-length-increase-255.sql' ],
113  [ 'addIndex', 'page_props', 'pp_propname_page',
114  'patch-page_props-propname-page-index.sql' ],
115  [ 'addIndex', 'image', 'img_media_mime', 'patch-img_media_mime-index.sql' ],
116 
117  // 1.22
118  [ 'addIndex', 'iwlinks', 'iwl_prefix_from_title', 'patch-iwlinks-from-title-index.sql' ],
119  [ 'addField', 'archive', 'ar_id', 'patch-archive-ar_id.sql' ],
120  [ 'addField', 'externallinks', 'el_id', 'patch-externallinks-el_id.sql' ],
121 
122  // 1.23
123  [ 'addField', 'recentchanges', 'rc_source', 'patch-rc_source.sql' ],
124  [ 'addIndex', 'logging', 'log_user_text_type_time',
125  'patch-logging_user_text_type_time_index.sql' ],
126  [ 'addIndex', 'logging', 'log_user_text_time', 'patch-logging_user_text_time_index.sql' ],
127  [ 'addField', 'page', 'page_links_updated', 'patch-page_links_updated.sql' ],
128  [ 'addField', 'user', 'user_password_expires', 'patch-user_password_expire.sql' ],
129 
130  // 1.24
131  [ 'addField', 'page_props', 'pp_sortkey', 'patch-pp_sortkey.sql' ],
132  [ 'dropField', 'recentchanges', 'rc_cur_time', 'patch-drop-rc_cur_time.sql' ],
133  [ 'addIndex', 'watchlist', 'wl_user_notificationtimestamp',
134  'patch-watchlist-user-notificationtimestamp-index.sql' ],
135  [ 'addField', 'page', 'page_lang', 'patch-page-page_lang.sql' ],
136  [ 'addField', 'pagelinks', 'pl_from_namespace', 'patch-pl_from_namespace.sql' ],
137  [ 'addField', 'templatelinks', 'tl_from_namespace', 'patch-tl_from_namespace.sql' ],
138  [ 'addField', 'imagelinks', 'il_from_namespace', 'patch-il_from_namespace.sql' ],
139 
140  // 1.25
141  [ 'dropTable', 'hitcounter' ],
142  [ 'dropField', 'site_stats', 'ss_total_views', 'patch-drop-ss_total_views.sql' ],
143  [ 'dropField', 'page', 'page_counter', 'patch-drop-page_counter.sql' ],
144  [ 'modifyField', 'filearchive', 'fa_deleted_reason', 'patch-editsummary-length.sql' ],
145 
146  // 1.27
147  [ 'dropTable', 'msg_resource_links' ],
148  [ 'dropTable', 'msg_resource' ],
149  [ 'addTable', 'bot_passwords', 'patch-bot_passwords.sql' ],
150  [ 'addField', 'watchlist', 'wl_id', 'patch-watchlist-wl_id.sql' ],
151  [ 'dropIndex', 'categorylinks', 'cl_collation', 'patch-kill-cl_collation_index.sql' ],
152  [ 'addIndex', 'categorylinks', 'cl_collation_ext',
153  'patch-add-cl_collation_ext_index.sql' ],
154  [ 'doCollationUpdate' ],
155 
156  // 1.28
157  [ 'addIndex', 'recentchanges', 'rc_name_type_patrolled_timestamp',
158  'patch-add-rc_name_type_patrolled_timestamp_index.sql' ],
159  [ 'addField', 'change_tag', 'ct_id', 'patch-change_tag-ct_id.sql' ],
160  [ 'addField', 'tag_summary', 'ts_id', 'patch-tag_summary-ts_id.sql' ],
161 
162  // 1.29
163  [ 'addField', 'externallinks', 'el_index_60', 'patch-externallinks-el_index_60.sql' ],
164  [ 'addField', 'user_groups', 'ug_expiry', 'patch-user_groups-ug_expiry.sql' ],
165  [ 'addIndex', 'image', 'img_user_timestamp', 'patch-image-user-index-2.sql' ],
166 
167  // 1.30
168  [ 'modifyField', 'image', 'img_media_type', 'patch-add-3d.sql' ],
169  [ 'addTable', 'ip_changes', 'patch-ip_changes.sql' ],
170  [ 'renameIndex', 'categorylinks', 'cl_from', 'PRIMARY', false,
171  'patch-categorylinks-fix-pk.sql' ],
172  [ 'renameIndex', 'templatelinks', 'tl_from', 'PRIMARY', false,
173  'patch-templatelinks-fix-pk.sql' ],
174  [ 'renameIndex', 'pagelinks', 'pl_from', 'PRIMARY', false, 'patch-pagelinks-fix-pk.sql' ],
175  [ 'renameIndex', 'text', 'old_id', 'PRIMARY', false, 'patch-text-fix-pk.sql' ],
176  [ 'renameIndex', 'imagelinks', 'il_from', 'PRIMARY', false, 'patch-imagelinks-fix-pk.sql' ],
177  [ 'renameIndex', 'iwlinks', 'iwl_from', 'PRIMARY', false, 'patch-iwlinks-fix-pk.sql' ],
178  [ 'renameIndex', 'langlinks', 'll_from', 'PRIMARY', false, 'patch-langlinks-fix-pk.sql' ],
179  [ 'renameIndex', 'log_search', 'ls_field_val', 'PRIMARY', false, 'patch-log_search-fix-pk.sql' ],
180  [ 'renameIndex', 'module_deps', 'md_module_skin', 'PRIMARY', false,
181  'patch-module_deps-fix-pk.sql' ],
182  [ 'renameIndex', 'objectcache', 'keyname', 'PRIMARY', false, 'patch-objectcache-fix-pk.sql' ],
183  [ 'renameIndex', 'querycache_info', 'qci_type', 'PRIMARY', false,
184  'patch-querycache_info-fix-pk.sql' ],
185  [ 'renameIndex', 'site_stats', 'ss_row_id', 'PRIMARY', false, 'patch-site_stats-fix-pk.sql' ],
186  [ 'renameIndex', 'user_former_groups', 'ufg_user_group', 'PRIMARY', false,
187  'patch-user_former_groups-fix-pk.sql' ],
188  [ 'renameIndex', 'user_properties', 'user_properties_user_property', 'PRIMARY', false,
189  'patch-user_properties-fix-pk.sql' ],
190  [ 'addTable', 'comment', 'patch-comment-table.sql' ],
191  [ 'addTable', 'revision_comment_temp', 'patch-revision_comment_temp-table.sql' ],
192  // image_comment_temp is no longer needed when upgrading to MW 1.31 or newer,
193  // as it is dropped later in the update process as part of 'migrateImageCommentTemp'.
194  // File kept on disk and the updater entry here for historical purposes.
195  // [ 'addTable', 'image_comment_temp', 'patch-image_comment_temp-table.sql' ],
196  [ 'addField', 'archive', 'ar_comment_id', 'patch-archive-ar_comment_id.sql' ],
197  [ 'modifyField', 'image', 'img_description', 'patch-image-img_description-default.sql' ],
198  [ 'addField', 'ipblocks', 'ipb_reason_id', 'patch-ipblocks-ipb_reason_id.sql' ],
199  [ 'addField', 'logging', 'log_comment_id', 'patch-logging-log_comment_id.sql' ],
200  [ 'addField', 'oldimage', 'oi_description_id', 'patch-oldimage-oi_description_id.sql' ],
201  [ 'addField', 'protected_titles', 'pt_reason_id', 'patch-protected_titles-pt_reason_id.sql' ],
202  [ 'addField', 'recentchanges', 'rc_comment_id', 'patch-recentchanges-rc_comment_id.sql' ],
203  [ 'modifyField', 'revision', 'rev_comment', 'patch-revision-rev_comment-default.sql' ],
204 
205  // This field was added in 1.31, but is put here so it can be used by 'migrateComments'
206  [ 'addField', 'image', 'img_description_id', 'patch-image-img_description_id.sql' ],
207  [ 'addField', 'filearchive', 'fa_description_id', 'patch-filearchive-fa_description_id.sql' ],
208 
209  [ 'migrateComments' ],
210  [ 'renameIndex', 'l10n_cache', 'lc_lang_key', 'PRIMARY', false,
211  'patch-l10n_cache-primary-key.sql' ],
212 
213  // 1.31
214  [ 'addTable', 'content', 'patch-content.sql' ],
215  [ 'addTable', 'content_models', 'patch-content_models.sql' ],
216  [ 'addTable', 'slots', 'patch-slots.sql' ],
217  [ 'addField', 'slots', 'slot_origin', 'patch-slot-origin.sql' ],
218  [ 'addTable', 'slot_roles', 'patch-slot_roles.sql' ],
219  [ 'migrateArchiveText' ],
220  [ 'addTable', 'actor', 'patch-actor-table.sql' ],
221  [ 'addField', 'archive', 'ar_actor', 'patch-archive-ar_actor.sql' ],
222  [ 'addTable', 'revision_actor_temp', 'patch-revision_actor_temp-table.sql' ],
223  [ 'addField', 'ipblocks', 'ipb_by_actor', 'patch-ipblocks-ipb_by_actor.sql' ],
224  [ 'addField', 'image', 'img_actor', 'patch-image-img_actor.sql' ],
225  [ 'addField', 'oldimage', 'oi_actor', 'patch-oldimage-oi_actor.sql' ],
226  [ 'addField', 'filearchive', 'fa_actor', 'patch-filearchive-fa_actor.sql' ],
227  [ 'addField', 'recentchanges', 'rc_actor', 'patch-recentchanges-rc_actor.sql' ],
228  [ 'addField', 'logging', 'log_actor', 'patch-logging-log_actor.sql' ],
229  [ 'migrateActors' ],
230  [ 'modifyField', 'revision', 'rev_text_id', 'patch-rev_text_id-default.sql' ],
231  [ 'modifyTable', 'site_stats', 'patch-site_stats-modify.sql' ],
232  [ 'populateArchiveRevId' ],
233  [ 'addIndex', 'recentchanges', 'rc_namespace_title_timestamp',
234  'patch-recentchanges-nttindex.sql' ],
235 
236  // 1.32
237  [ 'addTable', 'change_tag_def', 'patch-change_tag_def.sql' ],
238  [ 'populateExternallinksIndex60' ],
239  [ 'modifyfield', 'externallinks', 'el_index_60',
240  'patch-externallinks-el_index_60-drop-default.sql' ],
241  [ 'runMaintenance', DeduplicateArchiveRevId::class, 'maintenance/deduplicateArchiveRevId.php' ],
242  [ 'addField', 'change_tag', 'ct_tag_id', 'patch-change_tag-tag_id.sql' ],
243  [ 'addIndex', 'archive', 'ar_revid_uniq', 'patch-archive-ar_rev_id-unique.sql' ],
244  [ 'populateContentTables' ],
245  [ 'addIndex', 'logging', 'log_type_action', 'patch-logging-log-type-action-index.sql' ],
246  [ 'dropIndex', 'logging', 'type_action', 'patch-logging-drop-type-action-index.sql' ],
247  [ 'renameIndex', 'interwiki', 'iw_prefix', 'PRIMARY', false, 'patch-interwiki-fix-pk.sql' ],
248  [ 'renameIndex', 'page_props', 'pp_page_propname', 'PRIMARY', false,
249  'patch-page_props-fix-pk.sql' ],
250  [ 'renameIndex', 'protected_titles', 'pt_namespace_title', 'PRIMARY', false,
251  'patch-protected_titles-fix-pk.sql' ],
252  [ 'renameIndex', 'site_identifiers', 'site_ids_type', 'PRIMARY', false,
253  'patch-site_identifiers-fix-pk.sql' ],
254  [ 'addIndex', 'recentchanges', 'rc_this_oldid', 'patch-recentchanges-rc_this_oldid-index.sql' ],
255  [ 'dropTable', 'transcache' ],
256  [ 'runMaintenance', PopulateChangeTagDef::class, 'maintenance/populateChangeTagDef.php' ],
257  [ 'addIndex', 'change_tag', 'change_tag_rc_tag_id',
258  'patch-change_tag-change_tag_rc_tag_id.sql' ],
259  [ 'addField', 'ipblocks', 'ipb_sitewide', 'patch-ipb_sitewide.sql' ],
260  [ 'addTable', 'ipblocks_restrictions', 'patch-ipblocks_restrictions-table.sql' ],
261  [ 'migrateImageCommentTemp' ],
262  ];
263  }
264 
265  protected function sqliteInitialIndexes() {
266  // initial-indexes.sql fails if the indexes are already present,
267  // so we perform a quick check if our database is newer.
268  if ( $this->updateRowExists( 'initial_indexes' ) ||
269  $this->db->indexExists( 'user', 'user_name', __METHOD__ )
270  ) {
271  $this->output( "...have initial indexes\n" );
272 
273  return;
274  }
275  $this->applyPatch( 'initial-indexes.sql', false, "Adding initial indexes" );
276  }
277 
278  protected function sqliteSetupSearchindex() {
279  $module = DatabaseSqlite::getFulltextSearchModule();
280  $fts3tTable = $this->updateRowExists( 'fts3' );
281  if ( $fts3tTable && !$module ) {
282  $this->applyPatch(
283  'searchindex-no-fts.sql',
284  false,
285  'PHP is missing FTS3 support, downgrading tables'
286  );
287  } elseif ( !$fts3tTable && $module == 'FTS3' ) {
288  $this->applyPatch( 'searchindex-fts3.sql', false, "Adding FTS3 search capabilities" );
289  } else {
290  $this->output( "...fulltext search table appears to be in order.\n" );
291  }
292  }
293 }
DatabaseUpdater\output
output( $str)
Output some text.
Definition: DatabaseUpdater.php:215
DatabaseUpdater\applyPatch
applyPatch( $path, $isFullPath=false, $msg=null)
Applies a SQL patch.
Definition: DatabaseUpdater.php:668
Wikimedia\Rdbms\DatabaseSqlite
Definition: DatabaseSqlite.php:37
DatabaseUpdater
Class for handling database updates.
Definition: DatabaseUpdater.php:36
SqliteUpdater\sqliteSetupSearchindex
sqliteSetupSearchindex()
Definition: SqliteUpdater.php:278
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
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
SqliteUpdater\sqliteInitialIndexes
sqliteInitialIndexes()
Definition: SqliteUpdater.php:265
DatabaseUpdater\updateRowExists
updateRowExists( $key)
Helper function: check if the given key is present in the updatelog table.
Definition: DatabaseUpdater.php:505
SqliteUpdater\getCoreUpdateList
getCoreUpdateList()
Get an array of updates to perform on the database.
Definition: SqliteUpdater.php:34
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
SqliteUpdater
Class for handling updates to Sqlite databases.
Definition: SqliteUpdater.php:32