MediaWiki  1.30.0
MediaWiki\Shell\Shell Class Reference

Executes shell commands. More...

Static Public Member Functions

static command ( $command)
 Returns a new instance of Command class. More...
 
static escape ()
 Version of escapeshellarg() that works better on Windows. More...
 
static isDisabled ()
 Check if this class is effectively disabled via php.ini config. More...
 

Detailed Description

Executes shell commands.

Since
1.30

Use call chaining with this class for expressiveness: $result = Shell::command( 'some command' ) ->environment( [ 'ENVIRONMENT_VARIABLE' => 'VALUE' ] ) ->limits( [ 'time' => 300 ] ) ->execute();

... = $result->getExitCode(); ... = $result->getStdout();

Definition at line 41 of file Shell.php.

Member Function Documentation

◆ command()

static MediaWiki\Shell\Shell::command (   $command)
static

Returns a new instance of Command class.

Parameters
string | string[]$commandString or array of strings representing the command to be executed, each value will be escaped. Example: [ 'convert', '-font', 'font name' ] would produce "'convert' '-font' 'font name'"
Returns
Command

Definition at line 51 of file Shell.php.

References $args, $command, captcha-old\count, and MediaWiki\MediaWikiServices\getInstance().

◆ escape()

static MediaWiki\Shell\Shell::escape ( )
static

Version of escapeshellarg() that works better on Windows.

Originally, this fixed the incorrect use of single quotes on Windows (https://bugs.php.net/bug.php?id=26285) and the locale problems on Linux in PHP 5.2.6+ (bug backported to earlier distro releases of PHP).

Parameters
string$args,...strings to escape and glue together, or a single array of strings parameter. Null values are ignored.
Returns
string

Definition at line 96 of file Shell.php.

References $args, $tokens, as, captcha-old\count, and wfIsWindows().

Referenced by MediaWiki\Shell\Command\params().

◆ isDisabled()

static MediaWiki\Shell\Shell::isDisabled ( )
static

Check if this class is effectively disabled via php.ini config.

Returns
bool

Definition at line 70 of file Shell.php.

References wfDebug().

Referenced by MediaWiki\Shell\Command\__construct().


The documentation for this class was generated from the following file: