Fix-up for I32bad5fd9

Don't return nonexistent variable $content, and don't bypass loadString / callFunction.

Change-Id: Iae493606d0167853c3c79536e35eeb23a54bb6d1
This commit is contained in:
Ori Livneh 2015-08-25 17:36:26 -07:00
parent 7bd4959b55
commit eec31286bc

View file

@ -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 ) );