27use InvalidArgumentException;
35use Wikimedia\Assert\Assert;
54 public 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();
252 return new RevisionSlots( $this->mSlots->getOriginalSlots() );
267 return new RevisionSlots( $this->mSlots->getInheritedSlots() );
371 public function getUser( $audience = self::FOR_PUBLIC,
User $user =
null ) {
372 if ( !$this->
audienceCan( self::DELETED_USER, $audience, $user ) ) {
397 if ( !$this->
audienceCan( self::DELETED_COMMENT, $audience, $user ) ) {
464 if ( $audience == self::FOR_PUBLIC && $this->
isDeleted( $field ) ) {
466 } elseif ( $audience == self::FOR_THIS_USER ) {
468 throw new InvalidArgumentException(
469 'A User object must be given when checking FOR_THIS_USER audience.'
473 if ( !$this->
userCan( $field, $user ) ) {
515 if ( $bitfield & $field ) {
516 if ( $bitfield & self::DELETED_RESTRICTED ) {
517 $permissions = [
'suppressrevision',
'viewsuppressed' ];
518 } elseif ( $field & self::DELETED_TEXT ) {
519 $permissions = [
'deletedtext' ];
521 $permissions = [
'deletedhistory' ];
527 $permissionlist = implode(
', ', $permissions );
529 wfDebug(
"Checking for $permissionlist due to $field match on $bitfield" );
530 foreach ( $permissions as $perm ) {
531 if ( $permissionManager->userHasRight( $user, $perm ) ) {
537 $text =
$title->getPrefixedText();
538 wfDebug(
"Checking for $permissionlist on $text due to $field match on $bitfield" );
540 foreach ( $permissions as $perm ) {
541 if ( $permissionManager->userCan( $perm, $user,
$title ) ) {
573 && $this->
getUser( self::RAW ) !==
null
574 && $this->mSlots->getSlotRoles() !== [];
592class_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.