From d6dd3689f893c2b763825650a895de651c780288 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Sun, 25 Jan 2004 02:40:50 +0000 Subject: [PATCH] Better namespace 8 updating, and watchlist caching in memcached.doc --- docs/memcached.doc | 7 ++++ maintenance/InitialiseMessages.inc | 51 ++++++++++++++---------------- maintenance/rebuildMessages.php | 28 ++++++++++++++-- 3 files changed, 57 insertions(+), 29 deletions(-) diff --git a/docs/memcached.doc b/docs/memcached.doc index eba62ca14c..e2e016dfc9 100644 --- a/docs/memcached.doc +++ b/docs/memcached.doc @@ -115,4 +115,11 @@ MediaWiki namespace: stores: an array where the keys are DB keys and the values are messages set in: wfMsg(), Article::editUpdates() both call wfLoadAllMessages() cleared by: nothing + +Watchlist: + key: $wgDBname:watchlist:id:$userID + ex: wikidb:watchlist:id:4635 + stores: HTML string + cleared by: nothing, expiry time $wgWLCacheTimeout (1 hour) + note: emergency optimisation only ... more to come ... diff --git a/maintenance/InitialiseMessages.inc b/maintenance/InitialiseMessages.inc index 71fb8f0393..a2961476d4 100755 --- a/maintenance/InitialiseMessages.inc +++ b/maintenance/InitialiseMessages.inc @@ -8,14 +8,6 @@ function initialiseMessages( $overwrite = false) { $fname = "initialiseMessages"; $ns = NS_MEDIAWIKI; - if ( !$overwrite ) { - $sql = "SELECT 1 FROM cur WHERE cur_namespace=$ns LIMIT 1"; - $res = wfQuery( $sql, DB_READ, $fname ); - if ( wfNumRows( $res ) ) { - print "MediaWiki: namespace already initialised\n"; - return; - } - } $timestamp = wfTimestampNow(); $invTimestamp = wfInvertTimestamp( $timestamp ); @@ -38,24 +30,32 @@ function initialiseMessages( $overwrite = false) { $title = $titleObj->getDBkey(); $dbencMsg = wfStrencode( $message ); + $doInsert = true; if ( $overwrite ) { $sql = "DELETE FROM cur WHERE cur_namespace=$ns AND cur_title='$title'"; wfQuery( $sql, DB_WRITE, $fname ); + } else { + $row = wfGetArray("cur", array("1"), + array("cur_namespace"=>$ns, "cur_title"=>$title)); + if ($row) { + $doInsert = false; + } + } + if ( $doInsert ) { + $sql = "INSERT INTO cur (cur_namespace, cur_title, cur_text, + cur_user_text, cur_timestamp, cur_restrictions, + cur_is_new, inverse_timestamp, cur_touched) VALUES ( + $ns, + '$title', + '$dbencMsg', + 'MediaWiki default', + '$timestamp', + 'sysop', + 1, + '$invTimestamp', + '$timestamp')"; + wfQuery( $sql, DB_WRITE, $fname ); } - - $sql = "INSERT INTO cur (cur_namespace, cur_title, cur_text, - cur_user_text, cur_timestamp, cur_restrictions, - cur_is_new, inverse_timestamp, cur_touched) VALUES ( - $ns, - '$title', - '$dbencMsg', - 'MediaWiki default', - '$timestamp', - 'sysop', - 1, - '$invTimestamp', - '$timestamp')"; - wfQuery( $sql, DB_WRITE, $fname ); $mwObj =& MagicWord::get( MAG_MSGNW ); $mw = $mwObj->getSynonym( 0 ); $mw = str_replace( "$1", $key, $mw ); @@ -74,12 +74,9 @@ function initialiseMessages( $overwrite = false) { $navText = wfStrencode( $navText ); $title = wfMsgNoDB( "allmessages" ); + $sql = "DELETE FROM cur WHERE cur_namespace=$ns AND cur_title='$title'"; + wfQuery( $sql, DB_WRITE, $fname ); - if ( $overwrite ) { - $sql = "DELETE FROM cur WHERE cur_namespace=$ns AND cur_title='$title'"; - wfQuery( $sql, DB_WRITE, $fname ); - } - $sql = "INSERT INTO cur (cur_namespace, cur_title, cur_text, cur_user_text, cur_timestamp, cur_restrictions, cur_is_new, inverse_timestamp, cur_touched) VALUES ( diff --git a/maintenance/rebuildMessages.php b/maintenance/rebuildMessages.php index 318cf902b0..fde7d9c6dd 100755 --- a/maintenance/rebuildMessages.php +++ b/maintenance/rebuildMessages.php @@ -13,15 +13,39 @@ include_once( "../LocalSettings.php" ); include_once( "../AdminSettings.php" ); $sep = strchr( $include_path = ini_get( "include_path" ), ";" ) ? ";" : ":"; -ini_set( "include_path", "$IP$sep$include_path" ); +ini_set( "include_path", "../includes$sep../languages$sep$include_path" ); include_once( "Setup.php" ); include_once( "./InitialiseMessages.inc" ); +include_once( "../install-utils.inc" ); $wgTitle = Title::newFromText( "Rebuild messages script" ); $wgCommandLineMode = true; set_time_limit(0); -initialiseMessages( true ); +print "1. Update messages to include latest additions to Language.php\n" . + "2. Delete all messages and reinitialise namespace\n" . + "3. Quit\n\n". + + "Please enter a number: "; + +do { + $response = IntVal(readconsole()); + if ( $response >= 1 && $response <= 3 ) { + $good = true; + } else { + $good = false; + print "Please type a number between 1 and 3: "; + } +} while ( !$good ); + +switch ( $response ) { + case 1: + initialiseMessages( false ); + break; + case 2: + initialiseMessages( true ); + break; +} exit(); -- 2.20.1