From: Tim Starling Date: Sun, 29 May 2005 05:54:04 +0000 (+0000) Subject: ported $wgAntiLockFlags from REL1_4 X-Git-Tag: 1.5.0alpha2~46 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/Special:BookSources/2753300917?a=commitdiff_plain;h=a7c938d0c3f8ebe760428f58c9a66fdd7c99a741;p=lhc%2Fweb%2Fwiklou.git ported $wgAntiLockFlags from REL1_4 --- diff --git a/includes/Article.php b/includes/Article.php index b02b7679df..c619a3c043 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -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 diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index fac55a949c..051ac6da58 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -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). diff --git a/includes/Defines.php b/includes/Defines.php index 6f8b1b9138..6e00d629f2 100644 --- a/includes/Defines.php +++ b/includes/Defines.php @@ -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 ); /**#@-*/ ?> diff --git a/includes/LinkCache.php b/includes/LinkCache.php index 35e486bf92..9d86a24a2b 100644 --- a/includes/LinkCache.php +++ b/includes/LinkCache.php @@ -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();