MediaWiki master
RevisionStoreCacheRecord.php
Go to the documentation of this file.
1<?php
23namespace MediaWiki\Revision;
24
29
38
42 private $mCallback;
43
58 public function __construct(
59 callable $callback,
60 PageIdentity $page,
61 UserIdentity $user,
62 CommentStoreComment $comment,
63 $row,
64 RevisionSlots $slots,
65 $wikiID = self::LOCAL
66 ) {
67 parent::__construct( $page, $user, $comment, $row, $slots, $wikiID );
68 $this->mCallback = $callback;
69 }
70
76 public function getVisibility() {
77 if ( $this->mCallback ) {
78 $this->loadFreshRow();
79 }
80 return parent::getVisibility();
81 }
82
91 public function getUser( $audience = self::FOR_PUBLIC, Authority $performer = null ) {
92 if ( $this->mCallback ) {
93 $this->loadFreshRow();
94 }
95 return parent::getUser( $audience, $performer );
96 }
97
103 private function loadFreshRow() {
104 [ $freshRevDeleted, $freshUser ] = call_user_func( $this->mCallback, $this->mId );
105
106 // Set to null to ensure we do not make unnecessary queries for subsequent getter calls,
107 // and to allow the closure to be freed.
108 $this->mCallback = null;
109
110 if ( $freshRevDeleted !== null && $freshUser !== null ) {
111 $this->mDeleted = intval( $freshRevDeleted );
112 $this->mUser = $freshUser;
113 } else {
114 throw new RevisionAccessException(
115 'Unable to load fresh row for rev_id: {rev_id}',
116 [ 'rev_id' => $this->mId ]
117 );
118 }
119 }
120
121}
Value object for a comment stored by CommentStore.
Value object representing the set of slots belonging to a revision.
__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.
getUser( $audience=self::FOR_PUBLIC, Authority $performer=null)
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:37
Interface for objects representing user identity.