Dragons flight has uploaded a new change for review. https://gerrit.wikimedia.org/r/201086
Change subject: Adds "article_age" variable to AbuseFilter ...................................................................... Adds "article_age" variable to AbuseFilter Adds "article_age" variable that reports the number of seconds since the first edit to the current article (or 0 for new articles). Bug: T30844 Change-Id: I0993cecc322806382a1b567b60c0a4af69054841 --- M AbuseFilter.class.php M AbuseFilterVariableHolder.php 2 files changed, 24 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/AbuseFilter refs/changes/86/201086/1 diff --git a/AbuseFilter.class.php b/AbuseFilter.class.php index e8df9d9..a178069 100644 --- a/AbuseFilter.class.php +++ b/AbuseFilter.class.php @@ -88,6 +88,7 @@ 'old_size' => 'oldsize', 'removed_lines' => 'removedlines', 'summary' => 'summary', + 'article_age' => 'article-age', 'article_articleid' => 'article-id', 'article_namespace' => 'article-ns', 'article_text' => 'article-text', @@ -347,6 +348,16 @@ 'namespace' => $title->getNamespace() ) ); + $vars->setLazyLoadVar( + 'article_age', + 'article-age', + array( + 'title' => $title->getText(), + 'namespace' => $title->getNamespace(), + 'asof' => wfTimestampNow() + ) + ); + $vars->setLazyLoadVar( "{$prefix}_first_contributor", 'load-first-author', array( 'title' => $title->getText(), diff --git a/AbuseFilterVariableHolder.php b/AbuseFilterVariableHolder.php index b3702c9..783a8f0 100644 --- a/AbuseFilterVariableHolder.php +++ b/AbuseFilterVariableHolder.php @@ -174,6 +174,7 @@ 'get-page-restrictions', 'simple-user-accessor', 'user-age', + 'article-age', 'user-groups', 'user-rights', 'revision-text-by-id', @@ -572,6 +573,18 @@ $registration = $obj->getRegistration(); $result = wfTimestamp( TS_UNIX, $asOf ) - wfTimestampOrNull( TS_UNIX, $registration ); break; + case 'article-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']; -- To view, visit https://gerrit.wikimedia.org/r/201086 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0993cecc322806382a1b567b60c0a4af69054841 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/AbuseFilter Gerrit-Branch: master Gerrit-Owner: Dragons flight <ro...@robertrohde.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits