r107637 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107636‎ | r107637 | r107638 >
Date:16:12, 30 December 2011
Author:ialex
Status:ok (Comments)
Tags:
Comment:
* Removed usage of Article where possible in EditPage
* Added Article::getRevisionFetched() and use it in EditPage instead of accessing the member directly
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/EditPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Article.php
@@ -357,6 +357,18 @@
358358 }
359359
360360 /**
 361+ * Get the fetched Revision object depending on request parameters or null
 362+ * on failure.
 363+ *
 364+ * @return Revision|null
 365+ */
 366+ public function getRevisionFetched() {
 367+ $this->fetchContent();
 368+
 369+ return $this->mRevision;
 370+ }
 371+
 372+ /**
361373 * Use this to fetch the rev ID used on page views
362374 *
363375 * @return int revision ID of last article revision
Index: trunk/phase3/includes/EditPage.php
@@ -627,7 +627,6 @@
628628 $this->bot = $request->getBool( 'bot', true );
629629 $this->nosummary = $request->getBool( 'nosummary' );
630630
631 - // @todo FIXME: Unused variable?
632631 $this->oldid = $request->getInt( 'oldid' );
633632
634633 $this->live = $request->getCheck( 'live' );
@@ -740,7 +739,7 @@
741740 # Otherwise, $text will be left as-is.
742741 if ( !is_null( $undorev ) && !is_null( $oldrev ) &&
743742 $undorev->getPage() == $oldrev->getPage() &&
744 - $undorev->getPage() == $this->mArticle->getID() &&
 743+ $undorev->getPage() == $this->mTitle->getArticleId() &&
745744 !$undorev->isDeleted( Revision::DELETED_TEXT ) &&
746745 !$oldrev->isDeleted( Revision::DELETED_TEXT ) ) {
747746
@@ -1166,10 +1165,11 @@
11671166 # Article exists. Check for edit conflict.
11681167
11691168 $this->mArticle->clear(); # Force reload of dates, etc.
 1169+ $timestamp = $this->mArticle->getTimestamp();
11701170
1171 - wfDebug( "timestamp: {$this->mArticle->getTimestamp()}, edittime: {$this->edittime}\n" );
 1171+ wfDebug( "timestamp: {$timestamp}, edittime: {$this->edittime}\n" );
11721172
1173 - if ( $this->mArticle->getTimestamp() != $this->edittime ) {
 1173+ if ( $timestamp != $this->edittime ) {
11741174 $this->isConflict = true;
11751175 if ( $this->section == 'new' ) {
11761176 if ( $this->mArticle->getUserText() == $wgUser->getName() &&
@@ -1199,8 +1199,7 @@
12001200 }
12011201
12021202 if ( $this->isConflict ) {
1203 - wfDebug( __METHOD__ . ": conflict! getting section '$this->section' for time '$this->edittime' (article time '" .
1204 - $this->mArticle->getTimestamp() . "')\n" );
 1203+ wfDebug( __METHOD__ . ": conflict! getting section '$this->section' for time '$this->edittime' (article time '{$timestamp}')\n" );
12051204 $text = $this->mArticle->replaceSection( $this->section, $this->textbox1, $sectionTitle, $this->edittime );
12061205 } else {
12071206 wfDebug( __METHOD__ . ": getting section '$this->section'\n" );
@@ -1383,7 +1382,7 @@
13841383 $res = $dbw->select( 'revision',
13851384 'rev_user',
13861385 array(
1387 - 'rev_page' => $this->mArticle->getId(),
 1386+ 'rev_page' => $this->mTitle->getArticleId(),
13881387 'rev_timestamp > '.$dbw->addQuotes( $dbw->timestamp($edittime) )
13891388 ),
13901389 __METHOD__,
@@ -1706,7 +1705,7 @@
17071706 $autosumm = $this->autoSumm ? $this->autoSumm : md5( $this->summary );
17081707 $wgOut->addHTML( Html::hidden( 'wpAutoSummary', $autosumm ) );
17091708
1710 - $wgOut->addHTML( Html::hidden( 'oldid', $this->mArticle->getOldID() ) );
 1709+ $wgOut->addHTML( Html::hidden( 'oldid', $this->oldid ) );
17111710
17121711 if ( $this->section == 'new' ) {
17131712 $this->showSummaryInput( true, $this->summary );
@@ -1823,18 +1822,21 @@
18241823 $wgOut->addWikiMsg( 'nonunicodebrowser' );
18251824 }
18261825
1827 - if ( $this->section != 'new' && isset( $this->mArticle ) && isset( $this->mArticle->mRevision ) ) {
1828 - // Let sysop know that this will make private content public if saved
 1826+ if ( $this->section != 'new' ) {
 1827+ $revision = $this->mArticle->getRevisionFetched();
 1828+ if ( $revision ) {
 1829+ // Let sysop know that this will make private content public if saved
18291830
1830 - if ( !$this->mArticle->mRevision->userCan( Revision::DELETED_TEXT ) ) {
1831 - $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", 'rev-deleted-text-permission' );
1832 - } elseif ( $this->mArticle->mRevision->isDeleted( Revision::DELETED_TEXT ) ) {
1833 - $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", 'rev-deleted-text-view' );
1834 - }
 1831+ if ( !$revision->userCan( Revision::DELETED_TEXT ) ) {
 1832+ $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", 'rev-deleted-text-permission' );
 1833+ } elseif ( $revision->isDeleted( Revision::DELETED_TEXT ) ) {
 1834+ $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", 'rev-deleted-text-view' );
 1835+ }
18351836
1836 - if ( !$this->mArticle->mRevision->isCurrent() ) {
1837 - $this->mArticle->setOldSubtitle( $this->mArticle->mRevision->getId() );
1838 - $wgOut->addWikiMsg( 'editingold' );
 1837+ if ( !$revision->isCurrent() ) {
 1838+ $this->mArticle->setOldSubtitle( $revision->getId() );
 1839+ $wgOut->addWikiMsg( 'editingold' );
 1840+ }
18391841 }
18401842 }
18411843 }
@@ -2288,8 +2290,8 @@
22892291 */
22902292 public function getCancelLink() {
22912293 $cancelParams = array();
2292 - if ( !$this->isConflict && $this->mArticle->getOldID() > 0 ) {
2293 - $cancelParams['oldid'] = $this->mArticle->getOldID();
 2294+ if ( !$this->isConflict && $this->oldid > 0 ) {
 2295+ $cancelParams['oldid'] = $this->oldid;
22942296 }
22952297
22962298 return Linker::linkKnown(

Follow-up revisions

RevisionCommit summaryAuthorDate
r108167Per Nikerabbit, fix for r107637: added @sinceialex19:05, 5 January 2012

Comments

#Comment by Nikerabbit (talk | contribs)   10:07, 5 January 2012

"fetched Revision" doesn't say anything to me. Missing @since.

#Comment by IAlex (talk | contribs)   19:06, 5 January 2012

Added @since in r108167; I choosed the name to be consistent with getRevIdFetched().

Status & tagging log