Re-add BC alias for the VariableHolder class

Looks like it's needed for the UpdateVarDumps script, so add a note
about that. Also add a type check to the script so that it produces a
clearer error message if it finds an entity with unexpected type.

Bug: T331861
Change-Id: I68f8f954ed754c4282e13599ce06118e2336ecbb
This commit is contained in:
Daimona Eaytoy 2023-03-13 13:46:09 +01:00
parent 0abb60955d
commit d5b810e23a
3 changed files with 12 additions and 1 deletions

View file

@ -212,6 +212,10 @@
"ExtensionMessagesFiles": {
"AbuseFilterAliases": "AbuseFilter.alias.php"
},
"AutoloadClasses": {
"AbuseFilterVariableHolder": "includes/Variables/VariableHolder.php",
"MediaWiki\\Extension\\AbuseFilter\\Variables\\VariableHolder": "includes/Variables/VariableHolder.php"
},
"AutoloadNamespaces": {
"MediaWiki\\Extension\\AbuseFilter\\": "includes/",
"MediaWiki\\Extension\\AbuseFilter\\Maintenance\\": "maintenance/"

View file

@ -112,3 +112,7 @@ class VariableHolder {
unset( $this->mVars[$varName] );
}
}
// @deprecated Since 1.36. Kept for BC with the UpdateVarDumps script, see T331861. The alias can be removed
// once we no longer support updating from a MW version where that script may run.
class_alias( VariableHolder::class, 'AbuseFilterVariableHolder' );

View file

@ -558,8 +558,11 @@ class UpdateVarDumps extends LoggedUpdateMaintenance {
if ( $obj instanceof VariableHolder ) {
$varManager = AbuseFilterServices::getVariablesManager();
$varArray = $varManager->dumpAllVars( $obj, [ 'old_wikitext', 'new_wikitext' ] );
} else {
} elseif ( is_array( $obj ) ) {
$varArray = $obj;
} else {
$type = is_object( $obj ) ? get_class( $obj ) : gettype( $obj );
throw new UnexpectedValueException( "Unexpected type for stored blob: $type" );
}
$varArray = $this->updateVariables( $varArray );
// Recreating flags will also ensure that we don't add 'nativeDataArray'