From: Zheng Zhu Date: Fri, 8 Oct 2004 04:27:07 +0000 (+0000) Subject: performance tweak related to title conversion X-Git-Tag: 1.5.0alpha1~1637 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/operations/?a=commitdiff_plain;h=3285ea4627979a52c3aa81ff42de3d483770c440;p=lhc%2Fweb%2Fwiklou.git performance tweak related to title conversion --- diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 2fb7fb8cb8..0e8d533844 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -161,7 +161,8 @@ class OutputPage { function setRobotpolicy( $str ) { $this->mRobotpolicy = $str; } function setHTMLTitle( $name ) {$this->mHTMLtitle = $name; } function setPageTitle( $name ) { - global $action; + global $action, $wgContLang; + $name = $wgContLang->autoConvert($name); $this->mPagetitle = $name; if(!empty($action)) { $taction = $this->getPageTitleActionText(); @@ -356,12 +357,12 @@ class OutputPage { global $wgUser, $wgLang, $wgDebugComments, $wgCookieExpiration; global $wgInputEncoding, $wgOutputEncoding, $wgContLanguageCode; global $wgDebugRedirects, $wgMimeType, $wgProfiler; + if( $this->mDoNothing ){ return; } $fname = 'OutputPage::output'; wfProfileIn( $fname ); - $sk = $wgUser->getSkin(); if ( '' != $this->mRedirect ) { @@ -951,6 +952,7 @@ class OutputPage { $text); wfProfileOut( $fname.'-interwiki' ); } + wfProfileOut( $fname ); return $colours; } diff --git a/includes/Parser.php b/includes/Parser.php index 5977b7ba36..4b79b83e25 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -16,6 +16,7 @@ * Hence, we limit the number of inclusions of any given page, thus bringing any * attack back to O(N). */ + define( 'MAX_INCLUDE_REPEAT', 100 ); define( 'MAX_INCLUDE_SIZE', 1000000 ); // 1 Million @@ -136,7 +137,7 @@ class Parser * @return ParserOutput a ParserOutput */ function parse( $text, &$title, $options, $linestart = true, $clearState = true ) { - global $wgUseTidy; + global $wgUseTidy, $wgContLang; $fname = 'Parser::parse'; wfProfileIn( $fname ); @@ -150,6 +151,7 @@ class Parser $stripState = NULL; $text = $this->strip( $text, $this->mStripState ); + $text = $this->internalParse( $text, $linestart ); $text = $this->unstrip( $text, $this->mStripState ); # Clean up special characters, only run once, next-to-last before doBlockLevels @@ -182,6 +184,9 @@ class Parser } # only once and last $text = $this->doBlockLevels( $text, $linestart ); + + $text = $wgContLang->convert($text); + $text = $this->unstripNoWiki( $text, $this->mStripState ); $this->mOutput->setText( $text ); wfProfileOut( $fname ); @@ -658,8 +663,6 @@ class Parser $text = $this->removeHTMLtags( $text ); $text = $this->replaceVariables( $text, $args ); - $text = $wgContLang->convert($text); - $text = preg_replace( '/(^|\n)-----*/', '\\1
', $text ); $text = $this->doHeadings( $text ); @@ -1061,9 +1064,13 @@ class Parser * * @access private */ + function replaceInternalLinks( $s ) { global $wgLang, $wgContLang, $wgLinkCache; static $fname = 'Parser::replaceInternalLinks' ; + # use a counter to prevent too much unknown links from + # being checked for different language variants. + static $convertCount; wfProfileIn( $fname ); wfProfileIn( $fname.'-setup' ); @@ -1170,12 +1177,14 @@ class Parser //if the article does not exist global $wgContLang; $variants = $wgContLang->getVariants(); - if(sizeof($variants) > 1) { + + if(sizeof($variants) > 1 && $convertCount < 200) { $varnt = false; if($nt->getArticleID() == 0) { foreach ( $variants as $v ) { if($v == $wgContLang->getPreferredVariant()) continue; + $convertCount ++; $varlink = $wgContLang->autoConvert($link, $v); $varnt = Title::newFromText($varlink); if($varnt && $varnt->getArticleID()>0) { @@ -1281,7 +1290,9 @@ class Parser continue; } } - + + $text = $wgContLang->convert($text); + if( ( $nt->getPrefixedText() === $this->mTitle->getPrefixedText() ) && ( strpos( $link, '#' ) === FALSE ) ) { # Self-links are handled specially; generally de-link and change to bold. diff --git a/includes/Title.php b/includes/Title.php index b1cad3c807..9eb2552a6a 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -525,9 +525,7 @@ class Title { $s = str_replace( '_', ' ', $s ); $this->mPrefixedText = $s; } - //convert to the desired language variant - $t = $wgContLang->convert($this->mPrefixedText); - return $t; + return $this->mPrefixedText; } /** @@ -543,9 +541,7 @@ class Title { if( '' != $this->mFragment ) { $text .= '#' . $this->mFragment; } - //convert to desired language variant - $t = $wgContLang->convert($text); - return $t; + return $text; } /**