26 use InvalidArgumentException;
30 use Wikimedia\Assert\Assert;
65 parent::__construct(
$title, $slots, $wikiId );
66 Assert::parameterType(
'object', $row,
'$row' );
68 $this->mId = intval( $row->rev_id );
69 $this->mPageId = intval( $row->rev_page );
70 $this->mComment = $comment;
72 $timestamp =
wfTimestamp( TS_MW, $row->rev_timestamp );
73 Assert::parameter( is_string( $timestamp ),
'$row->rev_timestamp',
'must be a valid timestamp' );
76 $this->mMinorEdit = boolval( $row->rev_minor_edit );
77 $this->mTimestamp = $timestamp;
78 $this->mDeleted = intval( $row->rev_deleted );
83 $this->mParentId = isset( $row->rev_parent_id ) ? intval( $row->rev_parent_id ) :
null;
84 $this->mSize = isset( $row->rev_len ) ? intval( $row->rev_len ) :
null;
85 $this->mSha1 = !empty( $row->rev_sha1 ) ? $row->rev_sha1 :
null;
91 if ( isset( $row->page_latest ) ) {
92 $this->mCurrent = ( $row->rev_id == $row->page_latest );
97 $this->mPageId && $this->mTitle->exists()
98 && $this->mPageId !== $this->mTitle->getArticleID()
100 throw new InvalidArgumentException(
101 'The given Title does not belong to page ID ' . $this->mPageId .
102 ' but actually belongs to ' . $this->mTitle->getArticleID()
124 if ( $this->
isCurrent() && $field === self::DELETED_TEXT ) {
131 return parent::isDeleted( $field );
135 if ( $this->
isCurrent() && $field === self::DELETED_TEXT ) {
142 return parent::userCan( $field,
$user );
150 return parent::getId();
160 if ( $this->mSize ===
null ) {
161 $this->mSize = $this->mSlots->computeSize();
174 if ( $this->mSha1 ===
null ) {
175 $this->mSha1 = $this->mSlots->computeSha1();
189 return parent::getUser( $audience,
$user );
200 return parent::getComment( $audience,
$user );
208 return parent::getTimestamp();