ported $wgAntiLockFlags from REL1_4
authorTim Starling <tstarling@users.mediawiki.org>
Sun, 29 May 2005 05:54:04 +0000 (05:54 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sun, 29 May 2005 05:54:04 +0000 (05:54 +0000)
includes/Article.php
includes/DefaultSettings.php
includes/Defines.php
includes/LinkCache.php

index b02b767..c619a3c 100644 (file)
@@ -1195,9 +1195,24 @@ class Article {
         * the link tables and redirect to the new page.
         */
        function showArticle( $text, $subtitle , $sectionanchor = '', $me2, $now, $summary, $oldid ) {
-               global $wgOut, $wgUser, $wgLinkCache, $wgEnotif;
+               global $wgUseDumbLinkUpdate, $wgAntiLockFlags, $wgOut, $wgUser, $wgLinkCache, $wgEnotif;
 
                $wgLinkCache = new LinkCache();
+               
+               if ( !$wgUseDumbLinkUpdate ) {
+                       # Preload links to reduce lock time
+                       if ( $wgAntiLockFlags & ALF_PRELOAD_LINKS ) {
+                               $wgLinkCache->preFill( $this->mTitle );
+                               $wgLinkCache->clear();
+                       }
+               }
+               # Parse the text and replace links with placeholders
+               # Do this outside the locks on the links table
+               # The existence test queries need to be FOR UPDATE
+               #$oldUpdate = $wgParser->forUpdate( true );
+               $wgOut = new OutputPage();
+               $wgOut->addWikiTextWithTitle( $text, $this->mTitle );
+
                # Select for update
                $wgLinkCache->forUpdate( true );
 
@@ -1214,9 +1229,19 @@ class Article {
                # go wrong.
                $wgOut->addWikiTextWithTitle( $text, $this->mTitle );
 
-               # Look up the links in the DB and add them to the link cache
-               $wgOut->transformBuffer( RLH_FOR_UPDATE );
+               if ( !$wgUseDumbLinkUpdate ) {
+                       # Move the current links back to the second register
+                       $wgLinkCache->swapRegisters();
+
+                       # Get old version of link table to allow incremental link updates
+                       # Lock this data now since it is needed for an update
+                       $wgLinkCache->forUpdate( true );
+                       $wgLinkCache->preFill( $this->mTitle );
 
+                       # Swap this old version back into its rightful place
+                       $wgLinkCache->swapRegisters();
+               }
+               
                if( $this->isRedirect( $text ) )
                        $r = 'redirect=no';
                else
index fac55a9..051ac6d 100644 (file)
@@ -898,6 +898,15 @@ $wgDisableAnonTalk = false;
  */
 $wgUseDumbLinkUpdate = false; 
 
+/**
+ * Anti-lock flags - bitfield
+ *   ALF_PRELOAD_LINKS
+ *       Preload links during link update for save
+ *   ALF_PRELOAD_EXISTENCE
+ *       Preload cur_id during replaceLinkHolders
+ */
+$wgAntiLockFlags = 0;
+
 /**
  * Path to the GNU diff3 utility. If the file doesn't exist, edit conflicts will
  * fall back to the old behaviour (no merging).
index 6f8b1b9..6e00d62 100644 (file)
@@ -116,7 +116,15 @@ define( 'AV_NO_VIRUS', 0 );  #scan ok, no virus found
 define( 'AV_VIRUS_FOUND', 1 );  #virus found!
 define( 'AV_SCAN_ABORTED', -1 );  #scan aborted, the file is probably imune
 define( 'AV_SCAN_FAILED', false );  #scan failed (scanner not found or error in scanner)
+/**#@-*/
 
+/**#@+
+ * Anti-lock flags
+ * See DefaultSettings.php for a description
+ */
+define( 'ALF_PRELOAD_LINKS', 1 );
+define( 'ALF_PRELOAD_EXISTENCE', 2 );
+define( 'ALF_NO_LINK_LOCK', 4 );
 /**#@-*/
 
 ?>
index 35e486b..9d86a24 100644 (file)
@@ -127,7 +127,7 @@ class LinkCache {
        }
        
        function addLinkObj( &$nt ) {
-               global $wgMemc, $wgLinkCacheMemcached;
+               global $wgMemc, $wgLinkCacheMemcached, $wgAntiLockFlags;
                $title = $nt->getPrefixedDBkey();
                if ( $this->isBadLink( $title ) ) { return 0; }         
                $id = $this->getGoodLinkID( $title );
@@ -150,7 +150,9 @@ class LinkCache {
                if( ! is_integer( $id ) ) {
                        if ( $this->mForUpdate ) {
                                $db =& wfGetDB( DB_MASTER );
-                               $options = array( 'FOR UPDATE' );
+                               if ( !( $wgAntiLockFlags & ALF_NO_LINK_LOCK ) ) {
+                                       $options = array( 'FOR UPDATE' );
+                               }
                        } else {
                                $db =& wfGetDB( DB_SLAVE );
                                $options = array();