From: Brion Vibber Date: Sat, 15 Jan 2005 07:08:37 +0000 (+0000) Subject: * (bug 1132) Fix concatenation of link lists in refreshLinks X-Git-Tag: 1.5.0alpha1~937 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=f2dfed19309b4978b29cfb2e505fb40d0c276827;p=lhc%2Fweb%2Fwiklou.git * (bug 1132) Fix concatenation of link lists in refreshLinks * (bug 1101) Fix memory leak in refreshLinks --- diff --git a/includes/Title.php b/includes/Title.php index bdc57caaca..167d406340 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -11,6 +11,13 @@ require_once( 'normal/UtfNormal.php' ); $wgTitleInterwikiCache = array(); define ( 'GAID_FOR_UPDATE', 1 ); +# Title::newFromTitle maintains a cache to avoid +# expensive re-normalization of commonly used titles. +# On a batch operation this can become a memory leak +# if not bounded. After hitting this many titles, +# reset the cache. +define( 'MW_TITLECACHE_MAX', 1000 ); + /** * Title class * - Represents a title, which may contain an interwiki designation or namespace @@ -130,6 +137,10 @@ class Title { if( $t->secureAndSplit() ) { if( $defaultNamespace == 0 ) { + if( count( $titleCache ) >= MW_TITLECACHE_MAX ) { + # Avoid memory leaks on mass operations... + $titleCache = array(); + } $titleCache[$text] =& $t; } wfProfileOut( $fname ); diff --git a/maintenance/refreshLinks.inc b/maintenance/refreshLinks.inc index 60f29817f4..743293f01e 100644 --- a/maintenance/refreshLinks.inc +++ b/maintenance/refreshLinks.inc @@ -41,6 +41,16 @@ function refreshLinks( $start ) { $text = $wgArticle->getContent( true ); $wgLinkCache = new LinkCache; $wgLinkCache->forUpdate( true ); + + global $wgLinkHolders; + $wgLinkHolders = array( + 'namespaces' => array(), + 'dbkeys' => array(), + 'queries' => array(), + 'texts' => array(), + 'titles' => array() + ); + # Parse the text and replace links with placeholders $wgOut->addWikiText( $text );