X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=update.php;h=e4ae1874d074f0e1786da30c8878af41c2cb24cf;hb=0f266432891ce57e335fb87bf00324178960aac8;hp=f91a80ce3f3458b833b1be4fb7a0259eef0eb29f;hpb=57c2cffd82a30afaf0d584855b9784a166a7ff42;p=lhc%2Fweb%2Fwiklou.git diff --git a/update.php b/update.php index f91a80ce3f..e4ae1874d0 100644 --- a/update.php +++ b/update.php @@ -1,4 +1,4 @@ -isOpen() ) { + print "Unable to connect to database: " . $wgDatabase->lastError() . "\n"; + exit(); +} - do_revision_updates(); - - do_ipblocks_update(); - do_interwiki_update(); - do_index_update(); - do_linkscc_update(); +do_revision_updates(); - initialiseMessages(); +do_ipblocks_update(); +do_interwiki_update(); +do_index_update(); +do_linkscc_update(); +do_hitcounter_update(); +do_recentchanges_update(); - mysql_close( $rconn ); +initialiseMessages(); + +$wgDatabase->close(); print "Done.\n"; exit(); @@ -76,6 +82,18 @@ function do_update_files() { copydirectory( "./stylesheets", $wgStyleSheetDirectory ); copyfile( "./images", "wiki.png", $wgUploadDirectory ); + copyfile( "./images", "button_bold.gif", $wgUploadDirectory ); + copyfile( "./images", "button_extlink.gif", $wgUploadDirectory ); + copyfile( "./images", "button_headline.gif", $wgUploadDirectory ); + copyfile( "./images", "button_hr.gif", $wgUploadDirectory ); + copyfile( "./images", "button_image.gif", $wgUploadDirectory ); + copyfile( "./images", "button_italic.gif", $wgUploadDirectory ); + copyfile( "./images", "button_link.gif", $wgUploadDirectory ); + copyfile( "./images", "button_math.gif", $wgUploadDirectory ); + copyfile( "./images", "button_media.gif", $wgUploadDirectory ); + copyfile( "./images", "button_sig.gif", $wgUploadDirectory ); + copyfile( "./images", "button_template.gif", $wgUploadDirectory ); + copyfile( "./languages", "Language.php", $IP ); copyfile( "./languages", "Language" . ucfirst( $wgLanguageCode ) . ".php", $IP ); @@ -109,6 +127,7 @@ function do_revision_updates() { } function update_passwords() { + global $wgDatabase; $fname = "Update script: update_passwords()"; print "\nIt appears that you need to update the user passwords in your\n" . "database. If you have already done this (if you've run this update\n" . @@ -120,33 +139,51 @@ function update_passwords() { if ( ! ( "Y" == $resp{0} || "y" == $resp{0} ) ) { return; } $sql = "SELECT user_id,user_password FROM user"; - $source = wfQuery( $sql, DB_READ, fname ); + $source = $wgDatabase->query( $sql, $fname ); - while ( $row = mysql_fetch_object( $source ) ) { + while ( $row = $wgDatabase->fetchObject( $source ) ) { $id = $row->user_id; $oldpass = $row->user_password; $newpass = md5( "{$id}-{$oldpass}" ); $sql = "UPDATE user SET user_password='{$newpass}' " . "WHERE user_id={$id}"; - wfQuery( $sql, DB_WRITE, $fname ); + $wgDatabase->query( $sql, $fname ); } } function do_ipblocks_update() { - if ( wfFieldExists( "ipblocks", "ipb_id" ) ) { - echo "...ipblocks table is up to date.\n"; - } else { + global $wgDatabase; + + $do1 = $do2 = false; + + if ( !$wgDatabase->fieldExists( "ipblocks", "ipb_id" ) ) { + $do1 = true; + } + if ( !$wgDatabase->fieldExists( "ipblocks", "ipb_expiry" ) ) { + $do2 = true; + } + + if ( $do1 || $do2 ) { echo "Updating ipblocks table... "; - dbsource( "maintenance/archives/patch-ipblocks.sql" ); + if ( $do1 ) { + dbsource( "maintenance/archives/patch-ipblocks.sql", $wgDatabase ); + } + if ( $do2 ) { + dbsource( "maintenance/archives/patch-ipb_expiry.sql", $wgDatabase ); + } echo "ok\n"; + } else { + echo "...ipblocks is up to date.\n"; } + } function do_interwiki_update() { # Check that interwiki table exists; if it doesn't source it - if( table_exists( "interwiki" ) ) { + global $wgDatabase; + if( $wgDatabase->tableExists( "interwiki" ) ) { echo "...already have interwiki table\n"; return true; } @@ -160,7 +197,8 @@ function do_interwiki_update() { function do_index_update() { # Check that proper indexes are in place - $meta = field_info( "recentchanges", "rc_timestamp" ); + global $wgDatabase; + $meta = $wgDatabase->fieldInfo( "recentchanges", "rc_timestamp" ); if( $meta->multiple_key == 0 ) { echo "Updating indexes to 20031107: "; dbsource( "maintenance/archives/patch-indexes.sql" ); @@ -173,15 +211,35 @@ function do_index_update() { function do_linkscc_update() { // Create linkscc if necessary - global $rconn; - if( table_exists( "linkscc" ) ) { + global $wgDatabase; + if( $wgDatabase->tableExists( "linkscc" ) ) { echo "...have linkscc table.\n"; } else { echo "Adding linkscc table... "; - dbsource( "maintenance/archives/patch-linkscc.sql" ); + dbsource( "maintenance/archives/patch-linkscc.sql", $wgDatabase ); echo "ok\n"; } } +function do_hitcounter_update() { + // Create hitcounter if necessary + global $wgDatabase; + if( $wgDatabase->tableExists( "hitcounter" ) ) { + echo "...have hitcounter table.\n"; + } else { + echo "Adding hitcounter table... "; + dbsource( "maintenance/archives/patch-hitcounter.sql", $wgDatabase ); + echo "ok\n"; + } +} + +function do_recentchanges_update() { + global $wgDatabase; + if ( !$wgDatabase->fieldExists( "recentchanges", "rc_type" ) ) { + echo "Adding rc_type, rc_moved_to_ns, rc_moved_to_title..."; + dbsource( "maintenance/archives/patch-rc_type.sql" , $wgDatabase ); + echo "ok\n"; + } +} ?>