mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-24 06:03:49 +00:00
Merge "Add a new data type for non-initialized stuff"
This commit is contained in:
commit
35ab35978b
|
@ -8,6 +8,9 @@ class AFPData {
|
|||
const DBOOL = 'bool';
|
||||
const DFLOAT = 'float';
|
||||
const DARRAY = 'array';
|
||||
// Special purpose type for non-initialized stuff
|
||||
// @todo WIP, still equivalent to null for now
|
||||
const DNONE = 'null';
|
||||
|
||||
// Translation table mapping shell-style wildcards to PCRE equivalents.
|
||||
// Derived from <http://www.php.net/manual/en/function.fnmatch.php#100207>
|
||||
|
@ -36,7 +39,7 @@ class AFPData {
|
|||
* @param string $type
|
||||
* @param mixed|null $val
|
||||
*/
|
||||
public function __construct( $type = self::DNULL, $val = null ) {
|
||||
public function __construct( $type = self::DNONE, $val = null ) {
|
||||
$this->type = $type;
|
||||
$this->data = $val;
|
||||
}
|
||||
|
@ -63,7 +66,7 @@ class AFPData {
|
|||
}
|
||||
return new AFPData( self::DARRAY, $result );
|
||||
case 'NULL':
|
||||
return new AFPData();
|
||||
return new AFPData( self::DNULL );
|
||||
default:
|
||||
throw new AFPException(
|
||||
'Data type ' . gettype( $var ) . ' is not supported by AbuseFilter'
|
||||
|
@ -89,7 +92,7 @@ class AFPData {
|
|||
}
|
||||
if ( $target === self::DNULL ) {
|
||||
// We don't expose any method to cast to null. And, actually, should we?
|
||||
return new AFPData();
|
||||
return new AFPData( self::DNULL );
|
||||
}
|
||||
|
||||
if ( $orig->type === self::DARRAY ) {
|
||||
|
|
|
@ -104,7 +104,7 @@ class AbuseFilterCachingParser extends AbuseFilterParser {
|
|||
case "false":
|
||||
return new AFPData( AFPData::DBOOL, false );
|
||||
case "null":
|
||||
return new AFPData();
|
||||
return new AFPData( AFPData::DNULL );
|
||||
}
|
||||
// Fallthrough intended
|
||||
default:
|
||||
|
|
|
@ -851,7 +851,7 @@ class AbuseFilterParser {
|
|||
} elseif ( $tok === "false" ) {
|
||||
$result = new AFPData( AFPData::DBOOL, false );
|
||||
} elseif ( $tok === "null" ) {
|
||||
$result = new AFPData();
|
||||
$result = new AFPData( AFPData::DNULL );
|
||||
} else {
|
||||
throw new AFPUserVisibleException(
|
||||
'unrecognisedkeyword',
|
||||
|
|
Loading…
Reference in a new issue