MediaWiki master
RevisionStoreCacheRecord.php
Go to the documentation of this file.
1<?php
9namespace MediaWiki\Revision;
10
15
24
28 private $mCallback;
29
44 public function __construct(
45 callable $callback,
46 PageIdentity $page,
47 UserIdentity $user,
48 CommentStoreComment $comment,
49 $row,
50 RevisionSlots $slots,
51 $wikiID = self::LOCAL
52 ) {
53 parent::__construct( $page, $user, $comment, $row, $slots, $wikiID );
54 $this->mCallback = $callback;
55 }
56
62 public function getVisibility() {
63 if ( $this->mCallback ) {
64 $this->loadFreshRow();
65 }
66 return parent::getVisibility();
67 }
68
77 public function getUser( $audience = self::FOR_PUBLIC, ?Authority $performer = null ) {
78 if ( $this->mCallback ) {
79 $this->loadFreshRow();
80 }
81 return parent::getUser( $audience, $performer );
82 }
83
89 private function loadFreshRow() {
90 [ $freshRevDeleted, $freshUser ] = ( $this->mCallback )( $this->mId );
91
92 // Set to null to ensure we do not make unnecessary queries for subsequent getter calls,
93 // and to allow the closure to be freed.
94 $this->mCallback = null;
95
96 if ( $freshRevDeleted !== null && $freshUser !== null ) {
97 $this->mDeleted = intval( $freshRevDeleted );
98 $this->mUser = $freshUser;
99 } else {
100 throw new RevisionAccessException(
101 'Unable to load fresh row for rev_id: {rev_id}',
102 [ 'rev_id' => $this->mId ]
103 );
104 }
105 }
106
107}
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.