MediaWiki REL1_40
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 $this->mSize ??= $this->mSlots->computeSize();
122
123 return $this->mSize;
124 }
125
130 public function getSha1() {
131 // If hash is null, calculate it and remember (potentially SLOW!)
132 // This is for compatibility with old database rows that don't have the field set.
133 $this->mSha1 ??= $this->mSlots->computeSha1();
134
135 return $this->mSha1;
136 }
137
144 public function getUser( $audience = self::FOR_PUBLIC, Authority $performer = null ) {
145 // overwritten just to add a guarantee to the contract
146 return parent::getUser( $audience, $performer );
147 }
148
155 public function getComment( $audience = self::FOR_PUBLIC, Authority $performer = null ) {
156 // overwritten just to add a guarantee to the contract
157 return parent::getComment( $audience, $performer );
158 }
159
163 public function getTimestamp() {
164 // overwritten just to add a guarantee to the contract
165 return parent::getTimestamp();
166 }
167
173 public function isReadyForInsertion() {
174 return true;
175 }
176
177}
Library for creating and parsing MW-style timestamps.
Value object for a comment stored by CommentStore.
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.