r79874 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79873‎ | r79874 | r79875 >
Date:20:07, 8 January 2011
Author:ialex
Status:deferred (Comments)
Tags:
Comment:
Only set $mUser, $mUserText, $mComment and $mTimestamp fields in fetchContent() if we have loaded the latests revision
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Article.php
@@ -551,10 +551,9 @@
552552 // We should instead work with the Revision object when we need it...
553553 $this->mContent = $revision->getText( Revision::FOR_THIS_USER ); // Loads if user is allowed
554554
555 - $this->mUser = $revision->getUser();
556 - $this->mUserText = $revision->getUserText();
557 - $this->mComment = $revision->getComment();
558 - $this->mTimestamp = wfTimestamp( TS_MW, $revision->getTimestamp() );
 555+ if ( $revision->getId() == $this->mLatest ) {
 556+ $this->setLastEdit( $revision );
 557+ }
559558
560559 $this->mRevIdFetched = $revision->getId();
561560 $this->mContentLoaded = true;
@@ -705,18 +704,26 @@
706705 return;
707706 }
708707
709 - $this->mLastRevision = Revision::loadFromPageId( wfGetDB( DB_MASTER ), $id );
710 - if ( !is_null( $this->mLastRevision ) ) {
711 - $this->mUser = $this->mLastRevision->getUser();
712 - $this->mUserText = $this->mLastRevision->getUserText();
713 - $this->mTimestamp = $this->mLastRevision->getTimestamp();
714 - $this->mComment = $this->mLastRevision->getComment();
715 - $this->mMinorEdit = $this->mLastRevision->isMinor();
716 - $this->mRevIdFetched = $this->mLastRevision->getId();
 708+ $revision = Revision::loadFromPageId( wfGetDB( DB_MASTER ), $id );
 709+ if ( !is_null( $revision ) ) {
 710+ $this->setLastEdit( $revision );
717711 }
718712 }
719713
720714 /**
 715+ * Set the lastest revision
 716+ */
 717+ protected function setLastEdit( Revision $revision ) {
 718+ $this->mLastRevision = $revision;
 719+ $this->mUser = $revision->getUser();
 720+ $this->mUserText = $revision->getUserText();
 721+ $this->mTimestamp = $revision->getTimestamp();
 722+ $this->mComment = $revision->getComment();
 723+ $this->mMinorEdit = $revision->isMinor();
 724+ $this->mRevIdFetched = $revision->getId();
 725+ }
 726+
 727+ /**
721728 * @return string GMT timestamp of last article revision
722729 **/
723730

Follow-up revisions

RevisionCommit summaryAuthorDate
r79887Fix typo from r79874ialex11:48, 9 January 2011
r79906Fix for r79874: only set $mRevIdFetched from fetchContent(), it was overriden...ialex17:41, 9 January 2011
r86329* (bug 28592) Wrong timestamp were displayed in old revisionsialex17:59, 18 April 2011

Comments

#Comment by Aaron Schulz (talk | contribs)   20:42, 8 January 2011

I was tempted to do something like this a few weeks ago, but was worried about callers that might rely on the old behavior.

#Comment by IAlex (talk | contribs)   11:25, 9 January 2011

The documentations says that the accessor methods return data of the latest revision. Also Article::getContributors() is using them which could return in incorrect result (this is not the case since it's never called when this happens).

#Comment by Nikerabbit (talk | contribs)   10:46, 9 January 2011

 

+        * Set the lastest revision

Latest? I think the function name is misleading, were not setting what is the latest edit/revision for this page, but extracting the fields of the last revision.

#Comment by MaxSem (talk | contribs)   17:48, 18 April 2011

Causes bug 28592.

Status & tagging log