$this->insertRedirectEntry( $retval );
return $retval;
}
-
+
/**
* Insert or update the redirect table entry for this page to indicate
* it redirects to $rt .
// recurse through to only get the final target
return $this->getRedirectURL( Title::newFromRedirectRecurse( $text ) );
}
-
+
/**
* Get the Title object or URL to use for a redirect. We use Title
* objects for same-wiki, non-special redirects and URLs for everything
* @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.
$wgOut->setETag( $parserCache->getETag( $this, $parserOptions ) );
}
- # Is is client cached?
+ # Is it client cached?
if ( $wgOut->checkLastModified( $this->getTouched() ) ) {
wfDebug( __METHOD__ . ": done 304\n" );
wfProfileOut( __METHOD__ );
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 );
$outputDone = true;
- break;
+ break;
}
}
}
wfDebug( __METHOD__ . ": showing CSS/JS source\n" );
$this->showCssOrJsPage();
$outputDone = true;
- } else if ( $rt = Title::newFromRedirectArray( $text ) ) {
- wfDebug( __METHOD__ . ": showing redirect=no page\n" );
- # Viewing a redirect page (e.g. with parameter redirect=no)
- # Don't append the subtitle if this was an old revision
- $wgOut->addHTML( $this->viewRedirect( $rt, !$wasRedirected && $this->isCurrent() ) );
- # Parse just to get categories, displaytitle, etc.
- $this->mParserOutput = $wgParser->parse( $text, $this->mTitle, $parserOptions );
- $wgOut->addParserOutputNoText( $this->mParserOutput );
- $outputDone = true;
+ } else {
+ $rt = Title::newFromRedirectArray( $text );
+ if ( $rt ) {
+ wfDebug( __METHOD__ . ": showing redirect=no page\n" );
+ # Viewing a redirect page (e.g. with parameter redirect=no)
+ # Don't append the subtitle if this was an old revision
+ $wgOut->addHTML( $this->viewRedirect( $rt, !$wasRedirected && $this->isCurrent() ) );
+ # Parse just to get categories, displaytitle, etc.
+ $this->mParserOutput = $wgParser->parse( $text, $this->mTitle, $parserOptions );
+ $wgOut->addParserOutputNoText( $this->mParserOutput );
+ $outputDone = true;
+ }
}
break;
case 4:
# Run the parse, protected by a pool counter
wfDebug( __METHOD__ . ": doing uncached parse\n" );
- $this->checkTouched();
$key = $parserCache->getKey( $this, $parserOptions );
- $poolCounter = PoolCounter::factory( 'Article::view', $key );
- $dirtyCallback = $useParserCache ? array( $this, 'tryDirtyCache' ) : false;
- $status = $poolCounter->executeProtected( array( $this, 'doViewParse' ), $dirtyCallback );
+ $poolArticleView = new PoolWorkArticleView( $this, $key, $useParserCache, $parserOptions );
- if ( !$status->isOK() ) {
+ if ( !$poolArticleView->execute() ) {
# Connection or timeout error
- $this->showPoolError( $status );
wfProfileOut( __METHOD__ );
return;
} else {
}
$sk = $wgUser->getSkin();
- $token = $wgUser->editToken();
+ $token = $wgUser->editToken( $rcid );
$wgOut->addHTML(
"<div class='patrollink'>" .
global $wgOut;
$oldid = $this->getOldID();
- $useParserCache = $this->useParserCache( $oldid );
$parserOptions = $this->getParserOptions();
# Render printable version, use printable version cache
if ( !$this->isCurrent() || $wgOut->isPrintable() ) {
$parserOptions->setEditSection( false );
}
-
+
$useParserCache = $this->useParserCache( $oldid );
$this->outputWikiText( $this->getContent(), $useParserCache, $parserOptions );
+
+ return true;
}
/**
global $wgOut;
$parserCache = ParserCache::singleton();
$options = clone $this->getParserOptions();
-
+
if ( $wgOut->isPrintable() ) {
$options->setIsPrintable( true );
$options->setEditSection( false );
}
-
+
$output = $parserCache->getDirty( $this, $options );
if ( $output ) {
}
}
- /**
- * Show an error page for an error from the pool counter.
- * @param $status Status
- */
- public function showPoolError( $status ) {
- global $wgOut;
-
- $wgOut->clearHTML(); // for release() errors
- $wgOut->enableClientCache( false );
- $wgOut->setRobotPolicy( 'noindex,nofollow' );
- $wgOut->addWikiText(
- '<div class="errorbox">' .
- $status->getWikiText( false, 'view-pool-error' ) .
- '</div>'
- );
- }
-
/**
* View redirect
*
}
}
- $imageUrl = $wgStylePath . '/common/images/redirect' . $imageDir . '.png';
- return Html::element( 'img', array( 'src' => $imageUrl, 'alt' => '#REDIRECT' ) ) .
- '<span class="redirectText">' . $link . '</span>';
+ $imageUrl = $wgStylePath . '/common/images/redirect' . $imageDir . '.png';
+ return '<div class="redirectMsg">' .
+ Html::element( 'img', array( 'src' => $imageUrl, 'alt' => '#REDIRECT' ) ) .
+ '<span class="redirectText">' . $link . '</span></div>';
}
/**
}
$tbtext = "";
- while ( $o = $dbr->fetchObject( $tbs ) ) {
+ foreach ( $tbs as $o ) {
$rmvtxt = "";
if ( $wgUser->isAllowed( 'trackback' ) ) {
$form = Html::openElement( 'form', $formParams );
$form .= Xml::submitButton( wfMsg( 'confirm_purge_button' ) );
$form .= Html::closeElement( 'form' );
-
+
$wgOut->addHTML( $form );
$wgOut->addWikiMsg( 'confirm-purge-bottom' );
/**
* Update the page record to point to a newly saved revision.
*
- * @param $dbw Database object
+ * @param $dbw DatabaseBase: object
* @param $revision Revision: For ID number, and text used to set
length and redirect status fields
* @param $lastRevision Integer: if given, will not overwrite the page field
$userAbort = ignore_user_abort( true );
}
- $revisionId = 0;
-
$changed = ( strcmp( $text, $oldtext ) != 0 );
if ( $changed ) {
'parent_id' => $this->mLatest,
'user' => $user->getId(),
'user_text' => $user->getName(),
+ 'timestamp' => $now
) );
$dbw->begin();
# Update recentchanges
if ( !( $flags & EDIT_SUPPRESS_RC ) ) {
# Mark as patrolled if the user can do so
- $patrolled = $wgUseRCPatrol && $this->mTitle->userCan( 'autopatrol' );
+ $patrolled = $wgUseRCPatrol && !count(
+ $this->mTitle->getUserPermissionsErrors( 'autopatrol', $user ) );
# Add RC row to the DB
$rc = RecentChange::notifyEdit( $now, $this->mTitle, $isminor, $user, $summary,
$this->mLatest, $this->getTimestamp(), $bot, '', $oldsize, $newsize,
'text' => $text,
'user' => $user->getId(),
'user_text' => $user->getName(),
- ) );
+ 'timestamp' => $now
+ ) );
$revisionId = $revision->insertOn( $dbw );
$this->mTitle->resetArticleID( $newid );
global $wgUseRCPatrol, $wgUseNPPatrol;
# Mark as patrolled if the user can do so
- $patrolled = ( $wgUseRCPatrol || $wgUseNPPatrol ) && $this->mTitle->userCan( 'autopatrol' );
+ $patrolled = ( $wgUseRCPatrol || $wgUseNPPatrol ) && !count(
+ $this->mTitle->getUserPermissionsErrors( 'autopatrol', $user ) );
# Add RC row to the DB
$rc = RecentChange::notifyNew( $now, $this->mTitle, $isminor, $user, $summary, $bot,
'', strlen( $text ), $revisionId, $patrolled );
# If we haven't been given an rc_id value, we can't do anything
$rcid = (int) $wgRequest->getVal( 'rcid' );
- if ( !$wgUser->matchEditToken( $wgRequest->getVal( 'token' ) ) ) {
+ if ( !$wgUser->matchEditToken( $wgRequest->getVal( 'token' ), $rcid ) ) {
$wgOut->showErrorPage( 'sessionfailure-title', 'sessionfailure' );
return;
}
$id = $this->mTitle->getArticleID();
if ( $id <= 0 ) {
- wfDebug( "updateRestrictions failed: $id <= 0\n" );
+ wfDebug( "updateRestrictions failed: article id $id <= 0\n" );
return false;
}
$protect_description = '';
foreach ( $limit as $action => $restrictions ) {
if ( !isset( $expiry[$action] ) )
- $expiry[$action] = 'infinite';
+ $expiry[$action] = Block::infinity();
$encodedExpiry[$action] = Block::encodeExpiry( $expiry[$action], $dbw );
if ( $restrictions != '' ) {
$authors = array( $row->rev_user_text );
- while ( $row = $db->fetchObject( $res ) ) {
+ foreach ( $res as $row ) {
$authors[] = $row->rev_user_text;
}
</tr>" .
Xml::closeElement( 'table' ) .
Xml::closeElement( 'fieldset' ) .
- Xml::hidden( 'wpEditToken', $wgUser->editToken() ) .
+ Html::hidden( 'wpEditToken', $wgUser->editToken() ) .
Xml::closeElement( 'form' );
if ( $wgUser->isAllowed( 'editinterface' ) ) {
public function doDelete( $reason, $suppress = false ) {
global $wgOut, $wgUser;
- $id = $this->mTitle->getArticleID( GAID_FOR_UPDATE );
+ $id = $this->mTitle->getArticleID( Title::GAID_FOR_UPDATE );
$error = '';
if ( wfRunHooks( 'ArticleDelete', array( &$this, &$wgUser, &$reason, &$error ) ) ) {
$dbw = wfGetDB( DB_MASTER );
$t = $this->mTitle->getDBkey();
- $id = $id ? $id : $this->mTitle->getArticleID( GAID_FOR_UPDATE );
+ $id = $id ? $id : $this->mTitle->getArticleID( Title::GAID_FOR_UPDATE );
if ( $t === '' || $id == 0 ) {
return false;
* Every 100th edit, prune the recent changes table.
*
* @private
- * @param $text New text of the article
- * @param $summary Edit summary
- * @param $minoredit Minor edit
+ * @param $text String: New text of the article
+ * @param $summary String: Edit summary
+ * @param $minoredit Boolean: Minor edit
* @param $timestamp_of_pagechange Timestamp associated with the page change
- * @param $newid rev_id value of the new revision
- * @param $changed Whether or not the content actually changed
+ * @param $newid Integer: rev_id value of the new revision
+ * @param $changed Boolean: Whether or not the content actually changed
*/
public function editUpdates( $text, $summary, $minoredit, $timestamp_of_pagechange, $newid, $changed = true ) {
global $wgDeferredUpdateList, $wgMessageCache, $wgUser, $wgEnableParserCache;
$cacheable = false;
if ( HTMLFileCache::useFileCache() ) {
- $cacheable = $this->getID() && !$this->mRedirectedFrom;
+ $cacheable = $this->getID() && !$this->mRedirectedFrom && !$this->mTitle->isRedirect();
// Extension may have reason to disable file caching on some pages.
if ( $cacheable ) {
$cacheable = wfRunHooks( 'IsFileCacheable', array( &$this ) );
*/
public static function getAutosummary( $oldtext, $newtext, $flags ) {
global $wgContLang;
-
+
# Decide what kind of autosummary is needed.
# Redirect autosummaries
$this->mParserOptions->enableLimitReport();
}
- // Clone to allow modifications of the return value without affecting
+ // Clone to allow modifications of the return value without affecting
// the cache
return clone $this->mParserOptions;
}
*
* @param $parserOutput mixed ParserOptions object, or boolean false
**/
-
protected function doCascadeProtectionUpdates( $parserOutput ) {
if ( !$this->isCurrent() || wfReadOnly() || !$this->mTitle->areRestrictionsCascading() ) {
return;
}
# Get the diff
- # Note that we simulate array_diff_key in PHP <5.0.x
$templates_diff = array_diff_key( $poTemplates, $tlTemplates );
if ( count( $templates_diff ) > 0 ) {
* consider, so it's not appropriate to use there.
*
* @since 1.16 (r52326) for LiquidThreads
- *
+ *
* @param $oldid mixed integer Revision ID or null
*/
public function getParserOutput( $oldid = null ) {
}
}
+
+class PoolWorkArticleView extends PoolCounterWork {
+ private $mArticle;
+
+ function __construct( $article, $key, $useParserCache, $parserOptions ) {
+ parent::__construct( 'ArticleView', $key );
+ $this->mArticle = $article;
+ $this->cacheable = $useParserCache;
+ $this->parserOptions = $parserOptions;
+ }
+
+ function doWork() {
+ return $this->mArticle->doViewParse();
+ }
+
+ function getCachedWork() {
+ global $wgOut;
+
+ $parserCache = ParserCache::singleton();
+ $this->mArticle->mParserOutput = $parserCache->get( $this->mArticle, $this->parserOptions );
+
+ if ( $this->mArticle->mParserOutput !== false ) {
+ wfDebug( __METHOD__ . ": showing contents parsed by someone else\n" );
+ $wgOut->addParserOutput( $this->mArticle->mParserOutput );
+ # Ensure that UI elements requiring revision ID have
+ # the correct version information.
+ $wgOut->setRevisionId( $this->mArticle->getLatest() );
+ return true;
+ }
+ return false;
+ }
+
+ function fallback() {
+ return $this->mArticle->tryDirtyCache();
+ }
+
+ function error( $status ) {
+ global $wgOut;
+
+ $wgOut->clearHTML(); // for release() errors
+ $wgOut->enableClientCache( false );
+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
+
+ $errortext = $status->getWikiText( false, 'view-pool-error' );
+ $wgOut->addWikiText( '<div class="errorbox">' . $errortext . '</div>' );
+
+ return false;
+ }
+}