]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blob - includes/installer/SqliteUpdater.php
MediaWiki 1.17.0
[autoinstalls/mediawiki.git] / includes / installer / SqliteUpdater.php
1 <?php
2 /**
3  * Sqlite-specific updater.
4  *
5  * @file
6  * @ingroup Deployment
7  */
8
9 /**
10  * Class for handling updates to Sqlite databases.
11  *
12  * @ingroup Deployment
13  * @since 1.17
14  */
15 class SqliteUpdater extends DatabaseUpdater {
16
17         protected function getCoreUpdateList() {
18                 return array(
19                         // 1.14
20                         array( 'addField', 'site_stats',    'ss_active_users',  'patch-ss_active_users.sql' ),
21                         array( 'doActiveUsersInit' ),
22                         array( 'addField', 'ipblocks',      'ipb_allow_usertalk', 'patch-ipb_allow_usertalk.sql' ),
23                         array( 'sqliteInitialIndexes' ),
24
25                         // 1.15
26                         array( 'addTable', 'change_tag',                        'patch-change_tag.sql' ),
27                         array( 'addTable', 'tag_summary',                       'patch-change_tag.sql' ),
28                         array( 'addTable', 'valid_tag',                         'patch-change_tag.sql' ),
29
30                         // 1.16
31                         array( 'addTable', 'user_properties',                   'patch-user_properties.sql' ),
32                         array( 'addTable', 'log_search',                        'patch-log_search.sql' ),
33                         array( 'addField', 'logging',       'log_user_text',    'patch-log_user_text.sql' ),
34                         array( 'doLogUsertextPopulation' ), # listed separately from the previous update because 1.16 was released without this update
35                         array( 'doLogSearchPopulation' ),
36                         array( 'addTable', 'l10n_cache',                        'patch-l10n_cache.sql' ),
37                         array( 'addTable', 'external_user',                     'patch-external_user.sql' ),
38                         array( 'addIndex', 'log_search',    'ls_field_val',     'patch-log_search-rename-index.sql' ),
39                         array( 'addIndex', 'change_tag',    'change_tag_rc_tag', 'patch-change_tag-indexes.sql' ),
40                         array( 'addField', 'redirect',      'rd_interwiki',     'patch-rd_interwiki.sql' ),
41                         array( 'doUpdateTranscacheField' ),
42                         array( 'sqliteSetupSearchindex' ),
43
44                         // 1.17
45                         array( 'addTable', 'iwlinks',                            'patch-iwlinks.sql' ),
46                         array( 'addIndex', 'iwlinks',   'iwl_prefix_title_from', 'patch-rename-iwl_prefix.sql' ),
47                         array( 'addField', 'updatelog', 'ul_value',              'patch-ul_value.sql' ),
48                         array( 'addField', 'interwiki',     'iw_api',           'patch-iw_api_and_wikiid.sql' ),
49                         array( 'dropIndex', 'iwlinks', 'iwl_prefix',  'patch-kill-iwl_prefix.sql' ),
50                         array( 'dropIndex', 'iwlinks', 'iwl_prefix_from_title', 'patch-kill-iwl_pft.sql' ),
51                         array( 'addField', 'categorylinks', 'cl_collation', 'patch-categorylinks-better-collation.sql' ),
52                         array( 'doCollationUpdate' ),
53                         array( 'addTable', 'msg_resource',                      'patch-msg_resource.sql' ),
54                         array( 'addTable', 'module_deps',                       'patch-module_deps.sql' ),
55                 );
56         }
57
58         protected function sqliteInitialIndexes() {
59                 // initial-indexes.sql fails if the indexes are already present, so we perform a quick check if our database is newer.
60                 if ( $this->updateRowExists( 'initial_indexes' ) || $this->db->indexExists( 'user', 'user_name' ) ) {
61                         $this->output( "...have initial indexes\n" );
62                         return;
63                 }
64                 $this->output( "Adding initial indexes..." );
65                 $this->applyPatch( 'initial-indexes.sql' );
66                 $this->output( "done\n" );
67         }
68
69         protected function sqliteSetupSearchindex() {
70                 $module = DatabaseSqlite::getFulltextSearchModule();
71                 $fts3tTable = $this->updateRowExists( 'fts3' );
72                 if ( $fts3tTable &&  !$module ) {
73                         $this->output( '...PHP is missing FTS3 support, downgrading tables...' );
74                         $this->applyPatch( 'searchindex-no-fts.sql' );
75                         $this->output( "done\n" );
76                 } elseif ( !$fts3tTable && $module == 'FTS3' ) {
77                         $this->output( '...adding FTS3 search capabilities...' );
78                         $this->applyPatch( 'searchindex-fts3.sql' );
79                         $this->output( "done\n" );
80                 } else {
81                         $this->output( "...fulltext search table appears to be in order.\n" );
82                 }
83         }
84 }