X-Git-Url: https://git.cyclocoop.org/%28%28?a=blobdiff_plain;f=includes%2Fpage%2FArticle.php;h=6516ae81d2a570790e3a09aa4f6cccae4a89da50;hb=3c4bf0c2a86d9f515b47b8265bca978c21d363bd;hp=cf53f1d59a2c716ae550281991cb612195660b80;hpb=7cfeed5ad6f70b7099ce9bb86792e7ccf4ff0813;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/page/Article.php b/includes/page/Article.php index cf53f1d59a..6516ae81d2 100644 --- a/includes/page/Article.php +++ b/includes/page/Article.php @@ -120,7 +120,7 @@ class Article implements Page { } $page = null; - wfRunHooks( 'ArticleFromTitle', array( &$title, &$page, $context ) ); + Hooks::run( 'ArticleFromTitle', array( &$title, &$page, $context ) ); if ( !$page ) { switch ( $title->getNamespace() ) { case NS_FILE: @@ -226,7 +226,6 @@ class Article implements Page { * @since 1.21 */ protected function getContentObject() { - wfProfileIn( __METHOD__ ); if ( $this->mPage->getID() === 0 ) { # If this is a MediaWiki:x message, then load the messages @@ -247,7 +246,6 @@ class Article implements Page { $content = $this->mContentObject; } - wfProfileOut( __METHOD__ ); return $content; } @@ -344,12 +342,9 @@ class Article implements Page { return $this->mContent; } - wfProfileIn( __METHOD__ ); - $content = $this->fetchContentObject(); if ( !$content ) { - wfProfileOut( __METHOD__ ); return false; } @@ -357,8 +352,6 @@ class Article implements Page { $this->mContent = ContentHandler::getContentText( $content ); ContentHandler::runLegacyHooks( 'ArticleAfterFetchContent', array( &$this, &$this->mContent ) ); - wfProfileOut( __METHOD__ ); - return $this->mContent; } @@ -379,8 +372,6 @@ class Article implements Page { return $this->mContentObject; } - wfProfileIn( __METHOD__ ); - $this->mContentLoaded = true; $this->mContent = null; @@ -397,7 +388,6 @@ class Article implements Page { $this->mRevision = Revision::newFromId( $oldid ); if ( !$this->mRevision ) { wfDebug( __METHOD__ . " failed to retrieve specified revision, id $oldid\n" ); - wfProfileOut( __METHOD__ ); return false; } } @@ -405,7 +395,6 @@ class Article implements Page { if ( !$this->mPage->getLatest() ) { wfDebug( __METHOD__ . " failed to find page data for title " . $this->getTitle()->getPrefixedText() . "\n" ); - wfProfileOut( __METHOD__ ); return false; } @@ -414,7 +403,6 @@ class Article implements Page { if ( !$this->mRevision ) { wfDebug( __METHOD__ . " failed to retrieve current page, rev_id " . $this->mPage->getLatest() . "\n" ); - wfProfileOut( __METHOD__ ); return false; } } @@ -422,15 +410,21 @@ class Article implements Page { // @todo FIXME: Horrible, horrible! This content-loading interface just plain sucks. // We should instead work with the Revision object when we need it... // Loads if user is allowed - $this->mContentObject = $this->mRevision->getContent( + $content = $this->mRevision->getContent( Revision::FOR_THIS_USER, $this->getContext()->getUser() ); - $this->mRevIdFetched = $this->mRevision->getId(); - wfRunHooks( 'ArticleAfterFetchContentObject', array( &$this, &$this->mContentObject ) ); + if ( !$content ) { + wfDebug( __METHOD__ . " failed to retrieve content of revision " . + $this->mRevision->getId() . "\n" ); + return false; + } - wfProfileOut( __METHOD__ ); + $this->mContentObject = $content; + $this->mRevIdFetched = $this->mRevision->getId(); + + Hooks::run( 'ArticleAfterFetchContentObject', array( &$this, &$this->mContentObject ) ); return $this->mContentObject; } @@ -482,8 +476,6 @@ class Article implements Page { public function view() { global $wgUseFileCache, $wgUseETag, $wgDebugToolbar, $wgMaxRedirects; - wfProfileIn( __METHOD__ ); - # Get variables from query string # As side effect this will load the revision and update the title # in a revision ID is passed in the request, so this should remain @@ -495,7 +487,6 @@ class Article implements Page { $permErrors = $this->getTitle()->getUserPermissionsErrors( 'read', $user ); if ( count( $permErrors ) ) { wfDebug( __METHOD__ . ": denied on secondary read check\n" ); - wfProfileOut( __METHOD__ ); throw new PermissionsError( 'read', $permErrors ); } @@ -504,7 +495,6 @@ class Article implements Page { if ( $this->mRedirectUrl ) { $outputPage->redirect( $this->mRedirectUrl ); wfDebug( __METHOD__ . ": redirecting due to oldid\n" ); - wfProfileOut( __METHOD__ ); return; } @@ -513,7 +503,6 @@ class Article implements Page { if ( $this->getContext()->getRequest()->getCheck( 'diff' ) ) { wfDebug( __METHOD__ . ": showing diff page\n" ); $this->showDiffPage(); - wfProfileOut( __METHOD__ ); return; } @@ -568,7 +557,6 @@ class Article implements Page { # Is it client cached? if ( $outputPage->checkLastModified( $timestamp ) ) { wfDebug( __METHOD__ . ": done 304\n" ); - wfProfileOut( __METHOD__ ); return; # Try file cache @@ -577,7 +565,6 @@ class Article implements Page { # tell wgOut that output is taken care of $outputPage->disable(); $this->mPage->doViewUpdates( $user, $oldid ); - wfProfileOut( __METHOD__ ); return; } @@ -602,7 +589,7 @@ class Article implements Page { while ( !$outputDone && ++$pass ) { switch ( $pass ) { case 1: - wfRunHooks( 'ArticleViewHeader', array( &$this, &$outputDone, &$useParserCache ) ); + Hooks::run( 'ArticleViewHeader', array( &$this, &$outputDone, &$useParserCache ) ); break; case 2: # Early abort if the page doesn't exist @@ -610,7 +597,6 @@ class Article implements Page { wfDebug( __METHOD__ . ": showing missing article\n" ); $this->showMissingArticle(); $this->mPage->doViewUpdates( $user ); - wfProfileOut( __METHOD__ ); return; } @@ -649,7 +635,6 @@ class Article implements Page { if ( !$this->showDeletedRevisionHeader() ) { wfDebug( __METHOD__ . ": cannot view deleted revision\n" ); - wfProfileOut( __METHOD__ ); return; } } @@ -665,7 +650,7 @@ class Article implements Page { wfDebug( __METHOD__ . ": showing CSS/JS source\n" ); $this->showCssOrJsPage(); $outputDone = true; - } elseif ( !wfRunHooks( 'ArticleContentViewCustom', + } elseif ( !Hooks::run( 'ArticleContentViewCustom', array( $this->fetchContentObject(), $this->getTitle(), $outputPage ) ) ) { # Allow extensions do their own custom view for certain pages @@ -696,16 +681,14 @@ class Article implements Page { $outputPage->addWikiText( '
' . $errortext . '
' ); } # Connection or timeout error - wfProfileOut( __METHOD__ ); return; } $this->mParserOutput = $poolArticleView->getParserOutput(); $outputPage->addParserOutput( $this->mParserOutput ); if ( $content->getRedirectTarget() ) { - $outputPage->addSubtitle( - "" . wfMessage( 'redirectpagesub' )->parse() . "" - ); + $outputPage->addSubtitle( "" . + $this->getContext()->msg( 'redirectpagesub' )->parse() . "" ); } # Don't cache a dirty ParserOutput object @@ -755,7 +738,6 @@ class Article implements Page { $outputPage->addModules( 'mediawiki.action.view.postEdit' ); - wfProfileOut( __METHOD__ ); } /** @@ -835,7 +817,7 @@ class Article implements Page { if ( $showCacheHint ) { $dir = $this->getContext()->getLanguage()->getDir(); - $lang = $this->getContext()->getLanguage()->getCode(); + $lang = $this->getContext()->getLanguage()->getHtmlCode(); $outputPage->wrapWikiMsg( "
\n$1\n
", @@ -995,7 +977,7 @@ class Article implements Page { if ( isset( $this->mRedirectedFrom ) ) { // This is an internally redirected page view. // We'll need a backlink to the source page for navigation. - if ( wfRunHooks( 'ArticleViewRedirect', array( &$this ) ) ) { + if ( Hooks::run( 'ArticleViewRedirect', array( &$this ) ) ) { $redir = Linker::linkKnown( $this->mRedirectedFrom, null, @@ -1003,7 +985,9 @@ class Article implements Page { array( 'redirect' => 'no' ) ); - $outputPage->addSubtitle( wfMessage( 'redirectedfrom' )->rawParams( $redir ) ); + $outputPage->addSubtitle( "" . + wfMessage( 'redirectedfrom' )->rawParams( $redir )->parse() + . "" ); // Add the script to update the displayed URL and // set the fragment if one was specified in the redirect @@ -1025,7 +1009,9 @@ class Article implements Page { // If it was reported from a trusted site, supply a backlink. if ( $wgRedirectSources && preg_match( $wgRedirectSources, $rdfrom ) ) { $redir = Linker::makeExternalLink( $rdfrom, $rdfrom ); - $outputPage->addSubtitle( wfMessage( 'redirectedfrom' )->rawParams( $redir ) ); + $outputPage->addSubtitle( "" . + wfMessage( 'redirectedfrom' )->rawParams( $redir )->parse() + . "" ); // Add the script to update the displayed URL $outputPage->addJsConfigVars( array( @@ -1069,7 +1055,7 @@ class Article implements Page { // Show a footer allowing the user to patrol the shown revision or page if possible $patrolFooterShown = $this->showPatrolFooter(); - wfRunHooks( 'ArticleViewFooter', array( $this, $patrolFooterShown ) ); + Hooks::run( 'ArticleViewFooter', array( $this, $patrolFooterShown ) ); } /** @@ -1096,8 +1082,6 @@ class Article implements Page { return false; } - wfProfileIn( __METHOD__ ); - // New page patrol: Get the timestamp of the oldest revison which // the revision table holds for the given page. Then we look // whether it's within the RC lifespan and if it is, we try @@ -1106,7 +1090,6 @@ class Article implements Page { // Check for cached results if ( $cache->get( wfMemcKey( 'NotPatrollablePage', $this->getTitle()->getArticleID() ) ) ) { - wfProfileOut( __METHOD__ ); return false; } @@ -1115,7 +1098,6 @@ class Article implements Page { ) { // The current revision is already older than what could be in the RC table // 6h tolerance because the RC might not be cleaned out regularly - wfProfileOut( __METHOD__ ); return false; } @@ -1151,14 +1133,12 @@ class Article implements Page { // Don't cache in case we can patrol as this could change $cache->set( wfMemcKey( 'NotPatrollablePage', $this->getTitle()->getArticleID() ), '1' ); - wfProfileOut( __METHOD__ ); return false; } - if ( $rc->getPerformer()->getName() == $user->getName() ) { + if ( $rc->getPerformer()->equals( $user ) ) { // Don't show a patrol link for own creations. If the user could // patrol them, they already would be patrolled - wfProfileOut( __METHOD__ ); return false; } @@ -1188,7 +1168,6 @@ class Article implements Page { '' ); - wfProfileOut( __METHOD__ ); return true; } @@ -1240,12 +1219,12 @@ class Article implements Page { } } - wfRunHooks( 'ShowMissingArticle', array( $this ) ); + Hooks::run( 'ShowMissingArticle', array( $this ) ); // Give extensions a chance to hide their (unrelated) log entries $logTypes = array( 'delete', 'move' ); $conds = array( "log_action != 'revision'" ); - wfRunHooks( 'Article::MissingArticleConditions', array( &$conds, $logTypes ) ); + Hooks::run( 'Article::MissingArticleConditions', array( &$conds, $logTypes ) ); # Show delete and move logs LogEventsList::showLogExtract( $outputPage, $logTypes, $title, '', @@ -1266,7 +1245,7 @@ class Article implements Page { $outputPage->setIndexPolicy( $policy['index'] ); $outputPage->setFollowPolicy( $policy['follow'] ); - $hookResult = wfRunHooks( 'BeforeDisplayNoArticleText', array( $this ) ); + $hookResult = Hooks::run( 'BeforeDisplayNoArticleText', array( $this ) ); if ( !$hookResult ) { return; @@ -1342,11 +1321,12 @@ class Article implements Page { * @param int $oldid Revision ID of this article revision */ public function setOldSubtitle( $oldid = 0 ) { - if ( !wfRunHooks( 'DisplayOldSubtitle', array( &$this, &$oldid ) ) ) { + if ( !Hooks::run( 'DisplayOldSubtitle', array( &$this, &$oldid ) ) ) { return; } - $unhide = $this->getContext()->getRequest()->getInt( 'unhide' ) == 1; + $context = $this->getContext(); + $unhide = $context->getRequest()->getInt( 'unhide' ) == 1; # Cascade unhide param in links for easy deletion browsing $extraParams = array(); @@ -1363,8 +1343,8 @@ class Article implements Page { $timestamp = $revision->getTimestamp(); $current = ( $oldid == $this->mPage->getLatest() ); - $language = $this->getContext()->getLanguage(); - $user = $this->getContext()->getUser(); + $language = $context->getLanguage(); + $user = $context->getUser(); $td = $language->userTimeAndDate( $timestamp, $user ); $tddate = $language->userDate( $timestamp, $user ); @@ -1373,13 +1353,13 @@ class Article implements Page { # Show user links if allowed to see them. If hidden, then show them only if requested... $userlinks = Linker::revUserTools( $revision, !$unhide ); - $infomsg = $current && !wfMessage( 'revision-info-current' )->isDisabled() + $infomsg = $current && !$context->msg( 'revision-info-current' )->isDisabled() ? 'revision-info-current' : 'revision-info'; - $outputPage = $this->getContext()->getOutput(); + $outputPage = $context->getOutput(); $outputPage->addSubtitle( "
" . - wfMessage( $infomsg, $td ) + $context->msg( $infomsg, $td ) ->rawParams( $userlinks ) ->params( $revision->getID(), $tddate, $tdtime, $revision->getUserText() ) ->rawParams( Linker::revComment( $revision, true, true ) ) @@ -1388,18 +1368,18 @@ class Article implements Page { ); $lnk = $current - ? wfMessage( 'currentrevisionlink' )->escaped() + ? $context->msg( 'currentrevisionlink' )->escaped() : Linker::linkKnown( $this->getTitle(), - wfMessage( 'currentrevisionlink' )->escaped(), + $context->msg( 'currentrevisionlink' )->escaped(), array(), $extraParams ); $curdiff = $current - ? wfMessage( 'diff' )->escaped() + ? $context->msg( 'diff' )->escaped() : Linker::linkKnown( $this->getTitle(), - wfMessage( 'diff' )->escaped(), + $context->msg( 'diff' )->escaped(), array(), array( 'diff' => 'cur', @@ -1410,30 +1390,30 @@ class Article implements Page { $prevlink = $prev ? Linker::linkKnown( $this->getTitle(), - wfMessage( 'previousrevision' )->escaped(), + $context->msg( 'previousrevision' )->escaped(), array(), array( 'direction' => 'prev', 'oldid' => $oldid ) + $extraParams ) - : wfMessage( 'previousrevision' )->escaped(); + : $context->msg( 'previousrevision' )->escaped(); $prevdiff = $prev ? Linker::linkKnown( $this->getTitle(), - wfMessage( 'diff' )->escaped(), + $context->msg( 'diff' )->escaped(), array(), array( 'diff' => 'prev', 'oldid' => $oldid ) + $extraParams ) - : wfMessage( 'diff' )->escaped(); + : $context->msg( 'diff' )->escaped(); $nextlink = $current - ? wfMessage( 'nextrevision' )->escaped() + ? $context->msg( 'nextrevision' )->escaped() : Linker::linkKnown( $this->getTitle(), - wfMessage( 'nextrevision' )->escaped(), + $context->msg( 'nextrevision' )->escaped(), array(), array( 'direction' => 'next', @@ -1441,10 +1421,10 @@ class Article implements Page { ) + $extraParams ); $nextdiff = $current - ? wfMessage( 'diff' )->escaped() + ? $context->msg( 'diff' )->escaped() : Linker::linkKnown( $this->getTitle(), - wfMessage( 'diff' )->escaped(), + $context->msg( 'diff' )->escaped(), array(), array( 'diff' => 'next', @@ -1458,7 +1438,7 @@ class Article implements Page { } $outputPage->addSubtitle( "
" . $cdel . - wfMessage( 'revision-nav' )->rawParams( + $context->msg( 'revision-nav' )->rawParams( $prevdiff, $prevlink, $lnk, $curdiff, $nextlink, $nextdiff )->escaped() . "
" ); } @@ -1478,7 +1458,7 @@ class Article implements Page { $lang = $this->getTitle()->getPageLanguage(); $out = $this->getContext()->getOutput(); if ( $appendSubtitle ) { - $out->addSubtitle( wfMessage( 'redirectpagesub' )->parse() ); + $out->addSubtitle( wfMessage( 'redirectpagesub' ) ); } $out->addModuleStyles( 'mediawiki.action.view.redirectPage' ); return static::getRedirectHeaderHtml( $lang, $target, $forceKnown ); @@ -1555,7 +1535,8 @@ class Article implements Page { # This code desperately needs to be totally rewritten $title = $this->getTitle(); - $user = $this->getContext()->getUser(); + $context = $this->getContext(); + $user = $context->getUser(); # Check permissions $permissionErrors = $title->getUserPermissionsErrors( 'delete', $user ); @@ -1572,8 +1553,8 @@ class Article implements Page { $this->mPage->loadPageData( 'fromdbmaster' ); if ( !$this->mPage->exists() ) { $deleteLogPage = new LogPage( 'delete' ); - $outputPage = $this->getContext()->getOutput(); - $outputPage->setPageTitle( wfMessage( 'cannotdelete-title', $title->getPrefixedText() ) ); + $outputPage = $context->getOutput(); + $outputPage->setPageTitle( $context->msg( 'cannotdelete-title', $title->getPrefixedText() ) ); $outputPage->wrapWikiMsg( "
\n$1\n
", array( 'cannotdelete', wfEscapeWikiText( $title->getPrefixedText() ) ) ); @@ -1589,7 +1570,7 @@ class Article implements Page { return; } - $request = $this->getContext()->getRequest(); + $request = $context->getRequest(); $deleteReasonList = $request->getText( 'wpDeleteReasonList', 'other' ); $deleteReason = $request->getText( 'wpReason' ); @@ -1621,7 +1602,7 @@ class Article implements Page { if ( !$reason ) { try { $reason = $this->generateReason( $hasHistory ); - } catch ( MWException $e ) { + } catch ( Exception $e ) { # if a page is horribly broken, we still want to be able to # delete it. So be lenient about errors here. wfDebug( "Error while building auto delete summary: $e" ); @@ -1647,11 +1628,11 @@ class Article implements Page { ); // @todo FIXME: i18n issue/patchwork message - $this->getContext()->getOutput()->addHTML( + $context->getOutput()->addHTML( '' . - wfMessage( 'historywarning' )->numParams( $revisions )->parse() . - wfMessage( 'word-separator' )->plain() . Linker::linkKnown( $title, - wfMessage( 'history' )->escaped(), + $context->msg( 'historywarning' )->numParams( $revisions )->parse() . + $context->msg( 'word-separator' )->escaped() . Linker::linkKnown( $title, + $context->msg( 'history' )->escaped(), array( 'rel' => 'archives' ), array( 'action' => 'history' ) ) . '' @@ -1659,10 +1640,10 @@ class Article implements Page { if ( $title->isBigDeletion() ) { global $wgDeleteRevisionsLimit; - $this->getContext()->getOutput()->wrapWikiMsg( "
\n$1\n
\n", + $context->getOutput()->wrapWikiMsg( "
\n$1\n
\n", array( 'delete-warning-toobig', - $this->getContext()->getLanguage()->formatNum( $wgDeleteRevisionsLimit ) + $context->getLanguage()->formatNum( $wgDeleteRevisionsLimit ) ) ); } @@ -1693,7 +1674,7 @@ class Article implements Page { } $outputPage->addWikiMsg( 'confirmdeletetext' ); - wfRunHooks( 'ArticleConfirmDelete', array( $this, $outputPage, &$reason ) ); + Hooks::run( 'ArticleConfirmDelete', array( $this, $outputPage, &$reason ) ); $user = $this->getContext()->getUser(); @@ -1804,7 +1785,7 @@ class Article implements Page { $outputPage->addWikiMsg( 'deletedtext', wfEscapeWikiText( $deleted ), $loglink ); - wfRunHooks( 'ArticleDeleteAfterSuccess', array( $this->getTitle(), $outputPage ) ); + Hooks::run( 'ArticleDeleteAfterSuccess', array( $this->getTitle(), $outputPage ) ); $outputPage->returnToMain( false ); } else { @@ -1878,7 +1859,7 @@ class Article implements Page { && !$this->mRedirectedFrom && !$this->getTitle()->isRedirect(); // Extension may have reason to disable file caching on some pages. if ( $cacheable ) { - $cacheable = wfRunHooks( 'IsFileCacheable', array( &$this ) ); + $cacheable = Hooks::run( 'IsFileCacheable', array( &$this ) ); } }