Page MenuHomePhabricator
Paste P5491

CheckAbuseFilterUsesExtensionDefined
ActivePublic

Authored by Mattflaschen-WMF on May 27 2017, 1:06 AM.
Tags
None
Referenced Files
F8193642: Masterwork From Distant Lands
May 27 2017, 1:06 AM
Subscribers
None
<?php
require_once __DIR__ . '/Maintenance.php';
use Wikimedia\TestingAccessWrapper;
class CheckAbuseFilterUsesExtensionDefined extends Maintenance {
public function execute() {
global $wgHooks;
// TestingAccessWrapper is currently not available in production,
// but https://gerrit.wikimedia.org/r/#/c/353212/ will fix that.
$classReflection = new ReflectionClass( 'ChangeTags' );
$propertyReflection = $classReflection->getProperty( 'coreTags' );
$propertyReflection->setAccessible( true );
$coreTags = $propertyReflection->getValue( 'ChangeTags' );
// XXX
$wgHooks['ListDefinedTags'] = array_udiff(
$wgHooks['ListDefinedTags'],
[ 'AbuseFilterHooks::onListDefinedTags' ],
function ( $a, $b ) {
if ( $a < $b ) {
return -1;
} elseif ( $a > $b ) {
return 1;
} else {
return 0;
}
}
);
echo "Subtracted listeners:\n";
var_export( $wgHooks['ListDefinedTags'] );
// Next three lines are a copy of ChangeTags::listSoftwareDefinedTags(), but bypassing
// cache.
$softwareDefinedTags = $coreTags;
Hooks::run( 'ListDefinedTags', [ &$softwareDefinedTags ] );
$softwareDefinedTags = array_filter( array_unique( $softwareDefinedTags ) );
$allAFTags = [];
AbuseFilterHooks::onListDefinedTags( $allAFTags );
$allSoftwareDefinedAF = array_intersect(
$allAFTags,
$softwareDefinedTags
);
echo "All software-defined tags used in AbuseFilter filters:\n";
var_export( $allSoftwareDefinedAF );
echo "\n\n";
$activeAFTags = [];
AbuseFilterHooks::onChangeTagsListActive( $activeAFTags );
$activeSoftwareDefinedAF = array_intersect(
$activeAFTags,
$softwareDefinedTags
);
echo "Software-defined tags used in enabled AbuseFilter filters:\n";
var_export( $activeSoftwareDefinedAF );
echo "\n\n";
}
}
$maintClass = 'CheckAbuseFilterUsesExtensionDefined';
require_once RUN_MAINTENANCE_IF_MAIN;

Event Timeline

Mattflaschen-WMF changed the title of this paste from untitled to Masterwork From Distant Lands.
Mattflaschen-WMF updated the paste's language from autodetect to autodetect.
Mattflaschen-WMF changed the title of this paste from Masterwork From Distant Lands to CheckAbuseFilterUsesExtensionDefined.May 27 2017, 1:09 AM