Go to the documentation of this file.
19 if ( $params[
'session'] ) {
20 $sessionId = $params[
'session'];
22 $sessionId = mt_rand( 0, 0x7fffffff );
26 $sessionKey =
$cache->makeKey(
'scribunto-console', $this->
getUser()->getId(), $sessionId );
28 $sessionIsNew =
false;
29 if ( $params[
'session'] ) {
30 $session =
$cache->get( $sessionKey );
32 if ( !isset( $session[
'version'] ) ) {
41 $newSession = $session;
43 if ( !empty( $params[
'clear'] ) ) {
44 $newSession[
'size'] -= strlen( implode(
'', $newSession[
'questions'] ) );
45 $newSession[
'questions'] = [];
46 $session[
'questions'] = [];
48 if ( strlen( $params[
'question'] ) ) {
49 $newSession[
'size'] += strlen( $params[
'question'] );
50 $newSession[
'questions'][] = $params[
'question'];
52 if ( $params[
'content'] ) {
53 $newSession[
'size'] += strlen( $params[
'content'] ) - strlen( $newSession[
'content'] );
54 $newSession[
'content'] = $params[
'content'];
57 if ( $newSession[
'size'] > self::SC_MAX_SIZE ) {
62 'content' => $newSession[
'content'],
63 'prevQuestions' => $session[
'questions'],
64 'question' => $params[
'question'],
67 if ( $result[
'type'] ===
'error' ) {
69 $newSession[
'questions'] = $session[
'questions'];
71 $cache->set( $sessionKey, $newSession, self::SC_SESSION_EXPIRY );
72 $result[
'session'] = $sessionId;
73 $result[
'sessionSize'] = $newSession[
'size'];
75 if ( $sessionIsNew ) {
76 $result[
'sessionIsNew'] =
'';
78 foreach ( $result as $key => $value ) {
79 $this->
getResult()->addValue(
null, $key, $value );
89 $result = $engine->runConsole( $params );
92 $message = $e->getMessage();
93 $html = Html::element(
'p', [], $message );
94 if ( $trace !==
false ) {
95 $html .= Html::element(
'p',
97 $this->
msg(
'scribunto-common-backtrace' )->inContentLanguage()->text()
104 'message' => $message,
109 'print' => strval( $result[
'print'] ),
110 'return' => strval( $result[
'return'] )
Set options of the Parser.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
const PARAM_REQUIRED
(boolean) Is the parameter required?
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
Abort execution with an error.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
getResult()
Get the result object.
This abstract class implements many basic API functions, and is the base of all API classes.
API module for serving debug console requests on the edit page.
static getParserEngine(Parser $parser)
Get an engine instance for the given parser, and cache it in the parser so that subsequent calls to t...
isInternal()
Indicates whether this module is "internal" Internal API modules are not (yet) intended for 3rd party...
static getInstance( $id)
Get a cached instance of the specified type of cache object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
getScriptTraceHtml( $options=[])
Get the backtrace as HTML, or false if there is none available.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
runConsole(array $params)
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
An exception class which represents an error in the script.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...