MediaWiki REL1_33
RevisionStoreCacheRecord.php
Go to the documentation of this file.
1<?php
23namespace MediaWiki\Revision;
24
28use InvalidArgumentException;
30use User;
31
39
43 private $mCallback;
44
59 function __construct(
60 $callback,
61 Title $title,
62 UserIdentity $user,
63 CommentStoreComment $comment,
64 $row,
65 RevisionSlots $slots,
66 $wikiId = false
67 ) {
68 parent::__construct( $title, $user, $comment, $row, $slots, $wikiId );
69 $this->mCallback = $callback;
70 }
71
77 public function getVisibility() {
78 if ( $this->mCallback ) {
79 $this->loadFreshRow();
80 }
81 return parent::getVisibility();
82 }
83
92 public function getUser( $audience = self::FOR_PUBLIC, User $user = null ) {
93 if ( $this->mCallback ) {
94 $this->loadFreshRow();
95 }
96 return parent::getUser( $audience, $user );
97 }
98
104 private function loadFreshRow() {
105 $freshRow = call_user_func( $this->mCallback, $this->mId );
106
107 // Set to null to ensure we do not make unnecessary queries for subsequent getter calls,
108 // and to allow the closure to be freed.
109 $this->mCallback = null;
110
111 if ( $freshRow ) {
112 $this->mDeleted = intval( $freshRow->rev_deleted );
113
114 try {
115 $this->mUser = User::newFromAnyId(
116 $freshRow->rev_user ?? null,
117 $freshRow->rev_user_text ?? null,
118 $freshRow->rev_actor ?? null
119 );
120 } catch ( InvalidArgumentException $ex ) {
121 wfWarn(
122 __METHOD__
123 . ': '
124 . $this->mTitle->getPrefixedDBkey()
125 . ': '
126 . $ex->getMessage()
127 );
128 $this->mUser = new UserIdentityValue( 0, 'Unknown user', 0 );
129 }
130 } else {
131 throw new RevisionAccessException(
132 'Unable to load fresh row for rev_id: ' . $this->mId
133 );
134 }
135 }
136
137}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
wfWarn( $msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
CommentStoreComment represents a comment stored by CommentStore.
Exception representing a failure to look up a revision.
Value object representing the set of slots belonging to a revision.
getUser( $audience=self::FOR_PUBLIC, User $user=null)
Overridden to ensure that we return a fresh value and not a cached one.
__construct( $callback, Title $title, UserIdentity $user, CommentStoreComment $comment, $row, RevisionSlots $slots, $wikiId=false)
loadFreshRow()
Load a fresh row from the database to ensure we return updated information.
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.
Value object representing a user's identity.
Represents a title within MediaWiki.
Definition Title.php:40
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition User.php:48
static newFromAnyId( $userId, $userName, $actorId)
Static factory method for creation from an ID, name, and/or actor ID.
Definition User.php:676
namespace and then decline to actually register it file or subcat img or subcat $title
Definition hooks.txt:955
return true to allow those checks to and false if checking is done & $user
Definition hooks.txt:1510
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37
Interface for objects representing user identity.