MediaWiki REL1_33
Command.php
Go to the documentation of this file.
1<?php
22
23use Exception;
27use Psr\Log\LoggerAwareTrait;
28use Psr\Log\NullLogger;
29
35class Command {
36 use LoggerAwareTrait;
37
39 protected $command = '';
40
42 private $limits = [
43 // seconds
44 'time' => 180,
45 // seconds
46 'walltime' => 180,
47 // KB
48 'memory' => 307200,
49 // KB
50 'filesize' => 102400,
51 ];
52
54 private $env = [];
55
57 private $method;
58
60 private $inputString;
61
63 private $doIncludeStderr = false;
64
66 private $doLogStderr = false;
67
69 private $everExecuted = false;
70
72 private $cgroup = false;
73
79 protected $restrictions = 0;
80
86 public function __construct() {
87 if ( Shell::isDisabled() ) {
88 throw new ShellDisabledError();
89 }
90
91 $this->setLogger( new NullLogger() );
92 }
93
97 public function __destruct() {
98 if ( !$this->everExecuted ) {
99 $context = [ 'command' => $this->command ];
100 $message = __CLASS__ . " was instantiated, but execute() was never called.";
101 if ( $this->method ) {
102 $message .= ' Calling method: {method}.';
103 $context['method'] = $this->method;
104 }
105 $message .= ' Command: {command}';
106 $this->logger->warning( $message, $context );
107 }
108 }
109
117 public function params( /* ... */ ) {
118 $args = func_get_args();
119 if ( count( $args ) === 1 && is_array( reset( $args ) ) ) {
120 // If only one argument has been passed, and that argument is an array,
121 // treat it as a list of arguments
122 $args = reset( $args );
123 }
124 $this->command = trim( $this->command . ' ' . Shell::escape( $args ) );
125
126 return $this;
127 }
128
136 public function unsafeParams( /* ... */ ) {
137 $args = func_get_args();
138 if ( count( $args ) === 1 && is_array( reset( $args ) ) ) {
139 // If only one argument has been passed, and that argument is an array,
140 // treat it as a list of arguments
141 $args = reset( $args );
142 }
143 $args = array_filter( $args,
144 function ( $value ) {
145 return $value !== null;
146 }
147 );
148 $this->command = trim( $this->command . ' ' . implode( ' ', $args ) );
149
150 return $this;
151 }
152
160 public function limits( array $limits ) {
161 if ( !isset( $limits['walltime'] ) && isset( $limits['time'] ) ) {
162 // Emulate the behavior of old wfShellExec() where walltime fell back on time
163 // if the latter was overridden and the former wasn't
164 $limits['walltime'] = $limits['time'];
165 }
166 $this->limits = $limits + $this->limits;
167
168 return $this;
169 }
170
177 public function environment( array $env ) {
178 $this->env = $env;
179
180 return $this;
181 }
182
189 public function profileMethod( $method ) {
190 $this->method = $method;
191
192 return $this;
193 }
194
201 public function input( $inputString ) {
202 $this->inputString = is_null( $inputString ) ? null : (string)$inputString;
203
204 return $this;
205 }
206
214 public function includeStderr( $yesno = true ) {
215 $this->doIncludeStderr = $yesno;
216
217 return $this;
218 }
219
226 public function logStderr( $yesno = true ) {
227 $this->doLogStderr = $yesno;
228
229 return $this;
230 }
231
238 public function cgroup( $cgroup ) {
239 $this->cgroup = $cgroup;
240
241 return $this;
242 }
243
251 public function restrict( $restrictions ) {
252 $this->restrictions |= $restrictions;
253
254 return $this;
255 }
256
264 protected function hasRestriction( $restriction ) {
265 return ( $this->restrictions & $restriction ) === $restriction;
266 }
267
278 public function whitelistPaths( array $paths ) {
279 // Default implementation is a no-op
280 return $this;
281 }
282
290 protected function buildFinalCommand( $command ) {
291 $envcmd = '';
292 foreach ( $this->env as $k => $v ) {
293 if ( wfIsWindows() ) {
294 /* Surrounding a set in quotes (method used by wfEscapeShellArg) makes the quotes themselves
295 * appear in the environment variable, so we must use carat escaping as documented in
296 * https://technet.microsoft.com/en-us/library/cc723564.aspx
297 * Note however that the quote isn't listed there, but is needed, and the parentheses
298 * are listed there but doesn't appear to need it.
299 */
300 $envcmd .= "set $k=" . preg_replace( '/([&|()<>^"])/', '^\\1', $v ) . '&& ';
301 } else {
302 /* Assume this is a POSIX shell, thus required to accept variable assignments before the command
303 * http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_09_01
304 */
305 $envcmd .= "$k=" . escapeshellarg( $v ) . ' ';
306 }
307 }
308
309 $useLogPipe = false;
310 $cmd = $envcmd . trim( $command );
311
312 if ( is_executable( '/bin/bash' ) ) {
313 $time = intval( $this->limits['time'] );
314 $wallTime = intval( $this->limits['walltime'] );
315 $mem = intval( $this->limits['memory'] );
316 $filesize = intval( $this->limits['filesize'] );
317
318 if ( $time > 0 || $mem > 0 || $filesize > 0 || $wallTime > 0 ) {
319 $cmd = '/bin/bash ' . escapeshellarg( __DIR__ . '/limit.sh' ) . ' ' .
320 escapeshellarg( $cmd ) . ' ' .
321 escapeshellarg(
322 "MW_INCLUDE_STDERR=" . ( $this->doIncludeStderr ? '1' : '' ) . ';' .
323 "MW_CPU_LIMIT=$time; " .
324 'MW_CGROUP=' . escapeshellarg( $this->cgroup ) . '; ' .
325 "MW_MEM_LIMIT=$mem; " .
326 "MW_FILE_SIZE_LIMIT=$filesize; " .
327 "MW_WALL_CLOCK_LIMIT=$wallTime; " .
328 "MW_USE_LOG_PIPE=yes"
329 );
330 $useLogPipe = true;
331 }
332 }
333 if ( !$useLogPipe && $this->doIncludeStderr ) {
334 $cmd .= ' 2>&1';
335 }
336
337 return [ $cmd, $useLogPipe ];
338 }
339
349 public function execute() {
350 $this->everExecuted = true;
351
352 $profileMethod = $this->method ?: wfGetCaller();
353
354 list( $cmd, $useLogPipe ) = $this->buildFinalCommand( $this->command );
355
356 $this->logger->debug( __METHOD__ . ": $cmd" );
357
358 // Don't try to execute commands that exceed Linux's MAX_ARG_STRLEN.
359 // Other platforms may be more accomodating, but we don't want to be
360 // accomodating, because very long commands probably include user
361 // input. See T129506.
362 if ( strlen( $cmd ) > SHELL_MAX_ARG_STRLEN ) {
363 throw new Exception( __METHOD__ .
364 '(): total length of $cmd must not exceed SHELL_MAX_ARG_STRLEN' );
365 }
366
367 $desc = [
368 0 => $this->inputString === null ? [ 'file', 'php://stdin', 'r' ] : [ 'pipe', 'r' ],
369 1 => [ 'pipe', 'w' ],
370 2 => [ 'pipe', 'w' ],
371 ];
372 if ( $useLogPipe ) {
373 $desc[3] = [ 'pipe', 'w' ];
374 }
375 $pipes = null;
376 $scoped = Profiler::instance()->scopedProfileIn( __FUNCTION__ . '-' . $profileMethod );
377 $proc = proc_open( $cmd, $desc, $pipes );
378 if ( !$proc ) {
379 $this->logger->error( "proc_open() failed: {command}", [ 'command' => $cmd ] );
380 throw new ProcOpenError();
381 }
382
383 $buffers = [
384 0 => $this->inputString, // input
385 1 => '', // stdout
386 2 => null, // stderr
387 3 => '', // log
388 ];
389 $emptyArray = [];
390 $status = false;
391 $logMsg = false;
392
393 /* According to the documentation, it is possible for stream_select()
394 * to fail due to EINTR. I haven't managed to induce this in testing
395 * despite sending various signals. If it did happen, the error
396 * message would take the form:
397 *
398 * stream_select(): unable to select [4]: Interrupted system call (max_fd=5)
399 *
400 * where [4] is the value of the macro EINTR and "Interrupted system
401 * call" is string which according to the Linux manual is "possibly"
402 * localised according to LC_MESSAGES.
403 */
404 $eintr = defined( 'SOCKET_EINTR' ) ? SOCKET_EINTR : 4;
405 $eintrMessage = "stream_select(): unable to select [$eintr]";
406
407 /* The select(2) system call only guarantees a "sufficiently small write"
408 * can be made without blocking. And on Linux the read might block too
409 * in certain cases, although I don't know if any of them can occur here.
410 * Regardless, set all the pipes to non-blocking to avoid T184171.
411 */
412 foreach ( $pipes as $pipe ) {
413 stream_set_blocking( $pipe, false );
414 }
415
416 $running = true;
417 $timeout = null;
418 $numReadyPipes = 0;
419
420 while ( $pipes && ( $running === true || $numReadyPipes !== 0 ) ) {
421 if ( $running ) {
422 $status = proc_get_status( $proc );
423 // If the process has terminated, switch to nonblocking selects
424 // for getting any data still waiting to be read.
425 if ( !$status['running'] ) {
426 $running = false;
427 $timeout = 0;
428 }
429 }
430
431 // clear get_last_error without actually raising an error
432 // from https://secure.php.net/manual/en/function.error-get-last.php#113518
433 // TODO replace with clear_last_error when requirements are bumped to PHP7
434 set_error_handler( function () {
435 }, 0 );
436 \Wikimedia\suppressWarnings();
437 trigger_error( '' );
438 \Wikimedia\restoreWarnings();
439 restore_error_handler();
440
441 $readPipes = array_filter( $pipes, function ( $fd ) use ( $desc ) {
442 return $desc[$fd][0] === 'pipe' && $desc[$fd][1] === 'r';
443 }, ARRAY_FILTER_USE_KEY );
444 $writePipes = array_filter( $pipes, function ( $fd ) use ( $desc ) {
445 return $desc[$fd][0] === 'pipe' && $desc[$fd][1] === 'w';
446 }, ARRAY_FILTER_USE_KEY );
447 // stream_select parameter names are from the POV of us being able to do the operation;
448 // proc_open desriptor types are from the POV of the process doing it.
449 // So $writePipes is passed as the $read parameter and $readPipes as $write.
450 // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
451 $numReadyPipes = @stream_select( $writePipes, $readPipes, $emptyArray, $timeout );
452 if ( $numReadyPipes === false ) {
453 $error = error_get_last();
454 if ( strncmp( $error['message'], $eintrMessage, strlen( $eintrMessage ) ) == 0 ) {
455 continue;
456 } else {
457 trigger_error( $error['message'], E_USER_WARNING );
458 $logMsg = $error['message'];
459 break;
460 }
461 }
462 foreach ( $writePipes + $readPipes as $fd => $pipe ) {
463 // True if a pipe is unblocked for us to write into, false if for reading from
464 $isWrite = array_key_exists( $fd, $readPipes );
465
466 if ( $isWrite ) {
467 // Don't bother writing if the buffer is empty
468 if ( $buffers[$fd] === '' ) {
469 fclose( $pipes[$fd] );
470 unset( $pipes[$fd] );
471 continue;
472 }
473 $res = fwrite( $pipe, $buffers[$fd], 65536 );
474 } else {
475 $res = fread( $pipe, 65536 );
476 }
477
478 if ( $res === false ) {
479 $logMsg = 'Error ' . ( $isWrite ? 'writing to' : 'reading from' ) . ' pipe';
480 break 2;
481 }
482
483 if ( $res === '' || $res === 0 ) {
484 // End of file?
485 if ( feof( $pipe ) ) {
486 fclose( $pipes[$fd] );
487 unset( $pipes[$fd] );
488 }
489 } elseif ( $isWrite ) {
490 $buffers[$fd] = (string)substr( $buffers[$fd], $res );
491 if ( $buffers[$fd] === '' ) {
492 fclose( $pipes[$fd] );
493 unset( $pipes[$fd] );
494 }
495 } else {
496 $buffers[$fd] .= $res;
497 if ( $fd === 3 && strpos( $res, "\n" ) !== false ) {
498 // For the log FD, every line is a separate log entry.
499 $lines = explode( "\n", $buffers[3] );
500 $buffers[3] = array_pop( $lines );
501 foreach ( $lines as $line ) {
502 $this->logger->info( $line );
503 }
504 }
505 }
506 }
507 }
508
509 foreach ( $pipes as $pipe ) {
510 fclose( $pipe );
511 }
512
513 // Use the status previously collected if possible, since proc_get_status()
514 // just calls waitpid() which will not return anything useful the second time.
515 if ( $running ) {
516 $status = proc_get_status( $proc );
517 }
518
519 if ( $logMsg !== false ) {
520 // Read/select error
521 $retval = -1;
522 proc_close( $proc );
523 } elseif ( $status['signaled'] ) {
524 $logMsg = "Exited with signal {$status['termsig']}";
525 $retval = 128 + $status['termsig'];
526 proc_close( $proc );
527 } else {
528 if ( $status['running'] ) {
529 $retval = proc_close( $proc );
530 } else {
531 $retval = $status['exitcode'];
532 proc_close( $proc );
533 }
534 if ( $retval == 127 ) {
535 $logMsg = "Possibly missing executable file";
536 } elseif ( $retval >= 129 && $retval <= 192 ) {
537 $logMsg = "Probably exited with signal " . ( $retval - 128 );
538 }
539 }
540
541 if ( $logMsg !== false ) {
542 $this->logger->warning( "$logMsg: {command}", [ 'command' => $cmd ] );
543 }
544
545 if ( $buffers[2] && $this->doLogStderr ) {
546 $this->logger->error( "Error running {command}: {error}", [
547 'command' => $cmd,
548 'error' => $buffers[2],
549 'exitcode' => $retval,
550 'exception' => new Exception( 'Shell error' ),
551 ] );
552 }
553
554 return new Result( $retval, $buffers[1], $buffers[2] );
555 }
556
564 public function __toString() {
565 return "#Command: {$this->command}";
566 }
567}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
wfGetCaller( $level=2)
Get the name of the function which called this function wfGetCaller( 1 ) is the function with the wfG...
wfIsWindows()
Check if the operating system is Windows.
$line
Definition cdb.php:59
if( $line===false) $args
Definition cdb.php:64
Class used for executing shell commands.
Definition Command.php:35
profileMethod( $method)
Sets calling function for profiler.
Definition Command.php:189
int $restrictions
bitfield with restrictions
Definition Command.php:79
restrict( $restrictions)
Set additional restrictions for this request.
Definition Command.php:251
unsafeParams()
Adds unsafe parameters to the command.
Definition Command.php:136
limits(array $limits)
Sets execution limits.
Definition Command.php:160
string null $inputString
Definition Command.php:60
hasRestriction( $restriction)
Bitfield helper on whether a specific restriction is enabled.
Definition Command.php:264
environment(array $env)
Sets environment variables which should be added to the executed command environment.
Definition Command.php:177
includeStderr( $yesno=true)
Controls whether stderr should be included in stdout, including errors from limit....
Definition Command.php:214
input( $inputString)
Sends the provided input to the command.
Definition Command.php:201
__construct()
Constructor.
Definition Command.php:86
execute()
Executes command.
Definition Command.php:349
params()
Adds parameters to the command.
Definition Command.php:117
string false $cgroup
Definition Command.php:72
__destruct()
Destructor.
Definition Command.php:97
cgroup( $cgroup)
Sets cgroup for this command.
Definition Command.php:238
__toString()
Returns the final command line before environment/limiting, etc are applied.
Definition Command.php:564
buildFinalCommand( $command)
String together all the options and build the final command to execute.
Definition Command.php:290
logStderr( $yesno=true)
When enabled, text sent to stderr will be logged with a level of 'error'.
Definition Command.php:226
whitelistPaths(array $paths)
If called, only the files/directories that are whitelisted will be available to the shell command.
Definition Command.php:278
Returned by MediaWiki\Shell\Command::execute()
Definition Result.php:28
static escape(... $args)
Version of escapeshellarg() that works better on Windows.
Definition Shell.php:163
static isDisabled()
Check if this class is effectively disabled via php.ini config.
Definition Shell.php:137
Profiler base class that defines the interface and some trivial functionality.
Definition Profiler.php:33
$res
Definition database.txt:21
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
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
const SHELL_MAX_ARG_STRLEN
Definition Defines.php:279
see documentation in includes Linker php for Linker::makeImageLink & $time
Definition hooks.txt:1802
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
Definition hooks.txt:181
Status::newGood()` to allow deletion, and then `return false` from the hook function. Ensure you consume the 'ChangeTagAfterDelete' hook to carry out custom deletion actions. $tag:name of the tag $user:user initiating the action & $status:Status object. See above. 'ChangeTagsListActive':Allows you to nominate which of the tags your extension uses are in active use. & $tags:list of all active tags. Append to this array. 'ChangeTagsAfterUpdateTags':Called after tags have been updated with the ChangeTags::updateTags function. Params:$addedTags:tags effectively added in the update $removedTags:tags effectively removed in the update $prevTags:tags that were present prior to the update $rc_id:recentchanges table id $rev_id:revision table id $log_id:logging table id $params:tag params $rc:RecentChange being tagged when the tagging accompanies the action, or null $user:User who performed the tagging when the tagging is subsequent to the action, or null 'ChangeTagsAllowedAdd':Called when checking if a user can add tags to a change. & $allowedTags:List of all the tags the user is allowed to add. Any tags the user wants to add( $addTags) that are not in this array will cause it to fail. You may add or remove tags to this array as required. $addTags:List of tags user intends to add. $user:User who is adding the tags. 'ChangeUserGroups':Called before user groups are changed. $performer:The User who will perform the change $user:The User whose groups will be changed & $add:The groups that will be added & $remove:The groups that will be removed 'Collation::factory':Called if $wgCategoryCollation is an unknown collation. $collationName:Name of the collation in question & $collationObject:Null. Replace with a subclass of the Collation class that implements the collation given in $collationName. 'ConfirmEmailComplete':Called after a user 's email has been confirmed successfully. $user:user(object) whose email is being confirmed 'ContentAlterParserOutput':Modify parser output for a given content object. Called by Content::getParserOutput after parsing has finished. Can be used for changes that depend on the result of the parsing but have to be done before LinksUpdate is called(such as adding tracking categories based on the rendered HTML). $content:The Content to render $title:Title of the page, as context $parserOutput:ParserOutput to manipulate 'ContentGetParserOutput':Customize parser output for a given content object, called by AbstractContent::getParserOutput. May be used to override the normal model-specific rendering of page content. $content:The Content to render $title:Title of the page, as context $revId:The revision ID, as context $options:ParserOptions for rendering. To avoid confusing the parser cache, the output can only depend on parameters provided to this hook function, not on global state. $generateHtml:boolean, indicating whether full HTML should be generated. If false, generation of HTML may be skipped, but other information should still be present in the ParserOutput object. & $output:ParserOutput, to manipulate or replace 'ContentHandlerDefaultModelFor':Called when the default content model is determined for a given title. May be used to assign a different model for that title. $title:the Title in question & $model:the model name. Use with CONTENT_MODEL_XXX constants. 'ContentHandlerForModelID':Called when a ContentHandler is requested for a given content model name, but no entry for that model exists in $wgContentHandlers. Note:if your extension implements additional models via this hook, please use GetContentModels hook to make them known to core. $modeName:the requested content model name & $handler:set this to a ContentHandler object, if desired. 'ContentModelCanBeUsedOn':Called to determine whether that content model can be used on a given page. This is especially useful to prevent some content models to be used in some special location. $contentModel:ID of the content model in question $title:the Title in question. & $ok:Output parameter, whether it is OK to use $contentModel on $title. Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok. 'ContribsPager::getQueryInfo':Before the contributions query is about to run & $pager:Pager object for contributions & $queryInfo:The query for the contribs Pager 'ContribsPager::reallyDoQuery':Called before really executing the query for My Contributions & $data:an array of results of all contribs queries $pager:The ContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'ContributionsLineEnding':Called before a contributions HTML line is finished $page:SpecialPage object for contributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'ContributionsToolLinks':Change tool links above Special:Contributions $id:User identifier $title:User page title & $tools:Array of tool links $specialPage:SpecialPage instance for context and services. Can be either SpecialContributions or DeletedContributionsPage. Extensions should type hint against a generic SpecialPage though. 'ConvertContent':Called by AbstractContent::convert when a conversion to another content model is requested. Handler functions that modify $result should generally return false to disable further attempts at conversion. $content:The Content object to be converted. $toModel:The ID of the content model to convert to. $lossy:boolean indicating whether lossy conversion is allowed. & $result:Output parameter, in case the handler function wants to provide a converted Content object. Note that $result->getContentModel() must return $toModel. 'ContentSecurityPolicyDefaultSource':Modify the allowed CSP load sources. This affects all directives except for the script directive. If you want to add a script source, see ContentSecurityPolicyScriptSource hook. & $defaultSrc:Array of Content-Security-Policy allowed sources $policyConfig:Current configuration for the Content-Security-Policy header $mode:ContentSecurityPolicy::REPORT_ONLY_MODE or ContentSecurityPolicy::FULL_MODE depending on type of header 'ContentSecurityPolicyDirectives':Modify the content security policy directives. Use this only if ContentSecurityPolicyDefaultSource and ContentSecurityPolicyScriptSource do not meet your needs. & $directives:Array of CSP directives $policyConfig:Current configuration for the CSP header $mode:ContentSecurityPolicy::REPORT_ONLY_MODE or ContentSecurityPolicy::FULL_MODE depending on type of header 'ContentSecurityPolicyScriptSource':Modify the allowed CSP script sources. Note that you also have to use ContentSecurityPolicyDefaultSource if you want non-script sources to be loaded from whatever you add. & $scriptSrc:Array of CSP directives $policyConfig:Current configuration for the CSP header $mode:ContentSecurityPolicy::REPORT_ONLY_MODE or ContentSecurityPolicy::FULL_MODE depending on type of header 'CustomEditor':When invoking the page editor Return true to allow the normal editor to be used, or false if implementing a custom editor, e.g. for a special namespace, etc. $article:Article being edited $user:User performing the edit 'DatabaseOraclePostInit':Called after initialising an Oracle database $db:the DatabaseOracle object 'DeletedContribsPager::reallyDoQuery':Called before really executing the query for Special:DeletedContributions Similar to ContribsPager::reallyDoQuery & $data:an array of results of all contribs queries $pager:The DeletedContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'DeletedContributionsLineEnding':Called before a DeletedContributions HTML line is finished. Similar to ContributionsLineEnding $page:SpecialPage object for DeletedContributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'DeleteUnknownPreferences':Called by the cleanupPreferences.php maintenance script to build a WHERE clause with which to delete preferences that are not known about. This hook is used by extensions that have dynamically-named preferences that should not be deleted in the usual cleanup process. For example, the Gadgets extension creates preferences prefixed with 'gadget-', and so anything with that prefix is excluded from the deletion. &where:An array that will be passed as the $cond parameter to IDatabase::select() to determine what will be deleted from the user_properties table. $db:The IDatabase object, useful for accessing $db->buildLike() etc. 'DifferenceEngineAfterLoadNewText':called in DifferenceEngine::loadNewText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before returning true from this function. $differenceEngine:DifferenceEngine object 'DifferenceEngineLoadTextAfterNewContentIsLoaded':called in DifferenceEngine::loadText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before checking if the variable 's value is null. This hook can be used to inject content into said class member variable. $differenceEngine:DifferenceEngine object 'DifferenceEngineMarkPatrolledLink':Allows extensions to change the "mark as patrolled" link which is shown both on the diff header as well as on the bottom of a page, usually wrapped in a span element which has class="patrollink". $differenceEngine:DifferenceEngine object & $markAsPatrolledLink:The "mark as patrolled" link HTML(string) $rcid:Recent change ID(rc_id) for this change(int) 'DifferenceEngineMarkPatrolledRCID':Allows extensions to possibly change the rcid parameter. For example the rcid might be set to zero due to the user being the same as the performer of the change but an extension might still want to show it under certain conditions. & $rcid:rc_id(int) of the change or 0 $differenceEngine:DifferenceEngine object $change:RecentChange object $user:User object representing the current user 'DifferenceEngineNewHeader':Allows extensions to change the $newHeader variable, which contains information about the new revision, such as the revision 's author, whether the revision was marked as a minor edit or not, etc. $differenceEngine:DifferenceEngine object & $newHeader:The string containing the various #mw-diff-otitle[1-5] divs, which include things like revision author info, revision comment, RevisionDelete link and more $formattedRevisionTools:Array containing revision tools, some of which may have been injected with the DiffRevisionTools hook $nextlink:String containing the link to the next revision(if any) $status
Definition hooks.txt:1266
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
Definition hooks.txt:2848
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not null
Definition hooks.txt:783
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
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
Copyright (C) 2017 Kunal Mehta legoktm@member.fsf.org
Definition Command.php:21
$lines
Definition router.php:61