mCallback = $callback; } /** * Overridden to ensure that we return a fresh value and not a cached one. * * @return int */ public function getVisibility() { if ( $this->mCallback ) { $this->loadFreshRow(); } return parent::getVisibility(); } /** * Overridden to ensure that we return a fresh value and not a cached one. * * @param int $audience * @param Authority|null $performer * * @return UserIdentity The identity of the revision author, null if access is forbidden. */ public function getUser( $audience = self::FOR_PUBLIC, Authority $performer = null ) { if ( $this->mCallback ) { $this->loadFreshRow(); } return parent::getUser( $audience, $performer ); } /** * Load a fresh row from the database to ensure we return updated information * * @throws RevisionAccessException if the row could not be loaded */ private function loadFreshRow() { list( $freshRevDeleted, $freshUser ) = call_user_func( $this->mCallback, $this->mId ); // Set to null to ensure we do not make unnecessary queries for subsequent getter calls, // and to allow the closure to be freed. $this->mCallback = null; if ( $freshRevDeleted !== null && $freshUser !== null ) { $this->mDeleted = intval( $freshRevDeleted ); $this->mUser = $freshUser; } else { throw new RevisionAccessException( 'Unable to load fresh row for rev_id: {rev_id}', [ 'rev_id' => $this->mId ] ); } } }