mediawiki-extensions-Scribunto/engines/LuaCommon/LuaInterpreter.php
Brad Jorsch db07787390 Cleanup backwards-compatibility code
https://www.mediawiki.org/wiki/Extension:Scribunto says that master
requires 1.25+, so let's remove checks for stuff that was added before
that.

* PPFrame::getTTL() was in 1.24.
* PPFrame::setTTL() was in 1.24.
* PPFrame::isVolatile() was in 1.24.
* Parser::fetchCurrentRevisionOfTitle() was in 1.24.
* ObjectCache::getLocalServerInstance() was added in 1.27, so restore the call to ObjectCache::newAccelerator() as BC.

This also removes BC with the php-luasandbox extension older than 1.6, which
was released before MediaWiki 1.22.

Bug: T148012
Change-Id: I36e37f3b65d0f167e1d28b00e0842d9721feee31
2016-10-13 11:07:44 -04:00

68 lines
2 KiB
PHP

<?php
// @codingStandardsIgnoreLine Squiz.Classes.ValidClassName.NotCamelCaps
abstract class Scribunto_LuaInterpreter {
/**
* Load a string. Return an object which can later be passed to callFunction.
* If there is a pass error, a Scribunto_LuaError will be thrown.
*
* @param string $text The Lua source code
* @param string $chunkName The chunk name
*/
abstract public function loadString( $text, $chunkName );
/**
* Call a Lua function. Return an array of results, with indices starting
* at zero. If an error occurs, a Scribunto_LuaError will be thrown.
*
* @param mixed $func The function object
*/
abstract public function callFunction( $func /*...*/ );
/**
* Wrap a PHP callable as a Lua function, which can be passed back into
* Lua. If an error occurs, a Scribunto_LuaError will be thrown.
*
* @param callable $callable The PHP callable
* @return a Lua function
*/
abstract public function wrapPhpFunction( $callable );
/**
* Test whether an object is a Lua function.
*
* @param $object
* @return boolean
*/
abstract public function isLuaFunction( $object );
/**
* Register a library of functions.
*
* @param $name string The global variable name to be created or added to.
* @param $functions array An associative array mapping the function name to the
* callback. The callback may throw a Scribunto_LuaError, which will be
* caught and raised in the Lua code as a Lua error, catchable with
* pcall().
*/
abstract public function registerLibrary( $name, array $functions );
/**
* Pause CPU usage and limits
* @return void
*/
abstract public function pauseUsageTimer();
/**
* Unpause CPU usage and limits
* @return void
*/
abstract public function unpauseUsageTimer();
}
// @codingStandardsIgnoreLine Squiz.Classes.ValidClassName.NotCamelCaps
class Scribunto_LuaInterpreterNotFoundError extends MWException {}
// @codingStandardsIgnoreLine Squiz.Classes.ValidClassName.NotCamelCaps
class Scribunto_LuaInterpreterBadVersionError extends MWException {}