mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-23 21:53:35 +00:00
Fix a bug in the return value of the CachingParser
This has always been wrong, and remained unnoticed. Also added a typehint for added safety. Change-Id: I8a3c31e7385283d95b4712d457784016239a0b3b
This commit is contained in:
parent
7addec7b4a
commit
fa76405ea7
|
@ -44,7 +44,7 @@ class AbuseFilterCachingParser extends AbuseFilterParser {
|
|||
* @param string $code
|
||||
* @return AFPData
|
||||
*/
|
||||
public function intEval( $code ) {
|
||||
public function intEval( $code ) : AFPData {
|
||||
static $cache = null;
|
||||
if ( !$cache ) {
|
||||
$cache = ObjectCache::getLocalServerInstance( 'hash' );
|
||||
|
@ -285,6 +285,7 @@ class AbuseFilterCachingParser extends AbuseFilterParser {
|
|||
}
|
||||
$array = $this->mVariables->getVar( $varName );
|
||||
|
||||
$value = $this->evalNode( $value );
|
||||
if ( $array->getType() !== AFPData::DUNDEFINED ) {
|
||||
// If it's a DUNDEFINED, leave it as is
|
||||
if ( $array->getType() !== AFPData::DARRAY ) {
|
||||
|
@ -299,7 +300,7 @@ class AbuseFilterCachingParser extends AbuseFilterParser {
|
|||
[ $offset, count( $array ) ] );
|
||||
}
|
||||
|
||||
$array[$offset] = $this->evalNode( $value );
|
||||
$array[$offset] = $value;
|
||||
$this->setUserVariable( $varName, new AFPData( AFPData::DARRAY, $array ) );
|
||||
}
|
||||
|
||||
|
|
3
tests/parserTests/array-statements.t
Normal file
3
tests/parserTests/array-statements.t
Normal file
|
@ -0,0 +1,3 @@
|
|||
/* CachingParser's intEval used to return AFPTreeNode for this */
|
||||
var := [1];
|
||||
var[0] := 2;
|
3
tests/parserTests/array-statements2.t
Normal file
3
tests/parserTests/array-statements2.t
Normal file
|
@ -0,0 +1,3 @@
|
|||
/* CachingParser's intEval used to return AFPTreeNode for this */
|
||||
var := [1];
|
||||
var[0] := str_replace('a','b','c');
|
Loading…
Reference in a new issue