mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-23 21:53:35 +00:00
Merge "Add page_age variable to AbuseFilter"
This commit is contained in:
commit
46d78623f4
|
@ -316,14 +316,17 @@
|
|||
"abusefilter-edit-builder-vars-page-ns": "Page namespace",
|
||||
"abusefilter-edit-builder-vars-page-title": "Page title (without namespace)",
|
||||
"abusefilter-edit-builder-vars-page-prefixedtitle": "Full page title",
|
||||
"abusefilter-edit-builder-vars-page-age": "Page age (in seconds)",
|
||||
"abusefilter-edit-builder-vars-movedfrom-id": "Page ID of move source page",
|
||||
"abusefilter-edit-builder-vars-movedfrom-ns": "Namespace of move source page",
|
||||
"abusefilter-edit-builder-vars-movedfrom-title": "Title of move source page",
|
||||
"abusefilter-edit-builder-vars-movedfrom-prefixedtitle": "Full title of move source page",
|
||||
"abusefilter-edit-builder-vars-movedfrom-age": "Move source page age (in seconds)",
|
||||
"abusefilter-edit-builder-vars-movedto-id": "Page ID of move destination page",
|
||||
"abusefilter-edit-builder-vars-movedto-ns": "Namespace of move destination page",
|
||||
"abusefilter-edit-builder-vars-movedto-title": "Title of move destination page",
|
||||
"abusefilter-edit-builder-vars-movedto-prefixedtitle": "Full title of move destination page",
|
||||
"abusefilter-edit-builder-vars-movedto-age": "Move destination page age (in seconds)",
|
||||
"abusefilter-edit-builder-vars-user-editcount": "Edit count of the user",
|
||||
"abusefilter-edit-builder-vars-user-age": "Age of the user account",
|
||||
"abusefilter-edit-builder-vars-user-name": "Name of the user account",
|
||||
|
|
|
@ -349,14 +349,17 @@
|
|||
"abusefilter-edit-builder-vars-page-ns": "The namespace that the page for the trigger is supposed to be in. Abuse filter syntax option in a dropdown from the group {{msg-mw|abusefilter-edit-builder-group-vars}}.",
|
||||
"abusefilter-edit-builder-vars-page-title": "Abuse filter syntax option in a dropdown from the group {{msg-mw|abusefilter-edit-builder-group-vars}}.",
|
||||
"abusefilter-edit-builder-vars-page-prefixedtitle": "Abuse filter syntax option in a dropdown from the group {{msg-mw|abusefilter-edit-builder-group-vars}}.",
|
||||
"abusefilter-edit-builder-vars-page-age": "Abuse filter syntax option in a dropdown from the group {{msg-mw|abusefilter-edit-builder-group-vars}}.",
|
||||
"abusefilter-edit-builder-vars-movedfrom-id": "Paraphrase: The page ID of the page to be moved. Abuse filter syntax option in a dropdown from the group {{msg-mw|abusefilter-edit-builder-group-vars}}.",
|
||||
"abusefilter-edit-builder-vars-movedfrom-ns": "Paraphrase: Namespace of the page that is to be moved. Abuse filter syntax option in a dropdown from the group {{msg-mw|abusefilter-edit-builder-group-vars}}.",
|
||||
"abusefilter-edit-builder-vars-movedfrom-title": "Paraphrase: Name of the page that is to be moved. Abuse filter syntax option in a dropdown from the group {{msg-mw|abusefilter-edit-builder-group-vars}}.",
|
||||
"abusefilter-edit-builder-vars-movedfrom-prefixedtitle": "Paraphrase: Full name of the page that is to be moved. Abuse filter syntax option in a dropdown from the group {{msg-mw|abusefilter-edit-builder-group-vars}}.",
|
||||
"abusefilter-edit-builder-vars-movedfrom-age": "Paraphrase: The number of seconds since the first revision was made on the page that is to be moved. Abuse filter syntax option in a dropdown from the group {{msg-mw|abusefilter-edit-builder-group-vars}}.",
|
||||
"abusefilter-edit-builder-vars-movedto-id": "Paraphrased: Page ID of the destination of the page that is to be moved. Abuse filter syntax option in a dropdown from the group {{msg-mw|abusefilter-edit-builder-group-vars}}.",
|
||||
"abusefilter-edit-builder-vars-movedto-ns": "Paraphrased: Namespace of the destination of the page that is to be moved. Abuse filter syntax option in a dropdown from the group {{msg-mw|abusefilter-edit-builder-group-vars}}.",
|
||||
"abusefilter-edit-builder-vars-movedto-title": "Paraphrased: Name of the destination of the page that is to be moved. Abuse filter syntax option in a dropdown from the group {{msg-mw|abusefilter-edit-builder-group-vars}}.",
|
||||
"abusefilter-edit-builder-vars-movedto-prefixedtitle": "Paraphrased: Full name of the destination of the page that is to be moved. Abuse filter syntax option in a dropdown from the group {{msg-mw|abusefilter-edit-builder-group-vars}}.",
|
||||
"abusefilter-edit-builder-vars-movedto-age": "Paraphrase: The number of seconds since the first revision was made on the destination of the page that is to be moved. Returns zero when page is non-existent. Abuse filter syntax option in a dropdown from the group {{msg-mw|abusefilter-edit-builder-group-vars}}.",
|
||||
"abusefilter-edit-builder-vars-user-editcount": "Abuse filter syntax option in a dropdown from the group {{msg-mw|abusefilter-edit-builder-group-vars}}.",
|
||||
"abusefilter-edit-builder-vars-user-age": "Abuse filter syntax option in a dropdown from the group {{msg-mw|abusefilter-edit-builder-group-vars}}.",
|
||||
"abusefilter-edit-builder-vars-user-name": "Abuse filter syntax option in a dropdown from the group {{msg-mw|abusefilter-edit-builder-group-vars}}.",
|
||||
|
|
|
@ -371,6 +371,18 @@ class AFComputedVariable {
|
|||
$registration = $obj->getRegistration();
|
||||
$result = wfTimestamp( TS_UNIX, $asOf ) - wfTimestampOrNull( TS_UNIX, $registration );
|
||||
break;
|
||||
case 'page-age':
|
||||
$title = Title::makeTitle( $parameters['namespace'], $parameters['title'] );
|
||||
|
||||
$firstRevisionTime = $title->getEarliestRevTime();
|
||||
if ( !$firstRevisionTime ) {
|
||||
$result = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
$asOf = $parameters['asof'];
|
||||
$result = wfTimestamp( TS_UNIX, $asOf ) - wfTimestampOrNull( TS_UNIX, $firstRevisionTime );
|
||||
break;
|
||||
case 'user-groups':
|
||||
// Deprecated but needed by old log entries
|
||||
$user = $parameters['user'];
|
||||
|
|
|
@ -113,14 +113,17 @@ class AbuseFilter {
|
|||
'page_namespace' => 'page-ns',
|
||||
'page_title' => 'page-title',
|
||||
'page_prefixedtitle' => 'page-prefixedtitle',
|
||||
'page_age' => 'page-age',
|
||||
'moved_from_id' => 'movedfrom-id',
|
||||
'moved_from_namespace' => 'movedfrom-ns',
|
||||
'moved_from_title' => 'movedfrom-title',
|
||||
'moved_from_prefixedtitle' => 'movedfrom-prefixedtitle',
|
||||
'moved_from_age' => 'movedfrom-age',
|
||||
'moved_to_id' => 'movedto-id',
|
||||
'moved_to_namespace' => 'movedto-ns',
|
||||
'moved_to_title' => 'movedto-title',
|
||||
'moved_to_prefixedtitle' => 'movedto-prefixedtitle',
|
||||
'moved_to_age' => 'movedto-age',
|
||||
'user_editcount' => 'user-editcount',
|
||||
'user_age' => 'user-age',
|
||||
'user_name' => 'user-name',
|
||||
|
@ -447,6 +450,13 @@ class AbuseFilter {
|
|||
'namespace' => $title->getNamespace()
|
||||
] );
|
||||
|
||||
$vars->setLazyLoadVar( "{$prefix}_age", 'page-age',
|
||||
[
|
||||
'title' => $title->getText(),
|
||||
'namespace' => $title->getNamespace(),
|
||||
'asof' => wfTimestampNow()
|
||||
] );
|
||||
|
||||
$vars->setLazyLoadVar( "{$prefix}_first_contributor", 'load-first-author',
|
||||
[
|
||||
'title' => $title->getText(),
|
||||
|
|
|
@ -154,7 +154,8 @@ class AbuseFilterVariableHolder {
|
|||
'_NAMESPACE',
|
||||
'_TITLE',
|
||||
'_PREFIXEDTITLE',
|
||||
'_recent_contributors'
|
||||
'_recent_contributors',
|
||||
'_age',
|
||||
];
|
||||
foreach ( $wgRestrictionTypes as $action ) {
|
||||
$titleVars[] = "_restrictions_$action";
|
||||
|
@ -204,6 +205,7 @@ class AbuseFilterVariableHolder {
|
|||
static $dbTypes = [
|
||||
'links-from-wikitext-or-database',
|
||||
'load-recent-authors',
|
||||
'page-age',
|
||||
'get-page-restrictions',
|
||||
'simple-user-accessor',
|
||||
'user-age',
|
||||
|
|
Loading…
Reference in a new issue