27use InvalidArgumentException;
35use Wikimedia\Assert\Assert;
54 const SUPPRESSED_ALL = self::DELETED_TEXT | self::DELETED_COMMENT | self::DELETED_USER |
102 Assert::parameterType(
'string|boolean', $dbDomain,
'$dbDomain' );
105 $this->mSlots = $slots;
106 $this->mWiki = $dbDomain;
109 $this->mPageId =
$title->getArticleID();
118 throw new LogicException( __CLASS__ .
' is not serializable.' );
128 if ( $rec === $this ) {
167 public function getContent( $role, $audience = self::FOR_PUBLIC,
User $user =
null ) {
171 if ( !$this->
audienceCan( self::DELETED_TEXT, $audience, $user ) ) {
191 public function getSlot( $role, $audience = self::FOR_PUBLIC,
User $user =
null ) {
192 $slot = $this->mSlots->getSlot( $role );
194 if ( !$this->
audienceCan( self::DELETED_TEXT, $audience, $user ) ) {
209 return $this->mSlots->hasSlot( $role );
219 return $this->mSlots->getSlotRoles();
246 return new RevisionSlots( $this->mSlots->getOriginalSlots() );
261 return new RevisionSlots( $this->mSlots->getInheritedSlots() );
365 public function getUser( $audience = self::FOR_PUBLIC,
User $user =
null ) {
366 if ( !$this->
audienceCan( self::DELETED_USER, $audience, $user ) ) {
391 if ( !$this->
audienceCan( self::DELETED_COMMENT, $audience, $user ) ) {
458 if ( $audience == self::FOR_PUBLIC && $this->
isDeleted( $field ) ) {
460 } elseif ( $audience == self::FOR_THIS_USER ) {
462 throw new InvalidArgumentException(
463 'A User object must be given when checking FOR_THIS_USER audience.'
467 if ( !$this->
userCan( $field, $user ) ) {
509 if ( $bitfield & $field ) {
510 if ( $bitfield & self::DELETED_RESTRICTED ) {
511 $permissions = [
'suppressrevision',
'viewsuppressed' ];
512 } elseif ( $field & self::DELETED_TEXT ) {
513 $permissions = [
'deletedtext' ];
515 $permissions = [
'deletedhistory' ];
521 $permissionlist = implode(
', ', $permissions );
523 wfDebug(
"Checking for $permissionlist due to $field match on $bitfield\n" );
524 foreach ( $permissions as $perm ) {
525 if ( $permissionManager->userHasRight( $user, $perm ) ) {
531 $text =
$title->getPrefixedText();
532 wfDebug(
"Checking for $permissionlist on $text due to $field match on $bitfield\n" );
534 foreach ( $permissions as $perm ) {
535 if ( $permissionManager->userCan( $perm, $user,
$title ) ) {
567 && $this->
getUser( self::RAW ) !==
null
568 && $this->mSlots->getSlotRoles() !== [];
577class_alias( RevisionRecord::class,
'MediaWiki\Storage\RevisionRecord' );
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Represents a title within MediaWiki.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Base interface for content objects.