Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P5491
CheckAbuseFilterUsesExtensionDefined
Active
Public
Actions
Authored by
•
Mattflaschen-WMF
on May 27 2017, 1:06 AM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Referenced Files
F8193642: Masterwork From Distant Lands
May 27 2017, 1:06 AM
2017-05-27 01:06:30 (UTC+0)
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
edited the content of this paste.
(Show Details)
May 27 2017, 1:06 AM
2017-05-27 01:06:30 (UTC+0)
•
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
2017-05-27 01:09:28 (UTC+0)
•
Mattflaschen-WMF
mentioned this in
T92956: AbuseFilter needs better tag name validation
.
May 27 2017, 1:13 AM
2017-05-27 01:13:29 (UTC+0)
Log In to Comment