mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-12-12 08:25:10 +00:00
18d122b60d
This reverts commit 62e1fb0b5f
.
Reason for revert: caused several errors:
* unnamespaced HooksTest collides with core’s class of the same name
* Scribunto_LuaError renamed without class alias despite being used in Wikibase
Bug: T314464
Change-Id: I8b151327236bf86945e59823fba155497e4b3fc6
37 lines
742 B
PHP
37 lines
742 B
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\Scribunto\Engines\LuaSandbox;
|
|
|
|
use LuaSandboxRuntimeError;
|
|
use Scribunto_LuaError;
|
|
|
|
class LuaSandboxCallback {
|
|
|
|
/**
|
|
* @var callable
|
|
*/
|
|
protected $callback;
|
|
|
|
/**
|
|
* @param callable $callback
|
|
*/
|
|
public function __construct( $callback ) {
|
|
$this->callback = $callback;
|
|
}
|
|
|
|
/**
|
|
* We use __call with a variable function name so that LuaSandbox will be
|
|
* able to return a meaningful function name in profiling data.
|
|
* @param string $funcName
|
|
* @param array $args
|
|
* @return mixed
|
|
*/
|
|
public function __call( $funcName, $args ) {
|
|
try {
|
|
return ( $this->callback )( ...$args );
|
|
} catch ( Scribunto_LuaError $e ) {
|
|
throw new LuaSandboxRuntimeError( $e->getLuaMessage() );
|
|
}
|
|
}
|
|
}
|