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