diff options
author | Alexandre Emsenhuber <ialex@users.mediawiki.org> | 2011-12-30 16:12:46 +0000 |
---|---|---|
committer | Alexandre Emsenhuber <ialex@users.mediawiki.org> | 2011-12-30 16:12:46 +0000 |
commit | dd2cfee331eba87c915e624ed8c932ba9261376b (patch) | |
tree | c61328956a448d2de57576bad30895c72ea5ed53 | |
parent | 40addf3204629cad7df8132046a866d5d6307c40 (diff) | |
download | mediawikicore-dd2cfee331eba87c915e624ed8c932ba9261376b.tar.gz mediawikicore-dd2cfee331eba87c915e624ed8c932ba9261376b.zip |
* Removed usage of Article where possible in EditPage
* Added Article::getRevisionFetched() and use it in EditPage instead of accessing the member directly
Notes
Notes:
http://mediawiki.org/wiki/Special:Code/MediaWiki/107637
-rw-r--r-- | includes/Article.php | 12 | ||||
-rw-r--r-- | includes/EditPage.php | 42 |
2 files changed, 34 insertions, 20 deletions
diff --git a/includes/Article.php b/includes/Article.php index 2fdcd1a29ee5..f87ca23e3f63 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -357,6 +357,18 @@ class Article extends Page { } /** + * Get the fetched Revision object depending on request parameters or null + * on failure. + * + * @return Revision|null + */ + public function getRevisionFetched() { + $this->fetchContent(); + + return $this->mRevision; + } + + /** * Use this to fetch the rev ID used on page views * * @return int revision ID of last article revision diff --git a/includes/EditPage.php b/includes/EditPage.php index 15eb228546c8..5c6c3829e57b 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -627,7 +627,6 @@ class EditPage { $this->bot = $request->getBool( 'bot', true ); $this->nosummary = $request->getBool( 'nosummary' ); - // @todo FIXME: Unused variable? $this->oldid = $request->getInt( 'oldid' ); $this->live = $request->getCheck( 'live' ); @@ -740,7 +739,7 @@ class EditPage { # Otherwise, $text will be left as-is. if ( !is_null( $undorev ) && !is_null( $oldrev ) && $undorev->getPage() == $oldrev->getPage() && - $undorev->getPage() == $this->mArticle->getID() && + $undorev->getPage() == $this->mTitle->getArticleId() && !$undorev->isDeleted( Revision::DELETED_TEXT ) && !$oldrev->isDeleted( Revision::DELETED_TEXT ) ) { @@ -1166,10 +1165,11 @@ class EditPage { # Article exists. Check for edit conflict. $this->mArticle->clear(); # Force reload of dates, etc. + $timestamp = $this->mArticle->getTimestamp(); - wfDebug( "timestamp: {$this->mArticle->getTimestamp()}, edittime: {$this->edittime}\n" ); + wfDebug( "timestamp: {$timestamp}, edittime: {$this->edittime}\n" ); - if ( $this->mArticle->getTimestamp() != $this->edittime ) { + if ( $timestamp != $this->edittime ) { $this->isConflict = true; if ( $this->section == 'new' ) { if ( $this->mArticle->getUserText() == $wgUser->getName() && @@ -1199,8 +1199,7 @@ class EditPage { } if ( $this->isConflict ) { - wfDebug( __METHOD__ . ": conflict! getting section '$this->section' for time '$this->edittime' (article time '" . - $this->mArticle->getTimestamp() . "')\n" ); + wfDebug( __METHOD__ . ": conflict! getting section '$this->section' for time '$this->edittime' (article time '{$timestamp}')\n" ); $text = $this->mArticle->replaceSection( $this->section, $this->textbox1, $sectionTitle, $this->edittime ); } else { wfDebug( __METHOD__ . ": getting section '$this->section'\n" ); @@ -1383,7 +1382,7 @@ class EditPage { $res = $dbw->select( 'revision', 'rev_user', array( - 'rev_page' => $this->mArticle->getId(), + 'rev_page' => $this->mTitle->getArticleId(), 'rev_timestamp > '.$dbw->addQuotes( $dbw->timestamp($edittime) ) ), __METHOD__, @@ -1706,7 +1705,7 @@ HTML $autosumm = $this->autoSumm ? $this->autoSumm : md5( $this->summary ); $wgOut->addHTML( Html::hidden( 'wpAutoSummary', $autosumm ) ); - $wgOut->addHTML( Html::hidden( 'oldid', $this->mArticle->getOldID() ) ); + $wgOut->addHTML( Html::hidden( 'oldid', $this->oldid ) ); if ( $this->section == 'new' ) { $this->showSummaryInput( true, $this->summary ); @@ -1823,18 +1822,21 @@ HTML $wgOut->addWikiMsg( 'nonunicodebrowser' ); } - if ( $this->section != 'new' && isset( $this->mArticle ) && isset( $this->mArticle->mRevision ) ) { - // Let sysop know that this will make private content public if saved + if ( $this->section != 'new' ) { + $revision = $this->mArticle->getRevisionFetched(); + if ( $revision ) { + // Let sysop know that this will make private content public if saved - if ( !$this->mArticle->mRevision->userCan( Revision::DELETED_TEXT ) ) { - $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", 'rev-deleted-text-permission' ); - } elseif ( $this->mArticle->mRevision->isDeleted( Revision::DELETED_TEXT ) ) { - $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", 'rev-deleted-text-view' ); - } + if ( !$revision->userCan( Revision::DELETED_TEXT ) ) { + $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", 'rev-deleted-text-permission' ); + } elseif ( $revision->isDeleted( Revision::DELETED_TEXT ) ) { + $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", 'rev-deleted-text-view' ); + } - if ( !$this->mArticle->mRevision->isCurrent() ) { - $this->mArticle->setOldSubtitle( $this->mArticle->mRevision->getId() ); - $wgOut->addWikiMsg( 'editingold' ); + if ( !$revision->isCurrent() ) { + $this->mArticle->setOldSubtitle( $revision->getId() ); + $wgOut->addWikiMsg( 'editingold' ); + } } } } @@ -2288,8 +2290,8 @@ HTML */ public function getCancelLink() { $cancelParams = array(); - if ( !$this->isConflict && $this->mArticle->getOldID() > 0 ) { - $cancelParams['oldid'] = $this->mArticle->getOldID(); + if ( !$this->isConflict && $this->oldid > 0 ) { + $cancelParams['oldid'] = $this->oldid; } return Linker::linkKnown( |