Liangent has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/145014

Change subject: Add new variable article_first_contributor
......................................................................

Add new variable article_first_contributor

Change-Id: I725b7150de52bdc6518f73a6302f850e8d596824
---
M AbuseFilter.class.php
M AbuseFilterVariableHolder.php
M i18n/en.json
M i18n/qqq.json
4 files changed, 31 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/AbuseFilter 
refs/changes/14/145014/1

diff --git a/AbuseFilter.class.php b/AbuseFilter.class.php
index a742959..3c3cc63 100644
--- a/AbuseFilter.class.php
+++ b/AbuseFilter.class.php
@@ -123,6 +123,7 @@
                        'article_restrictions_create' => 'restrictions-create',
                        'article_restrictions_upload' => 'restrictions-upload',
                        'article_recent_contributors' => 'recent-contributors',
+                       'article_first_contributor' => 'first-contributor',
 #                      'old_text' => 'old-text-stripped', # Disabled, 
performance
 #                      'old_html' => 'old-html', # Disabled, performance
                        'old_links' => 'old-links',
@@ -342,6 +343,12 @@
                                        'namespace' => $title->getNamespace()
                                ) );
 
+               $vars->setLazyLoadVar( "{$prefix}_first_contributor", 
'load-first-author',
+                               array(
+                                       'title' => $title->getText(),
+                                       'namespace' => $title->getNamespace()
+                               ) );
+
                wfRunHooks( 'AbuseFilter-generateTitleVars', array( $vars, 
$title, $prefix ) );
 
                return $vars;
diff --git a/AbuseFilterVariableHolder.php b/AbuseFilterVariableHolder.php
index fcc2c00..8f09b3c 100644
--- a/AbuseFilterVariableHolder.php
+++ b/AbuseFilterVariableHolder.php
@@ -504,6 +504,27 @@
                                }
                                $result = $users;
                                break;
+                       case 'load-first-author':
+                               $title = Title::makeTitle( 
$parameters['namespace'], $parameters['title'] );
+                               $result = '';
+
+                               if ( !$title->exists() ) {
+                                       break;
+                               }
+
+                               $dbr = wfGetDB( DB_SLAVE );
+                               $res = $dbr->selectField(
+                                       'revision',
+                                       'rev_user_text',
+                                       array( 'rev_page' => 
$title->getArticleID() ),
+                                       __METHOD__,
+                                       array( 'ORDER BY' => 'rev_timestamp' )
+                               );
+
+                               if ( $res !== false ) {
+                                       $result = $res;
+                               }
+                               break;
                        case 'get-page-restrictions':
                                $action = $parameters['action'];
                                $title = Title::makeTitle( 
$parameters['namespace'], $parameters['title'] );
diff --git a/i18n/en.json b/i18n/en.json
index ee959f1..cd6a187 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -264,6 +264,7 @@
     "abusefilter-edit-builder-vars-user-blocked": "Whether user is blocked",
     "abusefilter-edit-builder-vars-user-emailconfirm": "Time email address was 
confirmed",
     "abusefilter-edit-builder-vars-recent-contributors": "Last ten users to 
contribute to the page",
+    "abusefilter-edit-builder-vars-first-contributor": "First user to 
contribute to the page",
     "abusefilter-edit-builder-vars-all-links": "All external links in the new 
text",
     "abusefilter-edit-builder-vars-added-links": "All external links added in 
the edit",
     "abusefilter-edit-builder-vars-removed-links": "All external links removed 
in the edit",
@@ -393,4 +394,4 @@
     "abusefilter-import-intro": "You can use this interface to import filters 
from other wikis.\nOn the source wiki, click 
\"{{int:abusefilter-edit-export}}\" under \"{{int:abusefilter-edit-tools}}\" on 
the editing interface.\nCopy from the textbox that appears, and paste it into 
this textbox, then click \"{{int:abusefilter-import-submit}}\".",
     "abusefilter-import-submit": "Import data",
     "abusefilter-group-default": "Default"
-}
\ No newline at end of file
+}
diff --git a/i18n/qqq.json b/i18n/qqq.json
index fb92995..63ed93c 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -284,6 +284,7 @@
        "abusefilter-edit-builder-vars-user-groups": "See also:\n* 
{{msg-mw|Abusefilter-edit-builder-vars-global-user-groups}}",
        "abusefilter-edit-builder-vars-user-rights": "Paraphrased: List of 
rights that the user has. Abuse filter syntax option in a dropdown from the 
group {{msg-mw|abusefilter-edit-builder-group-vars}}.",
        "abusefilter-edit-builder-vars-user-blocked": "Paraphrased: Boolean 
value on whether the user is blocked. Abuse filter syntax option in a dropdown 
from the group {{msg-mw|abusefilter-edit-builder-group-vars}}.",
+       "abusefilter-edit-builder-vars-first-contributor": "Paraphrased: The 
user who created the earliest revision of the page. Abuse filter syntax option 
in a dropdown from the group {{msg-mw|abusefilter-edit-builder-group-vars}}.",
        "abusefilter-edit-builder-vars-new-pst": "Paraphrased: The output 
wikitext after pre-save transform is applied to new_wikitext. Abuse filter 
syntax option in a dropdown from the group 
{{msg-mw|abusefilter-edit-builder-group-vars}}.",
        "abusefilter-edit-builder-vars-diff-pst": "Paraphrased: Edit diff of 
new_pst against old_wikitext. Abuse filter syntax option in a dropdown from the 
group {{msg-mw|abusefilter-edit-builder-group-vars}}.",
        "abusefilter-edit-builder-vars-addedlines-pst": "Paraphrased: Added 
lines in edit_diff_pst. Abuse filter syntax option in a dropdown from the group 
{{msg-mw|abusefilter-edit-builder-group-vars}}.",

-- 
To view, visit https://gerrit.wikimedia.org/r/145014
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I725b7150de52bdc6518f73a6302f850e8d596824
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/AbuseFilter
Gerrit-Branch: master
Gerrit-Owner: Liangent <liang...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to