Use WikiPage instead of Title to get its id, whether it exists and its latest revision's id

This commit is contained in:
Alexandre Emsenhuber 2012-02-02 09:55:04 +00:00
parent be06bd4560
commit c025d708eb
2 changed files with 5 additions and 5 deletions

View file

@ -112,7 +112,7 @@ class HistoryAction extends FormlessAction {
}
// Fail nicely if article doesn't exist.
if ( !$this->getTitle()->exists() ) {
if ( !$this->page->exists() ) {
$out->addWikiMsg( 'nohistory' );
# show deletion/move log if there is an entry
LogEventsList::showLogExtract(
@ -206,7 +206,7 @@ class HistoryAction extends FormlessAction {
$offsets = array();
}
$page_id = $this->getTitle()->getArticleID();
$page_id = $this->page->getId();
return $dbr->select( 'revision',
Revision::selectFields(),
@ -343,7 +343,7 @@ class HistoryPager extends ReverseChronologicalPager {
'tables' => array( 'revision', 'user' ),
'fields' => array_merge( Revision::selectFields(), Revision::selectUserFields() ),
'conds' => array_merge(
array( 'rev_page' => $this->getTitle()->getArticleID() ),
array( 'rev_page' => $this->getWikiPage()->getId() ),
$this->conds ),
'options' => array( 'USE INDEX' => array( 'revision' => 'page_timestamp' ) ),
'join_conds' => array(
@ -676,7 +676,7 @@ class HistoryPager extends ReverseChronologicalPager {
$cur,
array(),
array(
'diff' => $this->getTitle()->getLatestRevID(),
'diff' => $this->getWikiPage()->getLatest(),
'oldid' => $rev->getId()
)
);

View file

@ -166,7 +166,7 @@ class RawAction extends FormlessAction {
# output previous revision, or nothing if there isn't one
if( !$oldid ) {
# get the current revision so we can get the penultimate one
$oldid = $this->getTitle()->getLatestRevID();
$oldid = $this->page->getLatest();
}
$prev = $this->getTitle()->getPreviousRevisionId( $oldid );
$oldid = $prev ? $prev : -1 ;