MediaWiki  REL1_31
Command.php
Go to the documentation of this file.
1 <?php
21 namespace MediaWiki\Shell;
22 
23 use Exception;
27 use Psr\Log\LoggerAwareTrait;
28 use Psr\Log\NullLogger;
29 
35 class 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 
266  public function restrict( $restrictions ) {
267  $this->restrictions = $restrictions;
268 
269  return $this;
270  }
271 
279  protected function hasRestriction( $restriction ) {
280  return ( $this->restrictions & $restriction ) === $restriction;
281  }
282 
293  public function whitelistPaths( array $paths ) {
294  // Default implementation is a no-op
295  return $this;
296  }
297 
305  protected function buildFinalCommand( $command ) {
306  $envcmd = '';
307  foreach ( $this->env as $k => $v ) {
308  if ( wfIsWindows() ) {
309  /* Surrounding a set in quotes (method used by wfEscapeShellArg) makes the quotes themselves
310  * appear in the environment variable, so we must use carat escaping as documented in
311  * https://technet.microsoft.com/en-us/library/cc723564.aspx
312  * Note however that the quote isn't listed there, but is needed, and the parentheses
313  * are listed there but doesn't appear to need it.
314  */
315  $envcmd .= "set $k=" . preg_replace( '/([&|()<>^"])/', '^\\1', $v ) . '&& ';
316  } else {
317  /* Assume this is a POSIX shell, thus required to accept variable assignments before the command
318  * http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_09_01
319  */
320  $envcmd .= "$k=" . escapeshellarg( $v ) . ' ';
321  }
322  }
323 
324  $useLogPipe = false;
325  $cmd = $envcmd . trim( $command );
326 
327  if ( is_executable( '/bin/bash' ) ) {
328  $time = intval( $this->limits['time'] );
329  $wallTime = intval( $this->limits['walltime'] );
330  $mem = intval( $this->limits['memory'] );
331  $filesize = intval( $this->limits['filesize'] );
332 
333  if ( $time > 0 || $mem > 0 || $filesize > 0 || $wallTime > 0 ) {
334  $cmd = '/bin/bash ' . escapeshellarg( __DIR__ . '/limit.sh' ) . ' ' .
335  escapeshellarg( $cmd ) . ' ' .
336  escapeshellarg(
337  "MW_INCLUDE_STDERR=" . ( $this->doIncludeStderr ? '1' : '' ) . ';' .
338  "MW_CPU_LIMIT=$time; " .
339  'MW_CGROUP=' . escapeshellarg( $this->cgroup ) . '; ' .
340  "MW_MEM_LIMIT=$mem; " .
341  "MW_FILE_SIZE_LIMIT=$filesize; " .
342  "MW_WALL_CLOCK_LIMIT=$wallTime; " .
343  "MW_USE_LOG_PIPE=yes"
344  );
345  $useLogPipe = true;
346  }
347  }
348  if ( !$useLogPipe && $this->doIncludeStderr ) {
349  $cmd .= ' 2>&1';
350  }
351 
352  if ( wfIsWindows() ) {
353  $cmd = 'cmd.exe /c "' . $cmd . '"';
354  }
355 
356  return [ $cmd, $useLogPipe ];
357  }
358 
368  public function execute() {
369  $this->everExecuted = true;
370 
371  $profileMethod = $this->method ?: wfGetCaller();
372 
373  list( $cmd, $useLogPipe ) = $this->buildFinalCommand( $this->command );
374 
375  $this->logger->debug( __METHOD__ . ": $cmd" );
376 
377  // Don't try to execute commands that exceed Linux's MAX_ARG_STRLEN.
378  // Other platforms may be more accomodating, but we don't want to be
379  // accomodating, because very long commands probably include user
380  // input. See T129506.
381  if ( strlen( $cmd ) > SHELL_MAX_ARG_STRLEN ) {
382  throw new Exception( __METHOD__ .
383  '(): total length of $cmd must not exceed SHELL_MAX_ARG_STRLEN' );
384  }
385 
386  $desc = [
387  0 => $this->inputString === null ? [ 'file', 'php://stdin', 'r' ] : [ 'pipe', 'r' ],
388  1 => [ 'pipe', 'w' ],
389  2 => [ 'pipe', 'w' ],
390  ];
391  if ( $useLogPipe ) {
392  $desc[3] = [ 'pipe', 'w' ];
393  }
394  $pipes = null;
395  $scoped = Profiler::instance()->scopedProfileIn( __FUNCTION__ . '-' . $profileMethod );
396  $proc = null;
397 
398  if ( wfIsWindows() ) {
399  // Windows Shell bypassed, but command run is "cmd.exe /C "{$cmd}"
400  // This solves some shell parsing issues, see T207248
401  $proc = proc_open( $cmd, $desc, $pipes, null, null, [ 'bypass_shell' => true ] );
402  } else {
403  $proc = proc_open( $cmd, $desc, $pipes );
404  }
405 
406  if ( !$proc ) {
407  $this->logger->error( "proc_open() failed: {command}", [ 'command' => $cmd ] );
408  throw new ProcOpenError();
409  }
410 
411  $buffers = [
412  0 => $this->inputString, // input
413  1 => '', // stdout
414  2 => null, // stderr
415  3 => '', // log
416  ];
417  $emptyArray = [];
418  $status = false;
419  $logMsg = false;
420 
421  /* According to the documentation, it is possible for stream_select()
422  * to fail due to EINTR. I haven't managed to induce this in testing
423  * despite sending various signals. If it did happen, the error
424  * message would take the form:
425  *
426  * stream_select(): unable to select [4]: Interrupted system call (max_fd=5)
427  *
428  * where [4] is the value of the macro EINTR and "Interrupted system
429  * call" is string which according to the Linux manual is "possibly"
430  * localised according to LC_MESSAGES.
431  */
432  $eintr = defined( 'SOCKET_EINTR' ) ? SOCKET_EINTR : 4;
433  $eintrMessage = "stream_select(): unable to select [$eintr]";
434 
435  /* The select(2) system call only guarantees a "sufficiently small write"
436  * can be made without blocking. And on Linux the read might block too
437  * in certain cases, although I don't know if any of them can occur here.
438  * Regardless, set all the pipes to non-blocking to avoid T184171.
439  */
440  foreach ( $pipes as $pipe ) {
441  stream_set_blocking( $pipe, false );
442  }
443 
444  $running = true;
445  $timeout = null;
446  $numReadyPipes = 0;
447 
448  while ( $pipes && ( $running === true || $numReadyPipes !== 0 ) ) {
449  if ( $running ) {
450  $status = proc_get_status( $proc );
451  // If the process has terminated, switch to nonblocking selects
452  // for getting any data still waiting to be read.
453  if ( !$status['running'] ) {
454  $running = false;
455  $timeout = 0;
456  }
457  }
458 
459  // clear get_last_error without actually raising an error
460  // from http://php.net/manual/en/function.error-get-last.php#113518
461  // TODO replace with clear_last_error when requirements are bumped to PHP7
462  set_error_handler( function () {
463  }, 0 );
464  // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
465  @trigger_error( '' );
466  restore_error_handler();
467 
468  $readPipes = wfArrayFilterByKey( $pipes, function ( $fd ) use ( $desc ) {
469  return $desc[$fd][0] === 'pipe' && $desc[$fd][1] === 'r';
470  } );
471  $writePipes = wfArrayFilterByKey( $pipes, function ( $fd ) use ( $desc ) {
472  return $desc[$fd][0] === 'pipe' && $desc[$fd][1] === 'w';
473  } );
474  // stream_select parameter names are from the POV of us being able to do the operation;
475  // proc_open desriptor types are from the POV of the process doing it.
476  // So $writePipes is passed as the $read parameter and $readPipes as $write.
477  // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
478  $numReadyPipes = @stream_select( $writePipes, $readPipes, $emptyArray, $timeout );
479  if ( $numReadyPipes === false ) {
480  $error = error_get_last();
481  if ( strncmp( $error['message'], $eintrMessage, strlen( $eintrMessage ) ) == 0 ) {
482  continue;
483  } else {
484  trigger_error( $error['message'], E_USER_WARNING );
485  $logMsg = $error['message'];
486  break;
487  }
488  }
489  foreach ( $writePipes + $readPipes as $fd => $pipe ) {
490  // True if a pipe is unblocked for us to write into, false if for reading from
491  $isWrite = array_key_exists( $fd, $readPipes );
492 
493  if ( $isWrite ) {
494  // Don't bother writing if the buffer is empty
495  if ( $buffers[$fd] === '' ) {
496  fclose( $pipes[$fd] );
497  unset( $pipes[$fd] );
498  continue;
499  }
500  $res = fwrite( $pipe, $buffers[$fd], 65536 );
501  } else {
502  $res = fread( $pipe, 65536 );
503  }
504 
505  if ( $res === false ) {
506  $logMsg = 'Error ' . ( $isWrite ? 'writing to' : 'reading from' ) . ' pipe';
507  break 2;
508  }
509 
510  if ( $res === '' || $res === 0 ) {
511  // End of file?
512  if ( feof( $pipe ) ) {
513  fclose( $pipes[$fd] );
514  unset( $pipes[$fd] );
515  }
516  } elseif ( $isWrite ) {
517  $buffers[$fd] = (string)substr( $buffers[$fd], $res );
518  if ( $buffers[$fd] === '' ) {
519  fclose( $pipes[$fd] );
520  unset( $pipes[$fd] );
521  }
522  } else {
523  $buffers[$fd] .= $res;
524  if ( $fd === 3 && strpos( $res, "\n" ) !== false ) {
525  // For the log FD, every line is a separate log entry.
526  $lines = explode( "\n", $buffers[3] );
527  $buffers[3] = array_pop( $lines );
528  foreach ( $lines as $line ) {
529  $this->logger->info( $line );
530  }
531  }
532  }
533  }
534  }
535 
536  foreach ( $pipes as $pipe ) {
537  fclose( $pipe );
538  }
539 
540  // Use the status previously collected if possible, since proc_get_status()
541  // just calls waitpid() which will not return anything useful the second time.
542  if ( $running ) {
543  $status = proc_get_status( $proc );
544  }
545 
546  if ( $logMsg !== false ) {
547  // Read/select error
548  $retval = -1;
549  proc_close( $proc );
550  } elseif ( $status['signaled'] ) {
551  $logMsg = "Exited with signal {$status['termsig']}";
552  $retval = 128 + $status['termsig'];
553  proc_close( $proc );
554  } else {
555  if ( $status['running'] ) {
556  $retval = proc_close( $proc );
557  } else {
558  $retval = $status['exitcode'];
559  proc_close( $proc );
560  }
561  if ( $retval == 127 ) {
562  $logMsg = "Possibly missing executable file";
563  } elseif ( $retval >= 129 && $retval <= 192 ) {
564  $logMsg = "Probably exited with signal " . ( $retval - 128 );
565  }
566  }
567 
568  if ( $logMsg !== false ) {
569  $this->logger->warning( "$logMsg: {command}", [ 'command' => $cmd ] );
570  }
571 
572  if ( $buffers[2] && $this->doLogStderr ) {
573  $this->logger->error( "Error running {command}: {error}", [
574  'command' => $cmd,
575  'error' => $buffers[2],
576  'exitcode' => $retval,
577  'exception' => new Exception( 'Shell error' ),
578  ] );
579  }
580 
581  return new Result( $retval, $buffers[1], $buffers[2] );
582  }
583 }
$time
see documentation in includes Linker php for Linker::makeImageLink & $time
Definition: hooks.txt:1795
MediaWiki\Shell\Command\$everExecuted
bool $everExecuted
Definition: Command.php:69
MediaWiki\Shell\Result
Returned by MediaWiki\Shell\Command::execute()
Definition: Result.php:28
MediaWiki\Shell\Command\$doIncludeStderr
bool $doIncludeStderr
Definition: Command.php:63
MediaWiki\Shell\Command\__destruct
__destruct()
Destructor.
Definition: Command.php:97
use
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
Definition: APACHE-LICENSE-2.0.txt:10
MediaWiki\ProcOpenError
Definition: ProcOpenError.php:25
MediaWiki\Shell\Command\profileMethod
profileMethod( $method)
Sets calling function for profiler.
Definition: Command.php:189
MediaWiki\Shell\Command\restrict
restrict( $restrictions)
Set restrictions for this request, overwriting any previously set restrictions.
Definition: Command.php:266
Profiler\instance
static instance()
Singleton.
Definition: Profiler.php:62
array
the array() calling protocol came about after MediaWiki 1.4rc1.
string
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
MediaWiki\Shell\Command
Class used for executing shell commands.
Definition: Command.php:35
MediaWiki\Shell\Command\$inputString
string null $inputString
Definition: Command.php:60
MediaWiki\Shell\Command\cgroup
cgroup( $cgroup)
Sets cgroup for this command.
Definition: Command.php:238
MediaWiki\Shell\Command\limits
limits(array $limits)
Sets execution limits.
Definition: Command.php:160
MediaWiki\Shell\Command\hasRestriction
hasRestriction( $restriction)
Bitfield helper on whether a specific restriction is enabled.
Definition: Command.php:279
MediaWiki\Shell\Command\$restrictions
int $restrictions
bitfield with restrictions
Definition: Command.php:79
$res
$res
Definition: database.txt:21
wfArrayFilterByKey
wfArrayFilterByKey(array $arr, callable $callback)
Like array_filter with ARRAY_FILTER_USE_KEY, but works pre-5.6.
Definition: GlobalFunctions.php:168
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:37
MediaWiki\Shell\Command\unsafeParams
unsafeParams()
Adds unsafe parameters to the command.
Definition: Command.php:136
MediaWiki\Shell\Command\logStderr
logStderr( $yesno=true)
When enabled, text sent to stderr will be logged with a level of 'error'.
Definition: Command.php:226
Profiler
Profiler base class that defines the interface and some trivial functionality.
Definition: Profiler.php:33
SHELL_MAX_ARG_STRLEN
const SHELL_MAX_ARG_STRLEN
Definition: Defines.php:280
MediaWiki\Shell\Command\$env
string[] $env
Definition: Command.php:54
$lines
$lines
Definition: router.php:61
MediaWiki\Shell\Command\includeStderr
includeStderr( $yesno=true)
Controls whether stderr should be included in stdout, including errors from limit....
Definition: Command.php:214
MediaWiki\Shell\Command\environment
environment(array $env)
Sets environment variables which should be added to the executed command environment.
Definition: Command.php:177
MediaWiki\Shell\Shell\isDisabled
static isDisabled()
Check if this class is effectively disabled via php.ini config.
Definition: Shell.php:138
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
$line
$line
Definition: cdb.php:59
MediaWiki\Shell\Command\$command
string $command
Definition: Command.php:39
$value
$value
Definition: styleTest.css.php:45
MediaWiki\Shell\Command\$doLogStderr
bool $doLogStderr
Definition: Command.php:66
wfIsWindows
wfIsWindows()
Check if the operating system is Windows.
Definition: GlobalFunctions.php:2019
MediaWiki\ShellDisabledError
Definition: ShellDisabledError.php:28
$status
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. '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:1255
MediaWiki\Shell\Command\input
input( $inputString)
Sends the provided input to the command.
Definition: Command.php:201
MediaWiki\Shell\Shell\escape
static escape()
Version of escapeshellarg() that works better on Windows.
Definition: Shell.php:164
$args
if( $line===false) $args
Definition: cdb.php:64
MediaWiki\Shell
Copyright (C) 2017 Kunal Mehta legoktm@member.fsf.org
Definition: Command.php:21
MediaWiki\Shell\Command\$limits
array $limits
Definition: Command.php:42
as
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
Definition: distributors.txt:22
MediaWiki\Shell\Command\$cgroup
string false $cgroup
Definition: Command.php:72
MediaWiki\Shell\Command\$method
string $method
Definition: Command.php:57
MediaWiki\$context
IContextSource $context
Definition: MediaWiki.php:38
MediaWiki\Shell\Command\whitelistPaths
whitelistPaths(array $paths)
If called, only the files/directories that are whitelisted will be available to the shell command.
Definition: Command.php:293
MediaWiki\Shell\Command\buildFinalCommand
buildFinalCommand( $command)
String together all the options and build the final command to execute.
Definition: Command.php:305
MediaWiki\Shell\Command\execute
execute()
Executes command.
Definition: Command.php:368
$retval
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 incomplete not yet checked for validity & $retval
Definition: hooks.txt:266
wfGetCaller
wfGetCaller( $level=2)
Get the name of the function which called this function wfGetCaller( 1 ) is the function with the wfG...
Definition: GlobalFunctions.php:1547
MediaWiki\Shell\Command\__construct
__construct()
Constructor.
Definition: Command.php:86
MediaWiki\Shell\Command\params
params()
Adds parameters to the command.
Definition: Command.php:117