MediaWiki REL1_37
RevisionArchiveRecord.php
Go to the documentation of this file.
1<?php
23namespace MediaWiki\Revision;
24
29use MWTimestamp;
30use stdClass;
31use Wikimedia\Assert\Assert;
32
43
47 protected $mArchiveId;
48
61 public function __construct(
62 PageIdentity $page,
63 UserIdentity $user,
64 CommentStoreComment $comment,
65 stdClass $row,
66 RevisionSlots $slots,
67 $wikiId = self::LOCAL
68 ) {
69 parent::__construct( $page, $slots, $wikiId );
70
71 $timestamp = MWTimestamp::convert( TS_MW, $row->ar_timestamp );
72 Assert::parameter( is_string( $timestamp ), '$row->rev_timestamp', 'must be a valid timestamp' );
73
74 $this->mArchiveId = intval( $row->ar_id );
75
76 // NOTE: ar_page_id may be different from $this->mPage->getId() in some cases,
77 // notably when a partially restored page has been moved, and a new page has been created
78 // with the same title. Archive rows for that title will then have the wrong page id.
79 $this->mPageId = isset( $row->ar_page_id ) ? intval( $row->ar_page_id ) : $this->getArticleId( $this->mPage );
80
81 // NOTE: ar_parent_id = 0 indicates that there is no parent revision, while null
82 // indicates that the parent revision is unknown. As per MW 1.31, the database schema
83 // allows ar_parent_id to be NULL.
84 $this->mParentId = isset( $row->ar_parent_id ) ? intval( $row->ar_parent_id ) : null;
85 $this->mId = isset( $row->ar_rev_id ) ? intval( $row->ar_rev_id ) : null;
86 $this->mComment = $comment;
87 $this->mUser = $user;
88 $this->mTimestamp = $timestamp;
89 $this->mMinorEdit = boolval( $row->ar_minor_edit );
90 $this->mDeleted = intval( $row->ar_deleted );
91 $this->mSize = isset( $row->ar_len ) ? intval( $row->ar_len ) : null;
92 $this->mSha1 = !empty( $row->ar_sha1 ) ? $row->ar_sha1 : null;
93 }
94
100 public function getArchiveId() {
101 return $this->mArchiveId;
102 }
103
109 public function getId( $wikiId = self::LOCAL ) {
110 // overwritten just to refine the contract specification.
111 return parent::getId( $wikiId );
112 }
113
118 public function getSize() {
119 // If length is null, calculate and remember it (potentially SLOW!).
120 // This is for compatibility with old database rows that don't have the field set.
121 if ( $this->mSize === null ) {
122 $this->mSize = $this->mSlots->computeSize();
123 }
124
125 return $this->mSize;
126 }
127
132 public function getSha1() {
133 // If hash is null, calculate it and remember (potentially SLOW!)
134 // This is for compatibility with old database rows that don't have the field set.
135 if ( $this->mSha1 === null ) {
136 $this->mSha1 = $this->mSlots->computeSha1();
137 }
138
139 return $this->mSha1;
140 }
141
148 public function getUser( $audience = self::FOR_PUBLIC, Authority $performer = null ) {
149 // overwritten just to add a guarantee to the contract
150 return parent::getUser( $audience, $performer );
151 }
152
159 public function getComment( $audience = self::FOR_PUBLIC, Authority $performer = null ) {
160 // overwritten just to add a guarantee to the contract
161 return parent::getComment( $audience, $performer );
162 }
163
167 public function getTimestamp() {
168 // overwritten just to add a guarantee to the contract
169 return parent::getTimestamp();
170 }
171
177 public function isReadyForInsertion() {
178 return true;
179 }
180
181}
182
187class_alias( RevisionArchiveRecord::class, 'MediaWiki\Storage\RevisionArchiveRecord' );
Value object for a comment stored by CommentStore.
Library for creating and parsing MW-style timestamps.
A RevisionRecord representing a revision of a deleted page persisted in the archive table.
__construct(PageIdentity $page, UserIdentity $user, CommentStoreComment $comment, stdClass $row, RevisionSlots $slots, $wikiId=self::LOCAL)
getComment( $audience=self::FOR_PUBLIC, Authority $performer=null)
getUser( $audience=self::FOR_PUBLIC, Authority $performer=null)
Page revision base class.
string false $wikiId
Wiki ID; false means the current wiki.
Value object representing the set of slots belonging to a revision.
Interface for objects (potentially) representing an editable wiki page.
This interface represents the authority associated the current execution context, such as a web reque...
Definition Authority.php:37
Interface for objects representing user identity.