Better namespace 8 updating, and watchlist caching in memcached.doc
authorTim Starling <tstarling@users.mediawiki.org>
Sun, 25 Jan 2004 02:40:50 +0000 (02:40 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sun, 25 Jan 2004 02:40:50 +0000 (02:40 +0000)
docs/memcached.doc
maintenance/InitialiseMessages.inc
maintenance/rebuildMessages.php

index eba62ca..e2e016d 100644 (file)
@@ -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 ...
index 71fb8f0..a296147 100755 (executable)
@@ -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 (
index 318cf90..fde7d9c 100755 (executable)
@@ -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();