MediaWiki REL1_30
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 [ 'migrateComments' ],
194 [ 'renameIndex', 'l10n_cache', 'lc_lang_key', 'PRIMARY', false,
195 'patch-l10n_cache-primary-key.sql' ],
196 ];
197 }
198
199 protected function sqliteInitialIndexes() {
200 // initial-indexes.sql fails if the indexes are already present,
201 // so we perform a quick check if our database is newer.
202 if ( $this->updateRowExists( 'initial_indexes' ) ||
203 $this->db->indexExists( 'user', 'user_name', __METHOD__ )
204 ) {
205 $this->output( "...have initial indexes\n" );
206
207 return;
208 }
209 $this->applyPatch( 'initial-indexes.sql', false, "Adding initial indexes" );
210 }
211
212 protected function sqliteSetupSearchindex() {
213 $module = DatabaseSqlite::getFulltextSearchModule();
214 $fts3tTable = $this->updateRowExists( 'fts3' );
215 if ( $fts3tTable && !$module ) {
216 $this->applyPatch(
217 'searchindex-no-fts.sql',
218 false,
219 'PHP is missing FTS3 support, downgrading tables'
220 );
221 } elseif ( !$fts3tTable && $module == 'FTS3' ) {
222 $this->applyPatch( 'searchindex-fts3.sql', false, "Adding FTS3 search capabilities" );
223 } else {
224 $this->output( "...fulltext search table appears to be in order.\n" );
225 }
226 }
227}
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