(Bug 15936) New page's patrol button should always be visible
This commit is contained in:
parent
de2d73876a
commit
d169a9bc8a
3 changed files with 51 additions and 0 deletions
|
|
@ -967,6 +967,13 @@ class Article {
|
||||||
$wgOut->addWikiMsg('anontalkpagetext');
|
$wgOut->addWikiMsg('anontalkpagetext');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Only diffs and new page links from RC give rcid params, so if
|
||||||
|
# we are just viewing the page normally with no rcid, try to find it.
|
||||||
|
# This is more convenient for users.
|
||||||
|
if( empty($rcid) && $this->mTitle->userCan('patrol') ) {
|
||||||
|
$firstRev = $this->mTitle->getFirstRevision();
|
||||||
|
$rcid = $firstRev->isUnpatrolled();
|
||||||
|
}
|
||||||
# If we have been passed an &rcid= parameter, we want to give the user a
|
# If we have been passed an &rcid= parameter, we want to give the user a
|
||||||
# chance to mark this new article as patrolled.
|
# chance to mark this new article as patrolled.
|
||||||
if( !empty($rcid) && $this->mTitle->exists() && $this->mTitle->userCan('patrol') ) {
|
if( !empty($rcid) && $this->mTitle->exists() && $this->mTitle->userCan('patrol') ) {
|
||||||
|
|
|
||||||
|
|
@ -363,6 +363,7 @@ class Revision {
|
||||||
} else {
|
} else {
|
||||||
throw new MWException( 'Revision constructor passed invalid row format.' );
|
throw new MWException( 'Revision constructor passed invalid row format.' );
|
||||||
}
|
}
|
||||||
|
$this->mUnpatrolled = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
|
|
@ -536,6 +537,27 @@ class Revision {
|
||||||
public function isMinor() {
|
public function isMinor() {
|
||||||
return (bool)$this->mMinorEdit;
|
return (bool)$this->mMinorEdit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int rcid of the unpatrolled row, zero if there isn't one
|
||||||
|
*/
|
||||||
|
public function isUnpatrolled() {
|
||||||
|
if( $this->mUnpatrolled !== NULL ) {
|
||||||
|
return $this->mUnpatrolled;
|
||||||
|
}
|
||||||
|
$dbr = wfGetDB( DB_SLAVE );
|
||||||
|
$this->mUnpatrolled = $dbr->selectField( 'recentchanges',
|
||||||
|
'rc_id',
|
||||||
|
array( // Add redundant user,timestamp condition so we can use the existing index
|
||||||
|
'rc_user_text' => $this->getRawUserText(),
|
||||||
|
'rc_timestamp' => $dbr->timestamp( $this->getTimestamp() ),
|
||||||
|
'rc_this_oldid' => $this->getId(),
|
||||||
|
'rc_patrolled' => 0
|
||||||
|
),
|
||||||
|
__METHOD__
|
||||||
|
);
|
||||||
|
return (int)$this->mUnpatrolled;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* int $field one of DELETED_* bitfield constants
|
* int $field one of DELETED_* bitfield constants
|
||||||
|
|
|
||||||
|
|
@ -3033,6 +3033,28 @@ class Title {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the first revision of the page
|
||||||
|
*
|
||||||
|
* @param $flags \type{\int} GAID_FOR_UPDATE
|
||||||
|
* @return Revision (or NULL if page doesn't exist)
|
||||||
|
*/
|
||||||
|
public function getFirstRevision( $flags=0 ) {
|
||||||
|
$db = ($flags & GAID_FOR_UPDATE) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
|
||||||
|
$pageId = $this->getArticleId($flags);
|
||||||
|
if( !$pageId ) return NULL;
|
||||||
|
$row = $db->selectRow( 'revision', '*',
|
||||||
|
array( 'rev_page' => $pageId ),
|
||||||
|
__METHOD__,
|
||||||
|
array( 'ORDER BY' => 'rev_timestamp ASC', 'LIMIT' => 1 )
|
||||||
|
);
|
||||||
|
if( !$row ) {
|
||||||
|
return NULL;
|
||||||
|
} else {
|
||||||
|
return new Revision( $row );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if this is a new page
|
* Check if this is a new page
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue