MediaWiki REL1_31
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', 'change_tag', 'change_tag_rc_tag', 'patch-change_tag-indexes.sql' ],
58 [ 'addField', 'redirect', 'rd_interwiki', 'patch-rd_interwiki.sql' ],
59 [ 'doUpdateTranscacheField' ],
60 [ 'sqliteSetupSearchindex' ],
61
62 // 1.17
63 [ 'addTable', 'iwlinks', 'patch-iwlinks.sql' ],
64 [ 'addIndex', 'iwlinks', 'iwl_prefix_title_from', 'patch-rename-iwl_prefix.sql' ],
65 [ 'addField', 'updatelog', 'ul_value', 'patch-ul_value.sql' ],
66 [ 'addField', 'interwiki', 'iw_api', 'patch-iw_api_and_wikiid.sql' ],
67 [ 'dropIndex', 'iwlinks', 'iwl_prefix', 'patch-kill-iwl_prefix.sql' ],
68 [ 'addField', 'categorylinks', 'cl_collation', 'patch-categorylinks-better-collation.sql' ],
69 [ 'addTable', 'module_deps', 'patch-module_deps.sql' ],
70 [ 'dropIndex', 'archive', 'ar_page_revid', 'patch-archive_kill_ar_page_revid.sql' ],
71 [ 'addIndex', 'archive', 'ar_revid', '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 [ 'addIndex', 'logging', 'type_action', 'patch-logging-type-action-index.sql' ],
80 [ 'doMigrateUserOptions' ],
81 [ 'dropField', 'user', 'user_options', 'patch-drop-user_options.sql' ],
82 [ 'addField', 'revision', 'rev_sha1', 'patch-rev_sha1.sql' ],
83 [ 'addField', 'archive', 'ar_sha1', 'patch-ar_sha1.sql' ],
84 [ 'addIndex', 'page', 'page_redirect_namespace_len',
85 'patch-page_redirect_namespace_len.sql' ],
86 [ 'addField', 'uploadstash', 'us_chunk_inx', 'patch-uploadstash_chunk.sql' ],
87 [ 'addfield', 'job', 'job_timestamp', 'patch-jobs-add-timestamp.sql' ],
88
89 // 1.20
90 [ 'addIndex', 'revision', 'page_user_timestamp', 'patch-revision-user-page-index.sql' ],
91 [ 'addField', 'ipblocks', 'ipb_parent_block_id', 'patch-ipb-parent-block-id.sql' ],
92 [ 'addIndex', 'ipblocks', 'ipb_parent_block_id', 'patch-ipb-parent-block-id-index.sql' ],
93 [ 'dropField', 'category', 'cat_hidden', 'patch-cat_hidden.sql' ],
94
95 // 1.21
96 [ 'addField', 'revision', 'rev_content_format', 'patch-revision-rev_content_format.sql' ],
97 [ 'addField', 'revision', 'rev_content_model', 'patch-revision-rev_content_model.sql' ],
98 [ 'addField', 'archive', 'ar_content_format', 'patch-archive-ar_content_format.sql' ],
99 [ 'addField', 'archive', 'ar_content_model', 'patch-archive-ar_content_model.sql' ],
100 [ 'addField', 'page', 'page_content_model', 'patch-page-page_content_model.sql' ],
101 [ 'enableContentHandlerUseDB' ],
102
103 [ 'dropField', 'site_stats', 'ss_admins', 'patch-drop-ss_admins.sql' ],
104 [ 'dropField', 'recentchanges', 'rc_moved_to_title', 'patch-rc_moved.sql' ],
105 [ 'addTable', 'sites', 'patch-sites.sql' ],
106 [ 'addField', 'filearchive', 'fa_sha1', 'patch-fa_sha1.sql' ],
107 [ 'addField', 'job', 'job_token', 'patch-job_token.sql' ],
108 [ 'addField', 'job', 'job_attempts', 'patch-job_attempts.sql' ],
109 [ 'doEnableProfiling' ],
110 [ 'addField', 'uploadstash', 'us_props', 'patch-uploadstash-us_props.sql' ],
111 [ 'modifyField', 'user_groups', 'ug_group', 'patch-ug_group-length-increase-255.sql' ],
112 [ 'modifyField', 'user_former_groups', 'ufg_group',
113 'patch-ufg_group-length-increase-255.sql' ],
114 [ 'addIndex', 'page_props', 'pp_propname_page',
115 'patch-page_props-propname-page-index.sql' ],
116 [ 'addIndex', 'image', 'img_media_mime', 'patch-img_media_mime-index.sql' ],
117
118 // 1.22
119 [ 'addIndex', 'iwlinks', 'iwl_prefix_from_title', 'patch-iwlinks-from-title-index.sql' ],
120 [ 'addField', 'archive', 'ar_id', 'patch-archive-ar_id.sql' ],
121 [ 'addField', 'externallinks', 'el_id', 'patch-externallinks-el_id.sql' ],
122
123 // 1.23
124 [ 'addField', 'recentchanges', 'rc_source', 'patch-rc_source.sql' ],
125 [ 'addIndex', 'logging', 'log_user_text_type_time',
126 'patch-logging_user_text_type_time_index.sql' ],
127 [ 'addIndex', 'logging', 'log_user_text_time', 'patch-logging_user_text_time_index.sql' ],
128 [ 'addField', 'page', 'page_links_updated', 'patch-page_links_updated.sql' ],
129 [ 'addField', 'user', 'user_password_expires', 'patch-user_password_expire.sql' ],
130
131 // 1.24
132 [ 'addField', 'page_props', 'pp_sortkey', 'patch-pp_sortkey.sql' ],
133 [ 'dropField', 'recentchanges', 'rc_cur_time', 'patch-drop-rc_cur_time.sql' ],
134 [ 'addIndex', 'watchlist', 'wl_user_notificationtimestamp',
135 'patch-watchlist-user-notificationtimestamp-index.sql' ],
136 [ 'addField', 'page', 'page_lang', 'patch-page-page_lang.sql' ],
137 [ 'addField', 'pagelinks', 'pl_from_namespace', 'patch-pl_from_namespace.sql' ],
138 [ 'addField', 'templatelinks', 'tl_from_namespace', 'patch-tl_from_namespace.sql' ],
139 [ 'addField', 'imagelinks', 'il_from_namespace', 'patch-il_from_namespace.sql' ],
140
141 // 1.25
142 [ 'dropTable', 'hitcounter' ],
143 [ 'dropField', 'site_stats', 'ss_total_views', 'patch-drop-ss_total_views.sql' ],
144 [ 'dropField', 'page', 'page_counter', 'patch-drop-page_counter.sql' ],
145 [ 'modifyField', 'filearchive', 'fa_deleted_reason', 'patch-editsummary-length.sql' ],
146
147 // 1.27
148 [ 'dropTable', 'msg_resource_links' ],
149 [ 'dropTable', 'msg_resource' ],
150 [ 'addTable', 'bot_passwords', 'patch-bot_passwords.sql' ],
151 [ 'addField', 'watchlist', 'wl_id', 'patch-watchlist-wl_id.sql' ],
152 [ 'dropIndex', 'categorylinks', 'cl_collation', 'patch-kill-cl_collation_index.sql' ],
153 [ 'addIndex', 'categorylinks', 'cl_collation_ext',
154 'patch-add-cl_collation_ext_index.sql' ],
155 [ 'doCollationUpdate' ],
156
157 // 1.28
158 [ 'addIndex', 'recentchanges', 'rc_name_type_patrolled_timestamp',
159 'patch-add-rc_name_type_patrolled_timestamp_index.sql' ],
160 [ 'addField', 'change_tag', 'ct_id', 'patch-change_tag-ct_id.sql' ],
161 [ 'addField', 'tag_summary', 'ts_id', 'patch-tag_summary-ts_id.sql' ],
162
163 // 1.29
164 [ 'addField', 'externallinks', 'el_index_60', 'patch-externallinks-el_index_60.sql' ],
165 [ 'addField', 'user_groups', 'ug_expiry', 'patch-user_groups-ug_expiry.sql' ],
166 [ 'addIndex', 'image', 'img_user_timestamp', 'patch-image-user-index-2.sql' ],
167
168 // 1.30
169 [ 'modifyField', 'image', 'img_media_type', 'patch-add-3d.sql' ],
170 [ 'addTable', 'ip_changes', 'patch-ip_changes.sql' ],
171 [ 'renameIndex', 'categorylinks', 'cl_from', 'PRIMARY', false,
172 'patch-categorylinks-fix-pk.sql' ],
173 [ 'renameIndex', 'templatelinks', 'tl_from', 'PRIMARY', false,
174 'patch-templatelinks-fix-pk.sql' ],
175 [ 'renameIndex', 'pagelinks', 'pl_from', 'PRIMARY', false, 'patch-pagelinks-fix-pk.sql' ],
176 [ 'renameIndex', 'text', 'old_id', 'PRIMARY', false, 'patch-text-fix-pk.sql' ],
177 [ 'renameIndex', 'imagelinks', 'il_from', 'PRIMARY', false, 'patch-imagelinks-fix-pk.sql' ],
178 [ 'renameIndex', 'iwlinks', 'iwl_from', 'PRIMARY', false, 'patch-iwlinks-fix-pk.sql' ],
179 [ 'renameIndex', 'langlinks', 'll_from', 'PRIMARY', false, 'patch-langlinks-fix-pk.sql' ],
180 [ 'renameIndex', 'log_search', 'ls_field_val', 'PRIMARY', false, 'patch-log_search-fix-pk.sql' ],
181 [ 'renameIndex', 'module_deps', 'md_module_skin', 'PRIMARY', false,
182 'patch-module_deps-fix-pk.sql' ],
183 [ 'renameIndex', 'objectcache', 'keyname', 'PRIMARY', false, 'patch-objectcache-fix-pk.sql' ],
184 [ 'renameIndex', 'querycache_info', 'qci_type', 'PRIMARY', false,
185 'patch-querycache_info-fix-pk.sql' ],
186 [ 'renameIndex', 'site_stats', 'ss_row_id', 'PRIMARY', false, 'patch-site_stats-fix-pk.sql' ],
187 [ 'renameIndex', 'transcache', 'tc_url_idx', 'PRIMARY', false, 'patch-transcache-fix-pk.sql' ],
188 [ 'renameIndex', 'user_former_groups', 'ufg_user_group', 'PRIMARY', false,
189 'patch-user_former_groups-fix-pk.sql' ],
190 [ 'renameIndex', 'user_properties', 'user_properties_user_property', 'PRIMARY', false,
191 'patch-user_properties-fix-pk.sql' ],
192 [ 'addTable', 'comment', 'patch-comment-table.sql' ],
193 [ 'addTable', 'revision_comment_temp', 'patch-revision_comment_temp-table.sql' ],
194 [ 'addTable', 'image_comment_temp', 'patch-image_comment_temp-table.sql' ],
195 [ 'addField', 'archive', 'ar_comment_id', 'patch-archive-ar_comment_id.sql' ],
196 [ 'modifyField', 'image', 'img_description', 'patch-image-img_description-default.sql' ],
197 [ 'addField', 'ipblocks', 'ipb_reason_id', 'patch-ipblocks-ipb_reason_id.sql' ],
198 [ 'addField', 'logging', 'log_comment_id', 'patch-logging-log_comment_id.sql' ],
199 [ 'addField', 'oldimage', 'oi_description_id', 'patch-oldimage-oi_description_id.sql' ],
200 [ 'addField', 'protected_titles', 'pt_reason_id', 'patch-protected_titles-pt_reason_id.sql' ],
201 [ 'addField', 'recentchanges', 'rc_comment_id', 'patch-recentchanges-rc_comment_id.sql' ],
202 [ 'modifyField', 'revision', 'rev_comment', 'patch-revision-rev_comment-default.sql' ],
203
204 // This field was added in 1.31, but is put here so it can be used by 'migrateComments'
205 [ 'addField', 'image', 'img_description_id', 'patch-image-img_description_id.sql' ],
206 [ 'addField', 'filearchive', 'fa_description_id', 'patch-filearchive-fa_description_id.sql' ],
207
208 [ 'migrateComments' ],
209 [ 'renameIndex', 'l10n_cache', 'lc_lang_key', 'PRIMARY', false,
210 'patch-l10n_cache-primary-key.sql' ],
211
212 // 1.31
213 [ 'addTable', 'content', 'patch-content.sql' ],
214 [ 'addTable', 'content_models', 'patch-content_models.sql' ],
215 [ 'addTable', 'slots', 'patch-slots.sql' ],
216 [ 'addField', 'slots', 'slot_origin', 'patch-slot-origin.sql' ],
217 [ 'addTable', 'slot_roles', 'patch-slot_roles.sql' ],
218 [ 'migrateArchiveText' ],
219 [ 'addTable', 'actor', 'patch-actor-table.sql' ],
220 [ 'addField', 'archive', 'ar_actor', 'patch-archive-ar_actor.sql' ],
221 [ 'addTable', 'revision_actor_temp', 'patch-revision_actor_temp-table.sql' ],
222 [ 'addField', 'ipblocks', 'ipb_by_actor', 'patch-ipblocks-ipb_by_actor.sql' ],
223 [ 'addField', 'image', 'img_actor', 'patch-image-img_actor.sql' ],
224 [ 'addField', 'oldimage', 'oi_actor', 'patch-oldimage-oi_actor.sql' ],
225 [ 'addField', 'filearchive', 'fa_actor', 'patch-filearchive-fa_actor.sql' ],
226 [ 'addField', 'recentchanges', 'rc_actor', 'patch-recentchanges-rc_actor.sql' ],
227 [ 'addField', 'logging', 'log_actor', 'patch-logging-log_actor.sql' ],
228 [ 'migrateActors' ],
229 [ 'modifyField', 'revision', 'rev_text_id', 'patch-rev_text_id-default.sql' ],
230 [ 'modifyTable', 'site_stats', 'patch-site_stats-modify.sql' ],
231 [ 'populateArchiveRevId' ],
232 [ 'addIndex', 'recentchanges', 'rc_namespace_title_timestamp',
233 'patch-recentchanges-nttindex.sql' ],
234 ];
235 }
236
237 protected function sqliteInitialIndexes() {
238 // initial-indexes.sql fails if the indexes are already present,
239 // so we perform a quick check if our database is newer.
240 if ( $this->updateRowExists( 'initial_indexes' ) ||
241 $this->db->indexExists( 'user', 'user_name', __METHOD__ )
242 ) {
243 $this->output( "...have initial indexes\n" );
244
245 return;
246 }
247 $this->applyPatch( 'initial-indexes.sql', false, "Adding initial indexes" );
248 }
249
250 protected function sqliteSetupSearchindex() {
251 $module = DatabaseSqlite::getFulltextSearchModule();
252 $fts3tTable = $this->updateRowExists( 'fts3' );
253 if ( $fts3tTable && !$module ) {
254 $this->applyPatch(
255 'searchindex-no-fts.sql',
256 false,
257 'PHP is missing FTS3 support, downgrading tables'
258 );
259 } elseif ( !$fts3tTable && $module == 'FTS3' ) {
260 $this->applyPatch( 'searchindex-fts3.sql', false, "Adding FTS3 search capabilities" );
261 } else {
262 $this->output( "...fulltext search table appears to be in order.\n" );
263 }
264 }
265}
Class for handling database updates.
updateRowExists( $key)
Helper function: check if the given key is present in the updatelog table.
applyPatch( $path, $isFullPath=false, $msg=null)
Applies a SQL patch.
Class for handling updates to Sqlite databases.
getCoreUpdateList()
Get an array of updates to perform on the database.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling output() to send it all. It could be easily changed to send incrementally if that becomes useful