MediaWiki master
RevisionStoreCacheRecord.php
Go to the documentation of this file.
1<?php
9namespace MediaWiki\Revision;
10
15
24
28 private $mCallback;
29
45 public function __construct(
46 callable $callback,
47 PageIdentity $page,
48 UserIdentity $user,
49 CommentStoreComment $comment,
50 $row,
51 RevisionSlots $slots,
52 $wikiID = self::LOCAL
53 ) {
54 parent::__construct( $page, $user, $comment, $row, $slots, $wikiID );
55 $this->mCallback = $callback;
56 }
57
63 public function getVisibility() {
64 if ( $this->mCallback ) {
65 $this->loadFreshRow();
66 }
67 return parent::getVisibility();
68 }
69
78 public function getUser( $audience = self::FOR_PUBLIC, ?Authority $performer = null ) {
79 if ( $this->mCallback ) {
80 $this->loadFreshRow();
81 }
82 return parent::getUser( $audience, $performer );
83 }
84
98 private function loadFreshRow() {
99 [ $freshRevDeleted, $freshUser ] = ( $this->mCallback )( $this->mId );
100
101 // Set to null to ensure we do not make unnecessary queries for subsequent getter calls,
102 // and to allow the closure to be freed.
103 $this->mCallback = null;
104
105 if ( $freshRevDeleted !== null && $freshUser !== null ) {
106 $this->mDeleted = intval( $freshRevDeleted );
107 $this->mUser = $freshUser;
108 } else {
109 throw new RevisionAccessException(
110 'Unable to load fresh row for rev_id: {rev_id}',
111 [ 'rev_id' => $this->mId ]
112 );
113 }
114 }
115
116}
Value object for a comment stored by CommentStore.
Value object representing the set of slots belonging to a revision.
getUser( $audience=self::FOR_PUBLIC, ?Authority $performer=null)
Overridden to ensure that we return a fresh value and not a cached one.
__construct(callable $callback, PageIdentity $page, UserIdentity $user, CommentStoreComment $comment, $row, RevisionSlots $slots, $wikiID=self::LOCAL)
getVisibility()
Overridden to ensure that we return a fresh value and not a cached one.
A RevisionRecord representing an existing revision persisted in the revision table.
Interface for objects (potentially) representing an editable wiki page.
This interface represents the authority associated with the current execution context,...
Definition Authority.php:23
Interface for objects representing user identity.