Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

updaters.inc

Go to the documentation of this file.
00001 <?php 00002 00003 function do_revision_updates() { 00004 global $wgSoftwareRevision; 00005 if ( $wgSoftwareRevision < 1001 ) { 00006 update_passwords(); 00007 } 00008 } 00009 00010 function update_passwords() { 00011 global $wgDatabase; 00012 $fname = "Update script: update_passwords()"; 00013 print "\nIt appears that you need to update the user passwords in your\n" . 00014 "database. If you have already done this (if you've run this update\n" . 00015 "script once before, for example), doing so again will make all your\n" . 00016 "user accounts inaccessible, so be sure you only do this once.\n" . 00017 "Update user passwords? (yes/no)"; 00018 00019 $resp = readconsole(); 00020 if ( ! ( "Y" == $resp{0} || "y" == $resp{0} ) ) { return; } 00021 00022 $sql = "SELECT user_id,user_password FROM user"; 00023 $source = $wgDatabase->query( $sql, $fname ); 00024 00025 while ( $row = $wgDatabase->fetchObject( $source ) ) { 00026 $id = $row->user_id; 00027 $oldpass = $row->user_password; 00028 $newpass = md5( "{$id}-{$oldpass}" ); 00029 00030 $sql = "UPDATE user SET user_password='{$newpass}' " . 00031 "WHERE user_id={$id}"; 00032 $wgDatabase->query( $sql, $fname ); 00033 } 00034 } 00035 00036 function do_ipblocks_update() { 00037 global $wgDatabase; 00038 00039 $do1 = $do2 = false; 00040 00041 if ( !$wgDatabase->fieldExists( "ipblocks", "ipb_id" ) ) { 00042 $do1 = true; 00043 } 00044 if ( !$wgDatabase->fieldExists( "ipblocks", "ipb_expiry" ) ) { 00045 $do2 = true; 00046 } 00047 00048 if ( $do1 || $do2 ) { 00049 echo "Updating ipblocks table... "; 00050 if ( $do1 ) { 00051 dbsource( "maintenance/archives/patch-ipblocks.sql", $wgDatabase ); 00052 } 00053 if ( $do2 ) { 00054 dbsource( "maintenance/archives/patch-ipb_expiry.sql", $wgDatabase ); 00055 } 00056 echo "ok\n"; 00057 } else { 00058 echo "...ipblocks is up to date.\n"; 00059 } 00060 00061 } 00062 00063 00064 function do_interwiki_update() { 00065 # Check that interwiki table exists; if it doesn't source it 00066 global $wgDatabase; 00067 if( $wgDatabase->tableExists( "interwiki" ) ) { 00068 echo "...already have interwiki table\n"; 00069 return true; 00070 } 00071 echo "Creating interwiki table: "; 00072 dbsource( "maintenance/archives/patch-interwiki.sql" ); 00073 echo "ok\n"; 00074 echo "Adding default interwiki definitions: "; 00075 dbsource( "maintenance/interwiki.sql" ); 00076 echo "ok\n"; 00077 } 00078 00079 function do_index_update() { 00080 # Check that proper indexes are in place 00081 global $wgDatabase; 00082 $meta = $wgDatabase->fieldInfo( "recentchanges", "rc_timestamp" ); 00083 if( $meta->multiple_key == 0 ) { 00084 echo "Updating indexes to 20031107: "; 00085 dbsource( "maintenance/archives/patch-indexes.sql" ); 00086 echo "ok\n"; 00087 return true; 00088 } 00089 echo "...indexes seem up to 20031107 standards\n"; 00090 return false; 00091 } 00092 00093 function do_linkscc_update() { 00094 // Create linkscc if necessary 00095 global $wgDatabase; 00096 if( $wgDatabase->tableExists( "linkscc" ) ) { 00097 echo "...have linkscc table.\n"; 00098 } else { 00099 echo "Adding linkscc table... "; 00100 dbsource( "maintenance/archives/patch-linkscc.sql", $wgDatabase ); 00101 echo "ok\n"; 00102 } 00103 } 00104 00105 function do_linkscc_1_3_update() { 00106 // Update linkscc table to 1.3 schema if necessary 00107 global $wgDatabase, $wgVersion; 00108 if( ( strpos( "1.3", $wgVersion ) === 0 ) && $wgDatabase->tableExists( "linkscc" ) 00109 && $wgDatabase->fieldExists( "linkscc", "lcc_title" ) ) { 00110 echo "Altering lcc_title field from linkscc table... "; 00111 dbsource( "maintenance/archives/patch-linkscc-1.3.sql", $wgDatabase ); 00112 echo "ok\n"; 00113 } else { 00114 echo "...linkscc is up to date, or does not exist. Good.\n"; 00115 } 00116 } 00117 00118 function do_hitcounter_update() { 00119 // Create hitcounter if necessary 00120 global $wgDatabase; 00121 if( $wgDatabase->tableExists( "hitcounter" ) ) { 00122 echo "...have hitcounter table.\n"; 00123 } else { 00124 echo "Adding hitcounter table... "; 00125 dbsource( "maintenance/archives/patch-hitcounter.sql", $wgDatabase ); 00126 echo "ok\n"; 00127 } 00128 } 00129 00130 function do_recentchanges_update() { 00131 global $wgDatabase; 00132 if ( !$wgDatabase->fieldExists( "recentchanges", "rc_type" ) ) { 00133 echo "Adding rc_type, rc_moved_to_ns, rc_moved_to_title..."; 00134 dbsource( "maintenance/archives/patch-rc_type.sql" , $wgDatabase ); 00135 echo "ok\n"; 00136 } 00137 if ( !$wgDatabase->fieldExists( "recentchanges", "rc_ip" ) ) { 00138 echo "Adding rc_ip..."; 00139 dbsource( "maintenance/archives/patch-rc_ip.sql", $wgDatabase ); 00140 echo "ok\n"; 00141 } 00142 } 00143 00144 function do_user_real_name_update() { 00145 global $wgDatabase; 00146 if ( $wgDatabase->fieldExists( "user", "user_real_name" ) ) { 00147 echo "...have user_real_name field in user table.\n"; 00148 } else { 00149 echo "Adding user_real_name field to table user..."; 00150 dbsource( "maintenance/archives/patch-user-realname.sql" , $wgDatabase ); 00151 echo "ok\n"; 00152 } 00153 } 00154 00155 function do_querycache_update() { 00156 global $wgDatabase; 00157 if( $wgDatabase->tableExists( "querycache" ) ) { 00158 echo "...have special page querycache table.\n"; 00159 } else { 00160 echo "Adding querycache table for slow special pages... "; 00161 dbsource( "maintenance/archives/patch-querycache.sql", $wgDatabase ); 00162 echo "ok\n"; 00163 } 00164 } 00165 00166 function do_objectcache_update() { 00167 global $wgDatabase; 00168 if( $wgDatabase->tableExists( "objectcache" ) ) { 00169 echo "...have objectcache table.\n"; 00170 } else { 00171 echo "Adding objectcache table for message caching... "; 00172 dbsource( "maintenance/archives/patch-objectcache.sql", $wgDatabase ); 00173 echo "ok\n"; 00174 } 00175 } 00176 00177 function do_categorylinks_update() { 00178 global $wgDatabase; 00179 if( $wgDatabase->tableExists( "categorylinks" ) ) { 00180 echo "...have categorylinks table.\n"; 00181 } else { 00182 echo "Adding categorylinks table for category management... "; 00183 dbsource( "maintenance/archives/patch-categorylinks.sql", $wgDatabase ); 00184 echo "ok\n"; 00185 } 00186 } 00187 ?>

Generated on Tue Jun 29 23:40:07 2004 for Mediawiki by doxygen 1.3.7