mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-11-27 17:50:06 +00:00
Fix-up for I32bad5fd9
Don't return nonexistent variable $content, and don't bypass loadString / callFunction. Change-Id: Iae493606d0167853c3c79536e35eeb23a54bb6d1
This commit is contained in:
parent
7bd4959b55
commit
eec31286bc
|
@ -316,17 +316,21 @@ abstract class Scribunto_LuaEngine extends ScribuntoEngineBase {
|
|||
|
||||
$cacheKey = wfGlobalCacheKey( __CLASS__, $fileName );
|
||||
$fileData = $cache->get( $cacheKey );
|
||||
|
||||
$code = false;
|
||||
if ( $fileData ) {
|
||||
list( $code, $cachedMtime ) = $fileData;
|
||||
if ( $cachedMtime >= $mtime ) {
|
||||
return $content;
|
||||
if ( $cachedMtime < $mtime ) {
|
||||
$code = false;
|
||||
}
|
||||
}
|
||||
$code = file_get_contents( $fileName );
|
||||
if ( $code === false ) {
|
||||
throw new MWException( 'Lua file does not exist: ' . $fileName );
|
||||
if ( !$code ) {
|
||||
$code = file_get_contents( $fileName );
|
||||
if ( $code === false ) {
|
||||
throw new MWException( 'Lua file does not exist: ' . $fileName );
|
||||
}
|
||||
$cache->set( $cacheKey, array( $code, $mtime ), 60 * 5 );
|
||||
}
|
||||
$cache->set( $cacheKey, array( $code, $mtime ), 60 * 5 );
|
||||
|
||||
# Prepending an "@" to the chunk name makes Lua think it is a filename
|
||||
$module = $this->getInterpreter()->loadString( $code, '@' . basename( $fileName ) );
|
||||
|
|
Loading…
Reference in a new issue