MediaWiki  REL1_31
MssqlUpdater.php
Go to the documentation of this file.
1 <?php
25 
34 
38  protected $db;
39 
40  protected function getCoreUpdateList() {
41  return [
42  // 1.23
43  [ 'addField', 'mwuser', 'user_password_expires', 'patch-user_password_expires.sql' ],
44 
45  // 1.24
46  [ 'addField', 'page', 'page_lang', 'patch-page_page_lang.sql' ],
47 
48  // 1.25
49  [ 'dropTable', 'hitcounter' ],
50  [ 'dropField', 'site_stats', 'ss_total_views', 'patch-drop-ss_total_views.sql' ],
51  [ 'dropField', 'page', 'page_counter', 'patch-drop-page_counter.sql' ],
52  // scripts were updated in 1.27 due to SQL errors; retaining old updatekeys so that people
53  // updating from 1.23->1.25->1.27 do not execute these scripts twice even though the
54  // updatekeys no longer make sense as they are.
55  [ 'updateSchema', 'categorylinks', 'cl_type-category_types-ck',
56  'patch-categorylinks-constraints.sql' ],
57  [ 'updateSchema', 'filearchive', 'fa_major_mime-major_mime-ck',
58  'patch-filearchive-constraints.sql' ],
59  [ 'updateSchema', 'oldimage', 'oi_major_mime-major_mime-ck',
60  'patch-oldimage-constraints.sql' ],
61  [ 'updateSchema', 'image', 'img_major_mime-major_mime-ck', 'patch-image-constraints.sql' ],
62  [ 'updateSchema', 'uploadstash', 'us_media_type-media_type-ck',
63  'patch-uploadstash-constraints.sql' ],
64 
65  [ 'modifyField', 'image', 'img_major_mime',
66  'patch-img_major_mime-chemical.sql' ],
67  [ 'modifyField', 'oldimage', 'oi_major_mime',
68  'patch-oi_major_mime-chemical.sql' ],
69  [ 'modifyField', 'filearchive', 'fa_major_mime',
70  'patch-fa_major_mime-chemical.sql' ],
71 
72  // 1.27
73  [ 'dropTable', 'msg_resource_links' ],
74  [ 'dropTable', 'msg_resource' ],
75  [ 'addField', 'watchlist', 'wl_id', 'patch-watchlist-wl_id.sql' ],
76  [ 'dropField', 'mwuser', 'user_options', 'patch-drop-user_options.sql' ],
77  [ 'addTable', 'bot_passwords', 'patch-bot_passwords.sql' ],
78  [ 'addField', 'pagelinks', 'pl_from_namespace', 'patch-pl_from_namespace.sql' ],
79  [ 'addField', 'templatelinks', 'tl_from_namespace', 'patch-tl_from_namespace.sql' ],
80  [ 'addField', 'imagelinks', 'il_from_namespace', 'patch-il_from_namespace.sql' ],
81  [ 'dropIndex', 'categorylinks', 'cl_collation', 'patch-kill-cl_collation_index.sql' ],
82  [ 'addIndex', 'categorylinks', 'cl_collation_ext',
83  'patch-add-cl_collation_ext_index.sql' ],
84  [ 'dropField', 'recentchanges', 'rc_cur_time', 'patch-drop-rc_cur_time.sql' ],
85  [ 'addField', 'page_props', 'pp_sortkey', 'patch-pp_sortkey.sql' ],
86  [ 'updateSchema', 'oldimage', 'oldimage varchar', 'patch-oldimage-schema.sql' ],
87  [ 'updateSchema', 'filearchive', 'filearchive varchar', 'patch-filearchive-schema.sql' ],
88  [ 'updateSchema', 'image', 'image varchar', 'patch-image-schema.sql' ],
89  [ 'updateSchema', 'recentchanges', 'recentchanges-drop-fks',
90  'patch-recentchanges-drop-fks.sql' ],
91  [ 'updateSchema', 'logging', 'logging-drop-fks', 'patch-logging-drop-fks.sql' ],
92  [ 'updateSchema', 'archive', 'archive-drop-fks', 'patch-archive-drop-fks.sql' ],
93 
94  // 1.28
95  [ 'addIndex', 'recentchanges', 'rc_name_type_patrolled_timestamp',
96  'patch-add-rc_name_type_patrolled_timestamp_index.sql' ],
97  [ 'addField', 'change_tag', 'ct_id', 'patch-change_tag-ct_id.sql' ],
98  [ 'addField', 'tag_summary', 'ts_id', 'patch-tag_summary-ts_id.sql' ],
99 
100  // 1.29
101  [ 'addField', 'externallinks', 'el_index_60', 'patch-externallinks-el_index_60.sql' ],
102  [ 'dropIndex', 'oldimage', 'oi_name_archive_name',
103  'patch-alter-table-oldimage.sql' ],
104 
105  // 1.30
106  [ 'modifyField', 'image', 'img_media_type', 'patch-add-3d.sql' ],
107  [ 'addIndex', 'site_stats', 'PRIMARY', 'patch-site_stats-pk.sql' ],
108 
109  // Should have been in 1.30
110  [ 'addTable', 'comment', 'patch-comment-table.sql' ],
111  // This field was added in 1.31, but is put here so it can be used by 'migrateComments'
112  [ 'addField', 'image', 'img_description_id', 'patch-image-img_description_id.sql' ],
113  // Should have been in 1.30
114  [ 'migrateComments' ],
115 
116  // 1.31
117  [ 'addTable', 'slots', 'patch-slots.sql' ],
118  [ 'addField', 'slots', 'slot_origin', 'patch-slot-origin.sql' ],
119  [ 'addTable', 'content', 'patch-content.sql' ],
120  [ 'addTable', 'slot_roles', 'patch-slot_roles.sql' ],
121  [ 'addTable', 'content_models', 'patch-content_models.sql' ],
122  [ 'migrateArchiveText' ],
123  [ 'addTable', 'actor', 'patch-actor-table.sql' ],
124  [ 'migrateActors' ],
125  [ 'modifyField', 'revision', 'rev_text_id', 'patch-rev_text_id-default.sql' ],
126  [ 'modifyTable', 'site_stats', 'patch-site_stats-modify.sql' ],
127  [ 'populateArchiveRevId' ],
128  [ 'modifyField', 'recentchanges', 'rc_patrolled', 'patch-rc_patrolled_type.sql' ],
129  [ 'addIndex', 'recentchanges', 'rc_namespace_title_timestamp',
130  'patch-recentchanges-nttindex.sql' ],
131  ];
132  }
133 
134  protected function applyPatch( $path, $isFullPath = false, $msg = null ) {
135  $prevScroll = $this->db->scrollableCursor( false );
136  $prevPrep = $this->db->prepareStatements( false );
137  parent::applyPatch( $path, $isFullPath, $msg );
138  $this->db->scrollableCursor( $prevScroll );
139  $this->db->prepareStatements( $prevPrep );
140  }
141 
154  protected function updateSchema( $table, $updatekey, $patch, $fullpath = false ) {
155  if ( !$this->db->tableExists( $table, __METHOD__ ) ) {
156  $this->output( "...$table table does not exist, skipping schema update patch.\n" );
157  } elseif ( $this->updateRowExists( $updatekey ) ) {
158  $this->output( "...$table already had schema updated by $patch.\n" );
159  } else {
160  $apply = $this->applyPatch( $patch, $fullpath, "Updating schema of table $table" );
161  if ( $apply ) {
162  $this->insertUpdateRow( $updatekey );
163  }
164  return $apply;
165  }
166 
167  return true;
168  }
169 }
DatabaseUpdater\output
output( $str)
Output some text.
Definition: DatabaseUpdater.php:212
MssqlUpdater\$db
DatabaseMssql $db
Definition: MssqlUpdater.php:38
MssqlUpdater
Class for setting up the MediaWiki database using Microsoft SQL Server.
Definition: MssqlUpdater.php:33
use
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
Definition: APACHE-LICENSE-2.0.txt:10
DatabaseUpdater
Class for handling database updates.
Definition: DatabaseUpdater.php:36
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:37
DatabaseUpdater\updateRowExists
updateRowExists( $key)
Helper function: check if the given key is present in the updatelog table.
Definition: DatabaseUpdater.php:502
$path
$path
Definition: NoLocalSettings.php:25
Wikimedia\Rdbms\DatabaseMssql
Definition: DatabaseMssql.php:37
MssqlUpdater\updateSchema
updateSchema( $table, $updatekey, $patch, $fullpath=false)
General schema update for a table that touches more than one field or requires destructive actions (s...
Definition: MssqlUpdater.php:154
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:521
MssqlUpdater\getCoreUpdateList
getCoreUpdateList()
Get an array of updates to perform on the database.
Definition: MssqlUpdater.php:40
MssqlUpdater\applyPatch
applyPatch( $path, $isFullPath=false, $msg=null)
Applies a SQL patch.
Definition: MssqlUpdater.php:134