I'm not 100% sure this is the right thing to do, see the bug for the details. But basically this doesn't include an edit in the count if its text is hidden and its hidden from admins. (Not sure if it should not be included only if everything is hidden). Its also weird to show people different things depending if they have suppress rights, without really indicating that.
Minor db note: This causes the query to no longer use a covering index. I don't think that matters but just thought i'd mention.
p.s. The upload page show deleted edits link is broken right now, (from before) I'll fix in a follow-up.
environments
* (bug 14977) Fixed $wgServer detection in cases where an IPv6 address is used
as the server name.
+* (bug 19725) Do not list suppressed edits in the "View X deleted edits" link
+ if user cannot view suppressed edits.
=== API changes in 1.18 ===
* (bug 26339) Throw warning when truncating an overlarge API result.
if ( $this->getContext()->getUser()->isAllowed( 'deletedhistory' ) &&
( $this->getTitle()->getArticleId() == 0 || $action == 'history' ) ) {
- $n = $this->getTitle()->isDeleted();
+
+ $includeSuppressed = $this->getContext()->getUser()->isAllowed( 'suppressrevision' );
+ $n = $this->getTitle()->isDeleted( $includeSuppressed );
if ( $n ) {
if ( $this->getContext()->getUser()->isAllowed( 'undelete' ) ) {
} else {
// article doesn't exist or is deleted
if ( $wgUser->isAllowed( 'deletedhistory' ) ) {
- $n = $title->isDeleted();
+ $includeSuppressed = $wgUser->isAllowed( 'suppressrevision' );
+ $n = $title->isDeleted( $includeSuppressed );
if( $n ) {
$undelTitle = SpecialPage::getTitleFor( 'Undelete' );
// If the user can't undelete but can view deleted history show them a "View .. deleted" tab instead
/**
* Is there a version of this page in the deletion archive?
*
+ * @param $includeSuppressed Boolean Include suppressed revisions?
* @return Int the number of archived revisions
*/
- public function isDeleted() {
+ public function isDeleted( $includeSuppressed = false ) {
if ( $this->getNamespace() < 0 ) {
$n = 0;
} else {
$dbr = wfGetDB( DB_SLAVE );
+ $conditions = array( 'ar_namespace' => $this->getNamespace(), 'ar_title' => $this->getDBkey() );
+
+ if( !$includeSuppressed ) {
+ $suppressedTextBits = REVISION::DELETED_TEXT | REVISION::DELETED_RESTRICTED;
+ $conditions[] = $dbr->bitAnd('ar_deleted', $suppressedTextBits ) .
+ ' != ' . $suppressedTextBits;
+ }
+
$n = $dbr->selectField( 'archive', 'COUNT(*)',
- array( 'ar_namespace' => $this->getNamespace(), 'ar_title' => $this->getDBkey() ),
+ $conditions,
__METHOD__
);
if ( $this->getNamespace() == NS_FILE ) {
- $n += $dbr->selectField( 'filearchive', 'COUNT(*)',
- array( 'fa_name' => $this->getDBkey() ),
+ $fconditions = array( 'fa_name' => $this->getDBkey() );
+ if( !$includeSuppressed ) {
+ $suppressedTextBits = FILE::DELETED_FILE | FILE::DELETED_RESTRICTED;
+ $fconditions[] = $dbr->bitAnd('fa_deleted', $suppressedTextBits ) .
+ ' != ' . $suppressedTextBits;
+ }
+
+ $n += $dbr->selectField( 'filearchive',
+ 'COUNT(*)',
+ $fconditions,
__METHOD__
);
}
* @return ResultWrapper
*/
public static function listPagesByPrefix( $prefix ) {
+ global $wgUser;
$dbr = wfGetDB( DB_SLAVE );
$title = Title::newFromText( $prefix );
'ar_namespace' => $ns,
'ar_title' . $dbr->buildLike( $prefix, $dbr->anyString() ),
);
+
+ // bug 19725
+ $suppressedText = REVISION::DELETED_TEXT | REVISION::DELETED_RESTRICTED;
+ if( !$wgUser->isAllowed( 'suppressrevision' ) ) {
+ $conds[] = $dbr->bitAnd('ar_deleted', $suppressedText ) .
+ ' != ' . $suppressedText;
+ }
return self::listPages( $dbr, $conds );
}
$title = Title::makeTitleSafe( NS_FILE, $this->mDesiredDestName );
// Show a subtitle link to deleted revisions (to sysops et al only)
if( $title instanceof Title ) {
- $count = $title->isDeleted();
- if ( $count > 0 && $wgUser->isAllowed( 'deletedhistory' ) ) {
- $link = wfMsgExt(
- $wgUser->isAllowed( 'delete' ) ? 'thisisdeleted' : 'viewdeleted',
- array( 'parse', 'replaceafter' ),
- $this->getSkin()->linkKnown(
- SpecialPage::getTitleFor( 'Undelete', $title->getPrefixedText() ),
- wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $count )
- )
- );
- $wgOut->addHTML( "<div id=\"contentSub2\">{$link}</div>" );
+ if ( $wgUser->isAllowed( 'deletedhistory' ) ) {
+ $canViewSuppress = $wgUser->isAllowed( 'suppressrevision' );
+ $count = $title->isDeleted( $canViewSuppress );
+ if ( $count > 0 ) {
+ $link = wfMsgExt(
+ $wgUser->isAllowed( 'delete' ) ? 'thisisdeleted' : 'viewdeleted',
+ array( 'parse', 'replaceafter' ),
+ $this->getSkin()->linkKnown(
+ SpecialPage::getTitleFor( 'Undelete', $title->getPrefixedText() ),
+ wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $count )
+ )
+ );
+ $wgOut->addHTML( "<div id=\"contentSub2\">{$link}</div>" );
+ }
}
}