Merge "Hard deprecate Revision::userCanBitfield"
This commit is contained in:
commit
0d26fc6930
6 changed files with 66 additions and 14 deletions
|
|
@ -495,7 +495,8 @@ because of Phabricator reports.
|
|||
* AuthManager::singleton() has been deprecated. Use
|
||||
MediaWikiServices::getInstance()->getAuthManager() instead.
|
||||
* The following functions all accept an optional user parameter. Not passing a
|
||||
user is deprecated, and support for not passing a user will be remove in 1.36:
|
||||
user is hard deprecated, and support for calling them without passing a user
|
||||
will be removed in 1.36:
|
||||
- Title::getNotificationTimestamp
|
||||
- Revision::newNullRevision
|
||||
- WikiPage::insertProtectNullRevision
|
||||
|
|
@ -505,6 +506,10 @@ because of Phabricator reports.
|
|||
- LogEventsList::userCanViewLogType
|
||||
- LogPage::addEntry
|
||||
- FileDeleteForm::doDelete
|
||||
Additionally, not passing a user to the following is soft deprecated:
|
||||
- Revision::userCan
|
||||
- ArchivedFile::userCan
|
||||
- OldLocalFile::userCan
|
||||
* Article::insertProtectNullRevision is deprecated. Instead, use
|
||||
WikiPage::insertProtectNullRevision.
|
||||
* The SpecialPageFactory class was moved from the MediaWiki\Special namespace
|
||||
|
|
@ -515,6 +520,9 @@ because of Phabricator reports.
|
|||
* All methods of the old SpecialPageFactory, deprecated in 1.32, were hard
|
||||
deprecated. Instead, get a SpecialPageFactory from MediaWikiServices and
|
||||
use its methods.
|
||||
* Revision::userCanBitfield was soft deprecated along with the whole Revision
|
||||
class in 1.31. ::userCanBitfield was individually hard deprecated; use
|
||||
RevisionRecord::userCanBitfield instead.
|
||||
* …
|
||||
|
||||
=== Other changes in 1.35 ===
|
||||
|
|
|
|||
|
|
@ -1019,11 +1019,16 @@ class Revision implements IDBAccessObject {
|
|||
* @param int $field One of self::DELETED_TEXT,
|
||||
* self::DELETED_COMMENT,
|
||||
* self::DELETED_USER
|
||||
* @param User|null $user User object to check, or null to use $wgUser
|
||||
* @param User|null $user User object to check, or null to use $wgUser (deprecated since 1.35)
|
||||
* @return bool
|
||||
*/
|
||||
public function userCan( $field, User $user = null ) {
|
||||
return self::userCanBitfield( $this->getVisibility(), $field, $user );
|
||||
if ( !$user ) {
|
||||
// TODO check callers and hard deprecate
|
||||
global $wgUser;
|
||||
$user = $wgUser;
|
||||
}
|
||||
return RevisionRecord::userCanBitfield( $this->getVisibility(), $field, $user );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1043,9 +1048,9 @@ class Revision implements IDBAccessObject {
|
|||
public static function userCanBitfield( $bitfield, $field, User $user = null,
|
||||
Title $title = null
|
||||
) {
|
||||
global $wgUser;
|
||||
|
||||
wfDeprecated( __METHOD__, '1.31' );
|
||||
if ( !$user ) {
|
||||
global $wgUser;
|
||||
$user = $wgUser;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -307,7 +307,11 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
|
|||
$rev['userhidden'] = true;
|
||||
$anyHidden = true;
|
||||
}
|
||||
if ( Revision::userCanBitfield( $row->ar_deleted, RevisionRecord::DELETED_USER, $user ) ) {
|
||||
if ( RevisionRecord::userCanBitfield(
|
||||
$row->ar_deleted,
|
||||
RevisionRecord::DELETED_USER,
|
||||
$user
|
||||
) ) {
|
||||
if ( $fld_user ) {
|
||||
$rev['user'] = $row->ar_user_text;
|
||||
}
|
||||
|
|
@ -322,7 +326,11 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
|
|||
$rev['commenthidden'] = true;
|
||||
$anyHidden = true;
|
||||
}
|
||||
if ( Revision::userCanBitfield( $row->ar_deleted, RevisionRecord::DELETED_COMMENT, $user ) ) {
|
||||
if ( RevisionRecord::userCanBitfield(
|
||||
$row->ar_deleted,
|
||||
RevisionRecord::DELETED_COMMENT,
|
||||
$user
|
||||
) ) {
|
||||
$comment = $commentStore->getComment( 'ar_comment', $row )->text;
|
||||
if ( $fld_comment ) {
|
||||
$rev['comment'] = $comment;
|
||||
|
|
@ -345,7 +353,11 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
|
|||
$rev['sha1hidden'] = true;
|
||||
$anyHidden = true;
|
||||
}
|
||||
if ( Revision::userCanBitfield( $row->ar_deleted, RevisionRecord::DELETED_TEXT, $user ) ) {
|
||||
if ( RevisionRecord::userCanBitfield(
|
||||
$row->ar_deleted,
|
||||
RevisionRecord::DELETED_TEXT,
|
||||
$user
|
||||
) ) {
|
||||
if ( $row->ar_sha1 != '' ) {
|
||||
$rev['sha1'] = Wikimedia\base_convert( $row->ar_sha1, 36, 16, 40 );
|
||||
} else {
|
||||
|
|
@ -358,7 +370,11 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
|
|||
$rev['texthidden'] = true;
|
||||
$anyHidden = true;
|
||||
}
|
||||
if ( Revision::userCanBitfield( $row->ar_deleted, RevisionRecord::DELETED_TEXT, $user ) ) {
|
||||
if ( RevisionRecord::userCanBitfield(
|
||||
$row->ar_deleted,
|
||||
RevisionRecord::DELETED_TEXT,
|
||||
$user
|
||||
) ) {
|
||||
ApiResult::setContentValue( $rev, 'text',
|
||||
$revisionStore->newRevisionFromArchiveRow( $row )
|
||||
->getContent( SlotRecord::MAIN )->serialize() );
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Revision\RevisionRecord;
|
||||
|
||||
/**
|
||||
* Class representing a row of the 'filearchive' table
|
||||
|
|
@ -578,13 +579,24 @@ class ArchivedFile {
|
|||
* Determine if the current user is allowed to view a particular
|
||||
* field of this FileStore image file, if it's marked as deleted.
|
||||
* @param int $field
|
||||
* @param null|User $user User object to check, or null to use $wgUser
|
||||
* @param null|User $user User object to check, or null to use $wgUser (deprecated since 1.35)
|
||||
* @return bool
|
||||
*/
|
||||
public function userCan( $field, User $user = null ) {
|
||||
$this->load();
|
||||
|
||||
$title = $this->getTitle();
|
||||
return Revision::userCanBitfield( $this->deleted, $field, $user, $title ?: null );
|
||||
|
||||
if ( !$user ) {
|
||||
// TODO check callers and hard deprecate
|
||||
global $wgUser;
|
||||
$user = $wgUser;
|
||||
}
|
||||
|
||||
return RevisionRecord::userCanBitfield(
|
||||
$this->deleted,
|
||||
$field,
|
||||
$user,
|
||||
$title ?: null
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Revision\RevisionRecord;
|
||||
|
||||
/**
|
||||
* Class to represent a file in the oldimage table
|
||||
|
|
@ -353,13 +354,22 @@ class OldLocalFile extends LocalFile {
|
|||
* field of this image file, if it's marked as deleted.
|
||||
*
|
||||
* @param int $field
|
||||
* @param User|null $user User object to check, or null to use $wgUser
|
||||
* @param User|null $user User object to check, or null to use $wgUser (deprecated since 1.35)
|
||||
* @return bool
|
||||
*/
|
||||
function userCan( $field, User $user = null ) {
|
||||
$this->load();
|
||||
|
||||
return Revision::userCanBitfield( $this->deleted, $field, $user );
|
||||
if ( !$user ) {
|
||||
// TODO check callers and hard deprecate
|
||||
global $wgUser;
|
||||
$user = $wgUser;
|
||||
}
|
||||
return RevisionRecord::userCanBitfield(
|
||||
$this->deleted,
|
||||
$field,
|
||||
$user
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1540,6 +1540,7 @@ abstract class RevisionDbTestBase extends MediaWikiTestCase {
|
|||
* @covers Revision::userCanBitfield
|
||||
*/
|
||||
public function testUserCanBitfield( $bitField, $field, $userGroups, $title, $expected ) {
|
||||
$this->hideDeprecated( 'Revision::userCanBitfield' );
|
||||
$title = Title::newFromText( $title );
|
||||
|
||||
$this->setGroupPermissions(
|
||||
|
|
|
|||
Loading…
Reference in a new issue