Go to the documentation of this file.
27 use InvalidArgumentException;
36 use Wikimedia\NonSerializable\NonSerializableTrait;
49 use NonSerializableTrait;
58 public const SUPPRESSED_ALL = self::DELETED_TEXT | self::DELETED_COMMENT | self::DELETED_USER |
106 $this->mPage = $page;
107 $this->mSlots = $slots;
109 $this->mPageId = $this->getArticleId( $page );
119 if ( $rec === $this ) {
156 public function getContent( $role, $audience = self::FOR_PUBLIC, Authority $performer =
null ) {
160 if ( !$this->
audienceCan( self::DELETED_TEXT, $audience, $performer ) ) {
164 $content = $this->
getSlot( $role, $audience, $performer )->getContent();
180 public function getSlot( $role, $audience = self::FOR_PUBLIC, Authority $performer =
null ) {
181 $slot = $this->mSlots->getSlot( $role );
183 if ( !$this->
audienceCan( self::DELETED_TEXT, $audience, $performer ) ) {
198 return $this->mSlots->hasSlot( $role );
208 return $this->mSlots->getSlotRoles();
241 return new RevisionSlots( $this->mSlots->getOriginalSlots() );
256 return new RevisionSlots( $this->mSlots->getInheritedSlots() );
379 public function getUser( $audience = self::FOR_PUBLIC, Authority $performer =
null ) {
380 if ( !$this->
audienceCan( self::DELETED_USER, $audience, $performer ) ) {
403 public function getComment( $audience = self::FOR_PUBLIC, Authority $performer =
null ) {
404 if ( !$this->
audienceCan( self::DELETED_COMMENT, $audience, $performer ) ) {
469 public function audienceCan( $field, $audience, Authority $performer =
null ) {
470 if ( $audience == self::FOR_PUBLIC && $this->
isDeleted( $field ) ) {
472 } elseif ( $audience == self::FOR_THIS_USER ) {
474 throw new InvalidArgumentException(
475 'An Authority object must be given when checking FOR_THIS_USER audience.'
479 if ( !$this->
userCan( $field, $performer ) ) {
499 public function userCan( $field, Authority $performer ) {
519 public static function userCanBitfield( $bitfield, $field, Authority $performer, PageIdentity $page =
null ) {
520 if ( $bitfield & $field ) {
521 if ( $bitfield & self::DELETED_RESTRICTED ) {
522 $permissions = [
'suppressrevision',
'viewsuppressed' ];
523 } elseif ( $field & self::DELETED_TEXT ) {
524 $permissions = [
'deletedtext' ];
526 $permissions = [
'deletedhistory' ];
529 $permissionlist = implode(
', ', $permissions );
530 if ( $page ===
null ) {
531 wfDebug(
"Checking for $permissionlist due to $field match on $bitfield" );
532 return $performer->isAllowedAny( ...$permissions );
534 wfDebug(
"Checking for $permissionlist on $page due to $field match on $bitfield" );
535 foreach ( $permissions as $perm ) {
536 if ( $performer->authorizeRead( $perm, $page ) ) {
568 && $this->
getUser( self::RAW ) !==
null
569 && $this->mSlots->getSlotRoles() !== [];
586 class_alias( RevisionRecord::class,
'MediaWiki\Storage\RevisionRecord' );
Interface for objects (potentially) representing an editable wiki page.
static castFromPageIdentity(?PageIdentity $pageIdentity)
Return a Title for a given PageIdentity.
trait LegacyArticleIdAccess
Convenience trait for conversion to PageIdentity.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Base interface for content objects.
Represents a title within MediaWiki.