4 * @subpackage Maintenance
8 function do_revision_updates() {
9 global $wgSoftwareRevision;
10 if ( $wgSoftwareRevision < 1001 ) {
15 function update_passwords() {
17 $fname = "Update script: update_passwords()";
18 print "\nIt appears that you need to update the user passwords in your\n" .
19 "database. If you have already done this (if you've run this update\n" .
20 "script once before, for example), doing so again will make all your\n" .
21 "user accounts inaccessible, so be sure you only do this once.\n" .
22 "Update user passwords? (yes/no)";
24 $resp = readconsole();
25 if ( ! ( "Y" == $resp{0} || "y" == $resp{0} ) ) { return; }
27 $sql = "SELECT user_id,user_password FROM user";
28 $source = $wgDatabase->query( $sql, $fname );
30 while ( $row = $wgDatabase->fetchObject( $source ) ) {
32 $oldpass = $row->user_password;
33 $newpass = md5( "{$id}-{$oldpass}" );
35 $sql = "UPDATE user SET user_password='{$newpass}' " .
36 "WHERE user_id={$id}";
37 $wgDatabase->query( $sql, $fname );
41 function do_ipblocks_update() {
46 if ( !$wgDatabase->fieldExists( "ipblocks", "ipb_id" ) ) {
49 if ( !$wgDatabase->fieldExists( "ipblocks", "ipb_expiry" ) ) {
54 echo "Updating ipblocks table... ";
56 dbsource( "maintenance/archives/patch-ipblocks.sql", $wgDatabase );
59 dbsource( "maintenance/archives/patch-ipb_expiry.sql", $wgDatabase );
63 echo "...ipblocks is up to date.\n";
69 function do_interwiki_update() {
70 # Check that interwiki table exists; if it doesn't source it
72 if( $wgDatabase->tableExists( "interwiki" ) ) {
73 echo "...already have interwiki table\n";
76 echo "Creating interwiki table: ";
77 dbsource( "maintenance/archives/patch-interwiki.sql" );
79 echo "Adding default interwiki definitions: ";
80 dbsource( "maintenance/interwiki.sql" );
84 function do_index_update() {
85 # Check that proper indexes are in place
87 $meta = $wgDatabase->fieldInfo( "recentchanges", "rc_timestamp" );
88 if( $meta->multiple_key == 0 ) {
89 echo "Updating indexes to 20031107: ";
90 dbsource( "maintenance/archives/patch-indexes.sql" );
94 echo "...indexes seem up to 20031107 standards\n";
98 function do_linkscc_update() {
99 // Create linkscc if necessary
101 if( $wgDatabase->tableExists( "linkscc" ) ) {
102 echo "...have linkscc table.\n";
104 echo "Adding linkscc table... ";
105 dbsource( "maintenance/archives/patch-linkscc.sql", $wgDatabase );
110 function do_linkscc_1_3_update() {
111 // Update linkscc table to 1.3 schema if necessary
112 global $wgDatabase, $wgVersion;
113 if( ( strpos( "1.3", $wgVersion ) === 0 ) && $wgDatabase->tableExists( "linkscc" )
114 && $wgDatabase->fieldExists( "linkscc", "lcc_title" ) ) {
115 echo "Altering lcc_title field from linkscc table... ";
116 dbsource( "maintenance/archives/patch-linkscc-1.3.sql", $wgDatabase );
119 echo "...linkscc is up to date, or does not exist. Good.\n";
123 function do_hitcounter_update() {
124 // Create hitcounter if necessary
126 if( $wgDatabase->tableExists( "hitcounter" ) ) {
127 echo "...have hitcounter table.\n";
129 echo "Adding hitcounter table... ";
130 dbsource( "maintenance/archives/patch-hitcounter.sql", $wgDatabase );
135 function do_recentchanges_update() {
137 if ( !$wgDatabase->fieldExists( "recentchanges", "rc_type" ) ) {
138 echo "Adding rc_type, rc_moved_to_ns, rc_moved_to_title...";
139 dbsource( "maintenance/archives/patch-rc_type.sql" , $wgDatabase );
142 if ( !$wgDatabase->fieldExists( "recentchanges", "rc_ip" ) ) {
143 echo "Adding rc_ip...";
144 dbsource( "maintenance/archives/patch-rc_ip.sql", $wgDatabase );
147 if ( !$wgDatabase->fieldExists( "recentchanges", "rc_id" ) ) {
148 echo "Adding rc_id...";
149 dbsource( "maintenance/archives/patch-rc_id.sql", $wgDatabase );
152 if ( !$wgDatabase->fieldExists( "recentchanges", "rc_patrolled" ) ) {
153 echo "Adding rc_patrolled...";
154 dbsource( "maintenance/archives/patch-rc-patrol.sql", $wgDatabase );
159 function do_user_real_name_update() {
161 if ( $wgDatabase->fieldExists( "user", "user_real_name" ) ) {
162 echo "...have user_real_name field in user table.\n";
164 echo "Adding user_real_name field to table user...";
165 dbsource( "maintenance/archives/patch-user-realname.sql" , $wgDatabase );
170 function do_querycache_update() {
172 if( $wgDatabase->tableExists( "querycache" ) ) {
173 echo "...have special page querycache table.\n";
175 echo "Adding querycache table for slow special pages... ";
176 dbsource( "maintenance/archives/patch-querycache.sql", $wgDatabase );
181 function do_objectcache_update() {
183 if( $wgDatabase->tableExists( "objectcache" ) ) {
184 echo "...have objectcache table.\n";
186 echo "Adding objectcache table for message caching... ";
187 dbsource( "maintenance/archives/patch-objectcache.sql", $wgDatabase );
192 function do_categorylinks_update() {
194 if( $wgDatabase->tableExists( "categorylinks" ) ) {
195 echo "...have categorylinks table.\n";
197 echo "Adding categorylinks table for category management... ";
198 dbsource( "maintenance/archives/patch-categorylinks.sql", $wgDatabase );
203 function do_image_name_unique_update() {
205 if ( $wgDatabase->indexUnique( 'image', 'img_name' ) ) {
206 echo "...img_name already unique.\n";
208 echo "Making the img_name index unique... ";
209 dbsource( "maintenance/archives/patch-image_name_unique.sql", $wgDatabase );
214 function do_logging_update() {
216 if ( $wgDatabase->tableExists( 'logging' ) ) {
217 echo "...logging table already exists.\n";
219 echo "Creating logging table and adjusting recentchanges... ";
220 dbsource( "maintenance/archives/patch-logging.sql", $wgDatabase );
225 function do_user_rights_update() {
227 if ( $wgDatabase->tableExists( 'user_rights' ) ) {
228 echo "...user_rights table already exists.\n";
230 echo 'Creating user rights table...';
231 dbsource( 'maintenance/archives/patch-user_rights.sql', $wgDatabase );