X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FArticle.php;h=0999bdbd01f2ee71b43dd457903e3089898f9ed1;hb=dcacf45ef694b1ba9fa1bdd062591bbb3b15fa60;hp=8bd18edf0f05d19a3b3be3cbc6addf857e0abc0e;hpb=8d4c81e306f5ae675c894fbeecce76fe8ce3037a;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Article.php b/includes/Article.php index 8bd18edf0f..0999bdbd01 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -250,7 +250,7 @@ class Article { * @return Return the text of this revision */ public function getContent() { - global $wgUser, $wgContLang, $wgOut, $wgMessageCache; + global $wgUser, $wgContLang, $wgMessageCache; wfProfileIn( __METHOD__ ); @@ -260,7 +260,6 @@ class Article { if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { # If this is a system message, get the default text. list( $message, $lang ) = $wgMessageCache->figureMessage( $wgContLang->lcfirst( $this->mTitle->getText() ) ); - $wgMessageCache->loadAllMessages( $lang ); $text = wfMsgGetKey( $message, false, $lang, false ); if ( wfEmptyMsg( $message, $text ) ) @@ -322,9 +321,13 @@ class Article { * @return mixed string on success, false on failure */ public function getUndoText( Revision $undo, Revision $undoafter = null ) { + $currentRev = Revision::newFromTitle( $this->mTitle ); + if ( !$currentRev ) { + return false; // no page + } $undo_text = $undo->getText(); $undoafter_text = $undoafter->getText(); - $cur_text = $this->getContent(); + $cur_text = $currentRev->getText(); if ( $cur_text == $undo_text ) { # No use doing a merge if it's just a straight revert. @@ -826,9 +829,8 @@ class Article { * page of the given title. */ public function view() { - global $wgUser, $wgOut, $wgRequest, $wgContLang; - global $wgEnableParserCache, $wgStylePath, $wgParser; - global $wgUseTrackbacks, $wgUseFileCache; + global $wgUser, $wgOut, $wgRequest, $wgParser; + global $wgUseFileCache, $wgUseETag; wfProfileIn( __METHOD__ ); @@ -836,16 +838,17 @@ class Article { $oldid = $this->getOldID(); $parserCache = ParserCache::singleton(); - $parserOptions = clone $this->getParserOptions(); + $parserOptions = $this->getParserOptions(); # Render printable version, use printable version cache if ( $wgOut->isPrintable() ) { $parserOptions->setIsPrintable( true ); + $parserOptions->setEditSection( false ); + } else if ( $wgUseETag && !$this->mTitle->quickUserCan( 'edit' ) ) { + $parserOptions->setEditSection( false ); } # Try client and file cache if ( $oldid === 0 && $this->checkTouched() ) { - global $wgUseETag; - if ( $wgUseETag ) { $wgOut->setETag( $parserCache->getETag( $this, $parserOptions ) ); } @@ -890,10 +893,14 @@ class Article { return; } + if ( !$wgUseETag && !$this->mTitle->quickUserCan( 'edit' ) ) { + $parserOptions->setEditSection( false ); + } + # Should the parser cache be used? $useParserCache = $this->useParserCache( $oldid ); wfDebug( 'Article::view using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" ); - if ( $wgUser->getOption( 'stubthreshold' ) ) { + if ( $wgUser->getStubThreshold() ) { wfIncrStats( 'pcache_miss_stub' ); } @@ -959,13 +966,11 @@ class Article { if ( $oldid === $this->getLatest() && $this->useParserCache( false ) ) { $this->mParserOutput = $parserCache->get( $this, $parserOptions ); if ( $this->mParserOutput ) { - wfDebug( __METHOD__ . ": showing parser cache for current rev permalink\n" ); + wfDebug( __METHOD__ . ": showing parser cache for current rev permalink\n" ); $wgOut->addParserOutput( $this->mParserOutput ); $wgOut->setRevisionId( $this->mLatest ); - $this->showViewFooter(); - $this->viewUpdates(); - wfProfileOut( __METHOD__ ); - return; + $outputDone = true; + break; } } } @@ -993,14 +998,13 @@ class Article { case 4: # Run the parse, protected by a pool counter wfDebug( __METHOD__ . ": doing uncached parse\n" ); - $key = $parserCache->getKey( $this, $parserOptions ); - $poolCounter = PoolCounter::factory( 'Article::view', $key ); - $dirtyCallback = $useParserCache ? array( $this, 'tryDirtyCache' ) : false; - $status = $poolCounter->executeProtected( array( $this, 'doViewParse' ), $dirtyCallback ); - if ( !$status->isOK() ) { + $this->checkTouched(); + $key = $parserCache->getKey( $this, $parserOptions ); + $poolArticleView = new PoolWorkArticleView( $this, $key, $useParserCache, $parserOptions ); + + if ( !$poolArticleView->execute() ) { # Connection or timeout error - $this->showPoolError( $status ); wfProfileOut( __METHOD__ ); return; } else { @@ -1048,7 +1052,7 @@ class Article { * Article::view() only, other callers should use the DifferenceEngine class. */ public function showDiffPage() { - global $wgOut, $wgRequest, $wgUser; + global $wgRequest, $wgUser; $diff = $wgRequest->getVal( 'diff' ); $rcid = $wgRequest->getVal( 'rcid' ); @@ -1077,7 +1081,7 @@ class Article { * This is hooked by SyntaxHighlight_GeSHi to do syntax highlighting of these * page views. */ - public function showCssOrJsPage() { + protected function showCssOrJsPage() { global $wgOut; $wgOut->wrapWikiMsg( "
\n$1\n
", 'clearyourcache' ); @@ -1093,19 +1097,6 @@ class Article { } } - /** - * Get the robot policy to be used for the current action=view request. - * @return String the policy that should be set - * @deprecated use getRobotPolicy() instead, which returns an associative - * array - */ - public function getRobotPolicyForView() { - wfDeprecated( __METHOD__ ); - $policy = $this->getRobotPolicy( 'view' ); - - return $policy['index'] . ',' . $policy['follow']; - } - /** * Get the robot policy to be used for the current view * @param $action String the action= GET parameter @@ -1285,7 +1276,7 @@ class Article { * Show the footer section of an ordinary page view */ public function showViewFooter() { - global $wgOut, $wgUseTrackbacks, $wgRequest; + global $wgOut, $wgUseTrackbacks; # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page if ( $this->mTitle->getNamespace() == NS_USER_TALK && IP::isValid( $this->mTitle->getText() ) ) { @@ -1317,6 +1308,7 @@ class Article { } $sk = $wgUser->getSkin(); + $token = $wgUser->editToken(); $wgOut->addHTML( "