MediaWiki  1.29.1
ApiStashEdit.php
Go to the documentation of this file.
1 <?php
24 use Wikimedia\ScopedCallback;
25 
39 class ApiStashEdit extends ApiBase {
40  const ERROR_NONE = 'stashed';
41  const ERROR_PARSE = 'error_parse';
42  const ERROR_CACHE = 'error_cache';
43  const ERROR_UNCACHEABLE = 'uncacheable';
44  const ERROR_BUSY = 'busy';
45 
47  const MAX_CACHE_TTL = 300; // 5 minutes
48 
49  public function execute() {
50  $user = $this->getUser();
51  $params = $this->extractRequestParams();
52 
53  if ( $user->isBot() ) { // sanity
54  $this->dieWithError( 'apierror-botsnotsupported' );
55  }
56 
58  $page = $this->getTitleOrPageId( $params );
59  $title = $page->getTitle();
60 
61  if ( !ContentHandler::getForModelID( $params['contentmodel'] )
62  ->isSupportedFormat( $params['contentformat'] )
63  ) {
64  $this->dieWithError(
65  [ 'apierror-badformat-generic', $params['contentformat'], $params['contentmodel'] ],
66  'badmodelformat'
67  );
68  }
69 
70  $this->requireAtLeastOneParameter( $params, 'stashedtexthash', 'text' );
71 
72  $text = null;
73  $textHash = null;
74  if ( strlen( $params['stashedtexthash'] ) ) {
75  // Load from cache since the client indicates the text is the same as last stash
76  $textHash = $params['stashedtexthash'];
77  $textKey = $cache->makeKey( 'stashedit', 'text', $textHash );
78  $text = $cache->get( $textKey );
79  if ( !is_string( $text ) ) {
80  $this->dieWithError( 'apierror-stashedit-missingtext', 'missingtext' );
81  }
82  } elseif ( $params['text'] !== null ) {
83  // Trim and fix newlines so the key SHA1's match (see WebRequest::getText())
84  $text = rtrim( str_replace( "\r\n", "\n", $params['text'] ) );
85  $textHash = sha1( $text );
86  } else {
87  $this->dieWithError( [
88  'apierror-missingparam-at-least-one-of',
89  Message::listParam( [ '<var>stashedtexthash</var>', '<var>text</var>' ] ),
90  2,
91  ], 'missingparam' );
92  }
93 
94  $textContent = ContentHandler::makeContent(
95  $text, $title, $params['contentmodel'], $params['contentformat'] );
96 
98  if ( $page->exists() ) {
99  // Page exists: get the merged content with the proposed change
100  $baseRev = Revision::newFromPageId( $page->getId(), $params['baserevid'] );
101  if ( !$baseRev ) {
102  $this->dieWithError( [ 'apierror-nosuchrevid', $params['baserevid'] ] );
103  }
104  $currentRev = $page->getRevision();
105  if ( !$currentRev ) {
106  $this->dieWithError( [ 'apierror-missingrev-pageid', $page->getId() ], 'missingrev' );
107  }
108  // Merge in the new version of the section to get the proposed version
109  $editContent = $page->replaceSectionAtRev(
110  $params['section'],
111  $textContent,
112  $params['sectiontitle'],
113  $baseRev->getId()
114  );
115  if ( !$editContent ) {
116  $this->dieWithError( 'apierror-sectionreplacefailed', 'replacefailed' );
117  }
118  if ( $currentRev->getId() == $baseRev->getId() ) {
119  // Base revision was still the latest; nothing to merge
120  $content = $editContent;
121  } else {
122  // Merge the edit into the current version
123  $baseContent = $baseRev->getContent();
124  $currentContent = $currentRev->getContent();
125  if ( !$baseContent || !$currentContent ) {
126  $this->dieWithError( [ 'apierror-missingcontent-pageid', $page->getId() ], 'missingrev' );
127  }
128  $handler = ContentHandler::getForModelID( $baseContent->getModel() );
129  $content = $handler->merge3( $baseContent, $editContent, $currentContent );
130  }
131  } else {
132  // New pages: use the user-provided content model
133  $content = $textContent;
134  }
135 
136  if ( !$content ) { // merge3() failed
137  $this->getResult()->addValue( null,
138  $this->getModuleName(), [ 'status' => 'editconflict' ] );
139  return;
140  }
141 
142  // The user will abort the AJAX request by pressing "save", so ignore that
143  ignore_user_abort( true );
144 
145  if ( $user->pingLimiter( 'stashedit' ) ) {
146  $status = 'ratelimited';
147  } else {
149  $textKey = $cache->makeKey( 'stashedit', 'text', $textHash );
150  $cache->set( $textKey, $text, self::MAX_CACHE_TTL );
151  }
152 
153  $stats = MediaWikiServices::getInstance()->getStatsdDataFactory();
154  $stats->increment( "editstash.cache_stores.$status" );
155 
156  $this->getResult()->addValue(
157  null,
158  $this->getModuleName(),
159  [
160  'status' => $status,
161  'texthash' => $textHash
162  ]
163  );
164  }
165 
174  public static function parseAndStash( WikiPage $page, Content $content, User $user, $summary ) {
176  $logger = LoggerFactory::getInstance( 'StashEdit' );
177 
178  $title = $page->getTitle();
179  $key = self::getStashKey( $title, self::getContentHash( $content ), $user );
180 
181  // Use the master DB for fast blocking locks
182  $dbw = wfGetDB( DB_MASTER );
183  if ( !$dbw->lock( $key, __METHOD__, 1 ) ) {
184  // De-duplicate requests on the same key
185  return self::ERROR_BUSY;
186  }
188  $unlocker = new ScopedCallback( function () use ( $dbw, $key ) {
189  $dbw->unlock( $key, __METHOD__ );
190  } );
191 
192  $cutoffTime = time() - self::PRESUME_FRESH_TTL_SEC;
193 
194  // Reuse any freshly build matching edit stash cache
195  $editInfo = $cache->get( $key );
196  if ( $editInfo && wfTimestamp( TS_UNIX, $editInfo->timestamp ) >= $cutoffTime ) {
197  $alreadyCached = true;
198  } else {
199  $format = $content->getDefaultFormat();
200  $editInfo = $page->prepareContentForEdit( $content, null, $user, $format, false );
201  $alreadyCached = false;
202  }
203 
204  if ( $editInfo && $editInfo->output ) {
205  // Let extensions add ParserOutput metadata or warm other caches
206  Hooks::run( 'ParserOutputStashForEdit',
207  [ $page, $content, $editInfo->output, $summary, $user ] );
208 
209  if ( $alreadyCached ) {
210  $logger->debug( "Already cached parser output for key '$key' ('$title')." );
211  return self::ERROR_NONE;
212  }
213 
214  list( $stashInfo, $ttl, $code ) = self::buildStashValue(
215  $editInfo->pstContent,
216  $editInfo->output,
217  $editInfo->timestamp,
218  $user
219  );
220 
221  if ( $stashInfo ) {
222  $ok = $cache->set( $key, $stashInfo, $ttl );
223  if ( $ok ) {
224  $logger->debug( "Cached parser output for key '$key' ('$title')." );
225  return self::ERROR_NONE;
226  } else {
227  $logger->error( "Failed to cache parser output for key '$key' ('$title')." );
228  return self::ERROR_CACHE;
229  }
230  } else {
231  $logger->info( "Uncacheable parser output for key '$key' ('$title') [$code]." );
233  }
234  }
235 
236  return self::ERROR_PARSE;
237  }
238 
256  public static function checkCache( Title $title, Content $content, User $user ) {
257  if ( $user->isBot() ) {
258  return false; // bots never stash - don't pollute stats
259  }
260 
262  $logger = LoggerFactory::getInstance( 'StashEdit' );
263  $stats = MediaWikiServices::getInstance()->getStatsdDataFactory();
264 
265  $key = self::getStashKey( $title, self::getContentHash( $content ), $user );
266  $editInfo = $cache->get( $key );
267  if ( !is_object( $editInfo ) ) {
268  $start = microtime( true );
269  // We ignore user aborts and keep parsing. Block on any prior parsing
270  // so as to use its results and make use of the time spent parsing.
271  // Skip this logic if there no master connection in case this method
272  // is called on an HTTP GET request for some reason.
273  $lb = MediaWikiServices::getInstance()->getDBLoadBalancer();
274  $dbw = $lb->getAnyOpenConnection( $lb->getWriterIndex() );
275  if ( $dbw && $dbw->lock( $key, __METHOD__, 30 ) ) {
276  $editInfo = $cache->get( $key );
277  $dbw->unlock( $key, __METHOD__ );
278  }
279 
280  $timeMs = 1000 * max( 0, microtime( true ) - $start );
281  $stats->timing( 'editstash.lock_wait_time', $timeMs );
282  }
283 
284  if ( !is_object( $editInfo ) || !$editInfo->output ) {
285  $stats->increment( 'editstash.cache_misses.no_stash' );
286  $logger->debug( "Empty cache for key '$key' ('$title'); user '{$user->getName()}'." );
287  return false;
288  }
289 
290  $age = time() - wfTimestamp( TS_UNIX, $editInfo->output->getCacheTime() );
291  if ( $age <= self::PRESUME_FRESH_TTL_SEC ) {
292  // Assume nothing changed in this time
293  $stats->increment( 'editstash.cache_hits.presumed_fresh' );
294  $logger->debug( "Timestamp-based cache hit for key '$key' (age: $age sec)." );
295  } elseif ( isset( $editInfo->edits ) && $editInfo->edits === $user->getEditCount() ) {
296  // Logged-in user made no local upload/template edits in the meantime
297  $stats->increment( 'editstash.cache_hits.presumed_fresh' );
298  $logger->debug( "Edit count based cache hit for key '$key' (age: $age sec)." );
299  } elseif ( $user->isAnon()
300  && self::lastEditTime( $user ) < $editInfo->output->getCacheTime()
301  ) {
302  // Logged-out user made no local upload/template edits in the meantime
303  $stats->increment( 'editstash.cache_hits.presumed_fresh' );
304  $logger->debug( "Edit check based cache hit for key '$key' (age: $age sec)." );
305  } else {
306  // User may have changed included content
307  $editInfo = false;
308  }
309 
310  if ( !$editInfo ) {
311  $stats->increment( 'editstash.cache_misses.proven_stale' );
312  $logger->info( "Stale cache for key '$key'; old key with outside edits. (age: $age sec)" );
313  } elseif ( $editInfo->output->getFlag( 'vary-revision' ) ) {
314  // This can be used for the initial parse, e.g. for filters or doEditContent(),
315  // but a second parse will be triggered in doEditUpdates(). This is not optimal.
316  $logger->info( "Cache for key '$key' ('$title') has vary_revision." );
317  } elseif ( $editInfo->output->getFlag( 'vary-revision-id' ) ) {
318  // Similar to the above if we didn't guess the ID correctly.
319  $logger->info( "Cache for key '$key' ('$title') has vary_revision_id." );
320  }
321 
322  return $editInfo;
323  }
324 
329  private static function lastEditTime( User $user ) {
330  $time = wfGetDB( DB_REPLICA )->selectField(
331  'recentchanges',
332  'MAX(rc_timestamp)',
333  [ 'rc_user_text' => $user->getName() ],
334  __METHOD__
335  );
336 
337  return wfTimestampOrNull( TS_MW, $time );
338  }
339 
346  private static function getContentHash( Content $content ) {
347  return sha1( implode( "\n", [
348  $content->getModel(),
349  $content->getDefaultFormat(),
350  $content->serialize( $content->getDefaultFormat() )
351  ] ) );
352  }
353 
366  private static function getStashKey( Title $title, $contentHash, User $user ) {
367  return ObjectCache::getLocalClusterInstance()->makeKey(
368  'prepared-edit',
369  md5( $title->getPrefixedDBkey() ),
370  // Account for the edit model/text
371  $contentHash,
372  // Account for user name related variables like signatures
373  md5( $user->getId() . "\n" . $user->getName() )
374  );
375  }
376 
388  private static function buildStashValue(
389  Content $pstContent, ParserOutput $parserOutput, $timestamp, User $user
390  ) {
391  // If an item is renewed, mind the cache TTL determined by config and parser functions.
392  // Put an upper limit on the TTL for sanity to avoid extreme template/file staleness.
393  $since = time() - wfTimestamp( TS_UNIX, $parserOutput->getTimestamp() );
394  $ttl = min( $parserOutput->getCacheExpiry() - $since, self::MAX_CACHE_TTL );
395  if ( $ttl <= 0 ) {
396  return [ null, 0, 'no_ttl' ];
397  }
398 
399  // Only store what is actually needed
400  $stashInfo = (object)[
401  'pstContent' => $pstContent,
402  'output' => $parserOutput,
403  'timestamp' => $timestamp,
404  'edits' => $user->getEditCount()
405  ];
406 
407  return [ $stashInfo, $ttl, 'ok' ];
408  }
409 
410  public function getAllowedParams() {
411  return [
412  'title' => [
413  ApiBase::PARAM_TYPE => 'string',
415  ],
416  'section' => [
417  ApiBase::PARAM_TYPE => 'string',
418  ],
419  'sectiontitle' => [
420  ApiBase::PARAM_TYPE => 'string'
421  ],
422  'text' => [
423  ApiBase::PARAM_TYPE => 'text',
424  ApiBase::PARAM_DFLT => null
425  ],
426  'stashedtexthash' => [
427  ApiBase::PARAM_TYPE => 'string',
428  ApiBase::PARAM_DFLT => null
429  ],
430  'summary' => [
431  ApiBase::PARAM_TYPE => 'string',
432  ],
433  'contentmodel' => [
436  ],
437  'contentformat' => [
440  ],
441  'baserevid' => [
442  ApiBase::PARAM_TYPE => 'integer',
444  ]
445  ];
446  }
447 
448  public function needsToken() {
449  return 'csrf';
450  }
451 
452  public function mustBePosted() {
453  return true;
454  }
455 
456  public function isWriteMode() {
457  return true;
458  }
459 
460  public function isInternal() {
461  return true;
462  }
463 }
ContentHandler\getForModelID
static getForModelID( $modelId)
Returns the ContentHandler singleton for the given model ID.
Definition: ContentHandler.php:293
object
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration which are documented in DefaultSettings php There is no comprehensive documentation for the remaining however some of the most important ones are listed below They are typically initialised either in index php or in Setup php For a description of the see design txt $wgTitle Title object created from the request URL $wgOut OutputPage object for HTTP response $wgUser User object for the user associated with the current request $wgLang Language object selected by user preferences $wgContLang Language object associated with the wiki being viewed $wgParser Parser object Parser extensions register their hooks here $wgRequest WebRequest object
Definition: globals.txt:25
ContentHandler\getAllContentFormats
static getAllContentFormats()
Definition: ContentHandler.php:369
ParserOutput
Definition: ParserOutput.php:24
ObjectCache\getLocalClusterInstance
static getLocalClusterInstance()
Get the main cluster-local cache object.
Definition: ObjectCache.php:357
ApiStashEdit\needsToken
needsToken()
Returns the token type this module requires in order to execute.
Definition: ApiStashEdit.php:448
ApiBase\PARAM_REQUIRED
const PARAM_REQUIRED
(boolean) Is the parameter required?
Definition: ApiBase.php:115
ApiStashEdit\isWriteMode
isWriteMode()
Indicates whether this module requires write mode.
Definition: ApiStashEdit.php:456
ApiStashEdit\PRESUME_FRESH_TTL_SEC
const PRESUME_FRESH_TTL_SEC
Definition: ApiStashEdit.php:46
ApiBase\dieWithError
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
Abort execution with an error.
Definition: ApiBase.php:1796
ApiStashEdit\getContentHash
static getContentHash(Content $content)
Get hash of the content, factoring in model/format.
Definition: ApiStashEdit.php:346
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1994
ApiBase\getTitleOrPageId
getTitleOrPageId( $params, $load=false)
Get a WikiPage object from a title or pageid param, if possible.
Definition: ApiBase.php:895
ApiBase\PARAM_TYPE
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
Definition: ApiBase.php:91
ApiBase\getResult
getResult()
Get the result object.
Definition: ApiBase.php:610
$status
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
Definition: hooks.txt:1049
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:246
WikiPage
Class representing a MediaWiki article and history.
Definition: WikiPage.php:36
$params
$params
Definition: styleTest.css.php:40
ApiStashEdit\execute
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
Definition: ApiStashEdit.php:49
ApiStashEdit\parseAndStash
static parseAndStash(WikiPage $page, Content $content, User $user, $summary)
Definition: ApiStashEdit.php:174
Revision\newFromPageId
static newFromPageId( $pageId, $revId=0, $flags=0)
Load either the current, or a specified, revision that's attached to a given page ID.
Definition: Revision.php:165
ContextSource\getUser
getUser()
Get the User object.
Definition: ContextSource.php:133
ApiStashEdit\ERROR_NONE
const ERROR_NONE
Definition: ApiStashEdit.php:40
php
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:35
ApiBase
This abstract class implements many basic API functions, and is the base of all API classes.
Definition: ApiBase.php:41
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:934
WikiPage\factory
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition: WikiPage.php:120
ApiStashEdit\ERROR_CACHE
const ERROR_CACHE
Definition: ApiStashEdit.php:42
ContentHandler\getContentModels
static getContentModels()
Definition: ContentHandler.php:361
$content
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content $content
Definition: hooks.txt:1049
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:3060
$page
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
Definition: hooks.txt:2536
wfTimestampOrNull
wfTimestampOrNull( $outputtype=TS_UNIX, $ts=null)
Return a formatted timestamp, or null if input is null.
Definition: GlobalFunctions.php:2010
$time
see documentation in includes Linker php for Linker::makeImageLink & $time
Definition: hooks.txt:1769
DB_REPLICA
const DB_REPLICA
Definition: defines.php:25
DB_MASTER
const DB_MASTER
Definition: defines.php:26
ApiStashEdit\ERROR_UNCACHEABLE
const ERROR_UNCACHEABLE
Definition: ApiStashEdit.php:43
list
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition: deferred.txt:11
ContentHandler\makeContent
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
Definition: ContentHandler.php:129
ApiStashEdit\getAllowedParams
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
Definition: ApiStashEdit.php:410
ApiStashEdit\buildStashValue
static buildStashValue(Content $pstContent, ParserOutput $parserOutput, $timestamp, User $user)
Build a value to store in memcached based on the PST content and parser output.
Definition: ApiStashEdit.php:388
ApiBase\extractRequestParams
extractRequestParams( $parseLimit=true)
Using getAllowedParams(), this function makes an array of the values provided by the user,...
Definition: ApiBase.php:718
ApiStashEdit\isInternal
isInternal()
Indicates whether this module is "internal" Internal API modules are not (yet) intended for 3rd party...
Definition: ApiStashEdit.php:460
$handler
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable modifiable after all normalizations have been except for the $wgMaxImageArea check set to true or false to override the $wgMaxImageArea check result gives extension the possibility to transform it themselves $handler
Definition: hooks.txt:783
ApiStashEdit\ERROR_PARSE
const ERROR_PARSE
Definition: ApiStashEdit.php:41
Content
Base interface for content objects.
Definition: Content.php:34
ApiBase\requireAtLeastOneParameter
requireAtLeastOneParameter( $params, $required)
Die if none of a certain set of parameters is set and not false.
Definition: ApiBase.php:820
ApiStashEdit\lastEditTime
static lastEditTime(User $user)
Definition: ApiStashEdit.php:329
Title
Represents a title within MediaWiki.
Definition: Title.php:39
$cache
$cache
Definition: mcc.php:33
$code
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
Definition: hooks.txt:783
ApiBase\PARAM_DFLT
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
Definition: ApiBase.php:52
ApiStashEdit\getStashKey
static getStashKey(Title $title, $contentHash, User $user)
Get the temporary prepared edit stash key for a user.
Definition: ApiStashEdit.php:366
ApiBase\getModuleName
getModuleName()
Get the name of the module being executed by this instance.
Definition: ApiBase.php:490
LoggerFactory
MediaWiki Logger LoggerFactory implements a PSR[0] compatible message logging system Named Psr Log LoggerInterface instances can be obtained from the MediaWiki Logger LoggerFactory::getInstance() static method. MediaWiki\Logger\LoggerFactory expects a class implementing the MediaWiki\Logger\Spi interface to act as a factory for new Psr\Log\LoggerInterface instances. The "Spi" in MediaWiki\Logger\Spi stands for "service provider interface". An SPI is an API intended to be implemented or extended by a third party. This software design pattern is intended to enable framework extension and replaceable components. It is specifically used in the MediaWiki\Logger\LoggerFactory service to allow alternate PSR-3 logging implementations to be easily integrated with MediaWiki. The service provider interface allows the backend logging library to be implemented in multiple ways. The $wgMWLoggerDefaultSpi global provides the classname of the default MediaWiki\Logger\Spi implementation to be loaded at runtime. This can either be the name of a class implementing the MediaWiki\Logger\Spi with a zero argument const ructor or a callable that will return an MediaWiki\Logger\Spi instance. Alternately the MediaWiki\Logger\LoggerFactory MediaWiki Logger LoggerFactory
Definition: logger.txt:5
true
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
Definition: hooks.txt:1956
ApiStashEdit\MAX_CACHE_TTL
const MAX_CACHE_TTL
Definition: ApiStashEdit.php:47
MediaWikiServices
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 MediaWikiServices
Definition: injection.txt:23
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:50
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:131
ApiStashEdit
Prepare an edit in shared cache so that it can be reused on edit.
Definition: ApiStashEdit.php:39
ApiStashEdit\checkCache
static checkCache(Title $title, Content $content, User $user)
Check that a prepared edit is in cache and still up-to-date.
Definition: ApiStashEdit.php:256
$parserOutput
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context $parserOutput
Definition: hooks.txt:1049
ApiStashEdit\mustBePosted
mustBePosted()
Indicates whether this module must be called with a POST request.
Definition: ApiStashEdit.php:452
ApiStashEdit\ERROR_BUSY
const ERROR_BUSY
Definition: ApiStashEdit.php:44