User:松/Drafts/Extension:AbuseFilter/Rules format: Difference between revisions
m (renumber) |
(Marked this version for translation) |
||
Line 3: | Line 3: | ||
[[zh:Wikipedia:防滥用过滤器/操作指引]] |
[[zh:Wikipedia:防滥用过滤器/操作指引]] |
||
<translate> |
<translate> |
||
<!--T:1--> |
|||
The rules are formatted much as conditionals in a C/Java/Perl-like language. |
The rules are formatted much as conditionals in a C/Java/Perl-like language. |
||
== Strings == |
== Strings == <!--T:2--> |
||
<!--T:3--> |
|||
You can specify a literal by placing it in single or double quotes (for strings), or by typing it in as-is (for numbers, both floating-point and integer).</translate> |
You can specify a literal by placing it in single or double quotes (for strings), or by typing it in as-is (for numbers, both floating-point and integer).</translate> |
||
<translate> |
<translate> |
||
<!--T:4--> |
|||
You can get linebreaks with <tvar|1><code>\n</code></>, tab characters with <tvar|2><code>\t</code></>, and you can also escape the quote character with a backslash. |
You can get linebreaks with <tvar|1><code>\n</code></>, tab characters with <tvar|2><code>\t</code></>, and you can also escape the quote character with a backslash. |
||
<!--T:5--> |
|||
Use the <tvar|1><code>+</code></> (plus) symbol to [[w:concatenation|concatenate]] two [[w:string literal|literal strings]] or the values of two [[w:Variable (computer science)|vars]] with a string value. |
Use the <tvar|1><code>+</code></> (plus) symbol to [[w:concatenation|concatenate]] two [[w:string literal|literal strings]] or the values of two [[w:Variable (computer science)|vars]] with a string value. |
||
</translate> |
</translate> |
||
; <translate>Examples</translate>: |
; <translate><!--T:6--> Examples</translate>: |
||
<syntaxhighlight lang="perl"> |
<syntaxhighlight lang="perl"> |
||
"<translate>This is a string</translate>" |
"<translate><!--T:7--> This is a string</translate>" |
||
'<translate>This is also a string</translate>' |
'<translate><!--T:8--> This is also a string</translate>' |
||
'<translate>This string shouldn\'t fail</translate>' |
'<translate><!--T:9--> This string shouldn\'t fail</translate>' |
||
"<translate>This string\nHas a linebreak</translate>" |
"<translate><!--T:10--> This string\nHas a linebreak</translate>" |
||
1234 |
1234 |
||
1.234 |
1.234 |
||
Line 26: | Line 30: | ||
<translate> |
<translate> |
||
==User-defined variables== |
==User-defined variables== <!--T:11--> |
||
<!--T:12--> |
|||
You can define custom variables for ease of understanding with the assign symbol <tvar|1><code>:=</code></> in a line (closed by <tvar|2><code>;</code></>) within a condition.</translate> |
You can define custom variables for ease of understanding with the assign symbol <tvar|1><code>:=</code></> in a line (closed by <tvar|2><code>;</code></>) within a condition.</translate> |
||
<translate> |
<translate> |
||
<!--T:13--> |
|||
Such variables may use letters, underscores, and numbers (apart from the first character) and are case sensitive.</translate> |
Such variables may use letters, underscores, and numbers (apart from the first character) and are case sensitive.</translate> |
||
<translate> |
<translate> |
||
<!--T:14--> |
|||
Example (from <tvar|1>[[w:Special:AbuseFilter/79]]</>): |
Example (from <tvar|1>[[w:Special:AbuseFilter/79]]</>): |
||
</translate> |
</translate> |
||
Line 45: | Line 52: | ||
<translate> |
<translate> |
||
==Arrays== |
==Arrays== <!--T:15--> |
||
</translate> |
</translate> |
||
<!--Note: these examples are also used in https://phabricator.wikimedia.org/diffusion/EABF/browse/master/tests/parserTests/mwexamples-arrays.t --> |
<!--Note: these examples are also used in https://phabricator.wikimedia.org/diffusion/EABF/browse/master/tests/parserTests/mwexamples-arrays.t --> |
||
<translate> |
<translate> |
||
<!--T:16--> |
|||
AbuseFilter has support for non-associative arrays, which can be used like in the following examples. |
AbuseFilter has support for non-associative arrays, which can be used like in the following examples. |
||
</translate> |
</translate> |
||
Line 56: | Line 64: | ||
my_array[0] == 5 |
my_array[0] == 5 |
||
length(my_array) == 4 |
length(my_array) == 4 |
||
string(my_array) == "5\n6\n7\n10\n" //<translate>Note: the last linebreak could be removed in the future</translate> |
string(my_array) == "5\n6\n7\n10\n" //<translate><!--T:17--> Note: the last linebreak could be removed in the future</translate> |
||
5 in my_array == true |
5 in my_array == true |
||
'5' in my_array == true |
'5' in my_array == true |
||
'5\n6' in my_array == true //<translate>Note: this is due to how arrays are casted to string, i.e. by imploding them with linebreaks</translate> |
'5\n6' in my_array == true //<translate><!--T:18--> Note: this is due to how arrays are casted to string, i.e. by imploding them with linebreaks</translate> |
||
1 in my_array == true //<translate>Note: this happens because 'in' casts arguments to strings, so the 1 is catched in '10' and returns true.</translate> |
1 in my_array == true //<translate><!--T:19--> Note: this happens because 'in' casts arguments to strings, so the 1 is catched in '10' and returns true.</translate> |
||
</syntaxhighlight> |
</syntaxhighlight> |
||
<translate> |
<translate> |
||
== Comments == |
== Comments == <!--T:20--> |
||
<!--T:21--> |
|||
You can specify comments using the following syntax: |
You can specify comments using the following syntax: |
||
</translate> |
</translate> |
||
/* <translate>This is a comment</translate> */ |
/* <translate><!--T:22--> This is a comment</translate> */ |
||
<translate> |
<translate> |
||
== Arithmetic == |
== Arithmetic == <!--T:23--> |
||
<!--T:24--> |
|||
You can use basic arithmetic symbols to do arithmetic on variables and literals with the following syntax: |
You can use basic arithmetic symbols to do arithmetic on variables and literals with the following syntax: |
||
</translate> |
</translate> |
||
* <code>-</code> — <translate>Subtract the right-hand operand from the left-hand operand.</translate> |
* <code>-</code> — <translate><!--T:25--> Subtract the right-hand operand from the left-hand operand.</translate> |
||
* <code>+</code> — <translate>Add the right-hand operand to the left-hand operand.</translate> |
* <code>+</code> — <translate><!--T:26--> Add the right-hand operand to the left-hand operand.</translate> |
||
* <code>*</code> — <translate>Multiply the left-hand operand by the right-hand operand.</translate> |
* <code>*</code> — <translate><!--T:27--> Multiply the left-hand operand by the right-hand operand.</translate> |
||
* <code>/</code> — <translate>Divide the left-hand operand by the right-hand operand.</translate> |
* <code>/</code> — <translate><!--T:28--> Divide the left-hand operand by the right-hand operand.</translate> |
||
* <code>**</code> — <translate>Raise the left-hand operand to the exponential power specified by the right-hand operand.</translate> |
* <code>**</code> — <translate><!--T:29--> Raise the left-hand operand to the exponential power specified by the right-hand operand.</translate> |
||
* <code>%</code> — <translate>Return the remainder given when the left-hand operand is divided by the right-hand operand.</translate> |
* <code>%</code> — <translate><!--T:30--> Return the remainder given when the left-hand operand is divided by the right-hand operand.</translate> |
||
<translate> |
<translate> |
||
<!--T:31--> |
|||
The type of the returned result is the same that would be returned by PHP, for which a lot of documentation may be found [<tvar|url>https://secure.php.net/language.operators.arithmetic</> online].</translate> |
The type of the returned result is the same that would be returned by PHP, for which a lot of documentation may be found [<tvar|url>https://secure.php.net/language.operators.arithmetic</> online].</translate> |
||
<translate> |
<translate> |
||
<!--T:32--> |
|||
More exhaustive examples may be found in [<tvar|url>https://phabricator.wikimedia.org/diffusion/EABF/browse/master/tests/parserTests/arith.t</> this AF parser test]. |
More exhaustive examples may be found in [<tvar|url>https://phabricator.wikimedia.org/diffusion/EABF/browse/master/tests/parserTests/arith.t</> this AF parser test]. |
||
</translate> |
</translate> |
||
Line 91: | Line 103: | ||
<!--Note: these examples are also used in https://phabricator.wikimedia.org/diffusion/EABF/browse/master/tests/parserTests/mwexamples-arithmetic.t --> |
<!--Note: these examples are also used in https://phabricator.wikimedia.org/diffusion/EABF/browse/master/tests/parserTests/mwexamples-arithmetic.t --> |
||
{| class="wikitable" |
{| class="wikitable" |
||
!style="width: 50%;"|<translate>Example</translate> |
!style="width: 50%;"|<translate><!--T:33--> Example</translate> |
||
!<translate>Result</translate> |
!<translate><!--T:34--> Result</translate> |
||
|- |
|- |
||
| <code>1 + 1</code> || 2 |
| <code>1 + 1</code> || 2 |
||
Line 106: | Line 118: | ||
<translate> |
<translate> |
||
== Boolean operations == |
== Boolean operations == <!--T:35--> |
||
<!--T:36--> |
|||
You can match if and only if all of a number of conditions are true, one of a number of conditions are true, or one and only one of all conditions are true. |
You can match if and only if all of a number of conditions are true, one of a number of conditions are true, or one and only one of all conditions are true. |
||
</translate> |
</translate> |
||
<translate> |
<translate> |
||
<!--T:37--> |
|||
* <tvar|1><code>x | y</code> — OR</> – returns true if one or more of the conditions is true.</translate> |
* <tvar|1><code>x | y</code> — OR</> – returns true if one or more of the conditions is true.</translate> |
||
<translate> |
<translate> |
||
<!--T:38--> |
|||
* <tvar|1><code>x & y</code> — AND</> – returns true if both of the conditions are true.</translate> |
* <tvar|1><code>x & y</code> — AND</> – returns true if both of the conditions are true.</translate> |
||
<translate> |
<translate> |
||
<!--T:39--> |
|||
* <tvar|1><code>x ^ y</code> — XOR</> – returns true if one, and only one of the two conditions is true.</translate> |
* <tvar|1><code>x ^ y</code> — XOR</> – returns true if one, and only one of the two conditions is true.</translate> |
||
<translate> |
<translate> |
||
<!--T:40--> |
|||
* <tvar|1><code>!x</code> — NOT</> – returns true if the condition is not true. |
* <tvar|1><code>!x</code> — NOT</> – returns true if the condition is not true. |
||
</translate> |
</translate> |
||
'''<translate>Examples</translate>''' |
'''<translate><!--T:41--> Examples</translate>''' |
||
<!--Note: these examples are also used in https://phabricator.wikimedia.org/diffusion/EABF/browse/master/tests/parserTests/mwexamples-bools.t --> |
<!--Note: these examples are also used in https://phabricator.wikimedia.org/diffusion/EABF/browse/master/tests/parserTests/mwexamples-bools.t --> |
||
{| class="wikitable" |
{| class="wikitable" |
||
|- |
|- |
||
! <translate>Code</translate> |
! <translate><!--T:42--> Code</translate> |
||
! <translate>Result</translate> |
! <translate><!--T:43--> Result</translate> |
||
|- |
|- |
||
| <code>1 <nowiki>|</nowiki> 1</code> |
| <code>1 <nowiki>|</nowiki> 1</code> |
||
Line 162: | Line 179: | ||
{{anchor|Simple comparisons}} |
{{anchor|Simple comparisons}} |
||
<translate> |
<translate> |
||
== Simple comparisons == |
== Simple comparisons == <!--T:44--> |
||
<!--T:45--> |
|||
You can compare [[w:Variable (computer science)|variables]] with other variables and [[w:Operand|literals]] with the following [[w:syntax|syntax]]: |
You can compare [[w:Variable (computer science)|variables]] with other variables and [[w:Operand|literals]] with the following [[w:syntax|syntax]]: |
||
<!--T:46--> |
|||
* <tvar|1><code><</code>{{int|comma-separator}}<code>></code></> — Return true if the left-hand [[w:Operand|operand]] is ''less than/greater than'' the right-hand operand respectively.</translate> <translate>Watch out: operands are casted to strings and, like it happens in PHP, <code><tvar|1>null <</> any number <tvar|2>=== true</></code> and <code><tvar|3>null ></> any number <tvar|4>=== false</></code>.</translate> |
* <tvar|1><code><</code>{{int|comma-separator}}<code>></code></> — Return true if the left-hand [[w:Operand|operand]] is ''less than/greater than'' the right-hand operand respectively.</translate> <translate><!--T:47--> Watch out: operands are casted to strings and, like it happens in PHP, <code><tvar|1>null <</> any number <tvar|2>=== true</></code> and <code><tvar|3>null ></> any number <tvar|4>=== false</></code>.</translate> |
||
<translate> |
<translate> |
||
<!--T:48--> |
|||
* <tvar|1><code><=</code>{{int|comma-separator}}<code>>=</code></> — Return true if the left-hand operand is ''less than or equal to/greater than or equal to'' the right-hand operand respectively.</translate> <translate>Watch out: operands are casted to strings and, like it happens in PHP, <code><tvar|1>null <=</> any number <tvar|2>=== true</></code> and <code><tvar|3>null >=</> any number <tvar|4>=== false</></code>.</translate> |
* <tvar|1><code><=</code>{{int|comma-separator}}<code>>=</code></> — Return true if the left-hand operand is ''less than or equal to/greater than or equal to'' the right-hand operand respectively.</translate> <translate><!--T:49--> Watch out: operands are casted to strings and, like it happens in PHP, <code><tvar|1>null <=</> any number <tvar|2>=== true</></code> and <code><tvar|3>null >=</> any number <tvar|4>=== false</></code>.</translate> |
||
<translate> |
<translate> |
||
<!--T:50--> |
|||
* <tvar|1><code>==</code></> (or <tvar|2><code>=</code></>), <tvar|3><code>!=</code></> — Return true if the left-hand operand is ''equal to/not equal to'' the right-hand operand respectively.</translate> |
* <tvar|1><code>==</code></> (or <tvar|2><code>=</code></>), <tvar|3><code>!=</code></> — Return true if the left-hand operand is ''equal to/not equal to'' the right-hand operand respectively.</translate> |
||
<translate> |
<translate> |
||
<!--T:51--> |
|||
* <tvar|1><code>===</code>{{int|comma-separator}}<code>!==</code></> — Return true if the left-hand operand is ''equal to/not equal to'' the right-hand operand AND the left-hand operand is ''the same/not the same'' data type to the right-hand operand respectively.</translate> |
* <tvar|1><code>===</code>{{int|comma-separator}}<code>!==</code></> — Return true if the left-hand operand is ''equal to/not equal to'' the right-hand operand AND the left-hand operand is ''the same/not the same'' data type to the right-hand operand respectively.</translate> |
||
<!--Note: these examples are also used in https://phabricator.wikimedia.org/diffusion/EABF/browse/master/tests/parserTests/mwexamples-comparisons.t --> |
<!--Note: these examples are also used in https://phabricator.wikimedia.org/diffusion/EABF/browse/master/tests/parserTests/mwexamples-comparisons.t --> |
||
{| class="wikitable" |
{| class="wikitable" |
||
! style="width: 50%;"| <translate>Example</translate> |
! style="width: 50%;"| <translate><!--T:52--> Example</translate> |
||
! <translate>Result</translate> |
! <translate><!--T:53--> Result</translate> |
||
|- |
|- |
||
|<code>1 == 2</code>|| false |
|<code>1 == 2</code>|| false |
||
Line 224: | Line 246: | ||
|- |
|- |
||
|<code>['1'] == '1'</code> |
|<code>['1'] == '1'</code> |
||
|false<ref><translate>Comparing arrays to other types will always return false, except for the example above</translate></ref> |
|false<ref><translate><!--T:54--> Comparing arrays to other types will always return false, except for the example above</translate></ref> |
||
|} |
|} |
||
<translate> |
<translate> |
||
== Built-in variables == |
== Built-in variables == <!--T:55--> |
||
<!--T:56--> |
|||
The abuse filter passes various variables by name into the parser.</translate> |
The abuse filter passes various variables by name into the parser.</translate> |
||
<translate> |
<translate> |
||
<!--T:57--> |
|||
These variables can be accessed by typing their name in, in a place where a literal would work.</translate> |
These variables can be accessed by typing their name in, in a place where a literal would work.</translate> |
||
<translate> |
<translate> |
||
<!--T:58--> |
|||
You can view the variables associated with each request in the abuse log. |
You can view the variables associated with each request in the abuse log. |
||
===Variables from AbuseFilter=== |
===Variables from AbuseFilter=== <!--T:59--> |
||
</translate> |
</translate> |
||
{| class="wikitable sortable" |
{| class="wikitable sortable" |
||
|+ <translate>Variables available</translate> |
|+ <translate><!--T:60--> Variables available</translate> |
||
! <translate>Description</translate> |
! <translate><!--T:61--> Description</translate> |
||
! <translate>Name</translate> |
! <translate><!--T:62--> Name</translate> |
||
! <translate>Data type</translate> |
! <translate><!--T:63--> Data type</translate> |
||
! <translate>Notes</translate> |
! <translate><!--T:64--> Notes</translate> |
||
|- |
|- |
||
| <translate>Action</translate> || <code>action</code> || <translate>string</translate> || <translate>One of the following:</translate> edit, move, createaccount, autocreateaccount, delete, upload<ref name="upload"><translate>The only variables currently available for file uploads (<tvar|1>action='upload'</>) are <tvar|2>user_*, page_*, file_sha1, file_size, file_mime, file_mediatype, file_width, file_height, file_bits_per_channel</> (the last five were only added since the release for MediaWiki 1.27, <tvar|3>[[gerrit:281503]]</>).</translate> <translate>All the <tvar|1>file_*</> variables are unavailable for other actions (including <tvar|2>action='edit'</>).</translate></ref>, stashupload<ref><translate>Since <tvar|1>MediaWiki 1.28 (https://gerrit.wikimedia.org/r/#/c/295254/)</></translate></ref> |
| <translate><!--T:65--> Action</translate> || <code>action</code> || <translate><!--T:66--> string</translate> || <translate><!--T:67--> One of the following:</translate> edit, move, createaccount, autocreateaccount, delete, upload<ref name="upload"><translate><!--T:68--> The only variables currently available for file uploads (<tvar|1>action='upload'</>) are <tvar|2>user_*, page_*, file_sha1, file_size, file_mime, file_mediatype, file_width, file_height, file_bits_per_channel</> (the last five were only added since the release for MediaWiki 1.27, <tvar|3>[[gerrit:281503]]</>).</translate> <translate><!--T:69--> All the <tvar|1>file_*</> variables are unavailable for other actions (including <tvar|2>action='edit'</>).</translate></ref>, stashupload<ref><translate><!--T:70--> Since <tvar|1>MediaWiki 1.28 (https://gerrit.wikimedia.org/r/#/c/295254/)</></translate></ref> |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-user-editcount}} || <code>user_editcount</code> || <translate>integer/null</translate> || <translate>Null only for unregistered users.</translate> |
| {{int|abusefilter-edit-builder-vars-user-editcount}} || <code>user_editcount</code> || <translate><!--T:71--> integer/null</translate> || <translate><!--T:72--> Null only for unregistered users.</translate> |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-user-name}} || <code>user_name</code> || <translate>string</translate> || {{note|1=<translate>this is empty for <tvar|1>"createaccount"</> action, use <tvar|2><code>accountname</code></> instead.</translate>}} |
| {{int|abusefilter-edit-builder-vars-user-name}} || <code>user_name</code> || <translate><!--T:73--> string</translate> || {{note|1=<translate><!--T:74--> this is empty for <tvar|1>"createaccount"</> action, use <tvar|2><code>accountname</code></> instead.</translate>}} |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-user-emailconfirm}} || <code>user_emailconfirm</code> || <translate>string</translate> || <translate>In the format: YYYYMMDDHHMMSS.</translate> <translate>Null if the email wasn't confirmed.</translate> |
| {{int|abusefilter-edit-builder-vars-user-emailconfirm}} || <code>user_emailconfirm</code> || <translate><!--T:75--> string</translate> || <translate><!--T:76--> In the format: YYYYMMDDHHMMSS.</translate> <translate><!--T:77--> Null if the email wasn't confirmed.</translate> |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-user-age}} || <code>user_age</code> || <translate>integer</translate> || <translate>In seconds.</translate> <translate>0 for unregistered users.</translate> |
| {{int|abusefilter-edit-builder-vars-user-age}} || <code>user_age</code> || <translate><!--T:78--> integer</translate> || <translate><!--T:79--> In seconds.</translate> <translate><!--T:80--> 0 for unregistered users.</translate> |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-user-blocked}} || <code>user_blocked</code> || boolean || <translate><tvar|1>true</> for blocked registered users, <tvar|2>false</> for unregistered users.</translate> {{note|1=<translate>This doesn't differentiate between partial and total blocks.</translate>}} |
| {{int|abusefilter-edit-builder-vars-user-blocked}} || <code>user_blocked</code> || boolean || <translate><!--T:81--> <tvar|1>true</> for blocked registered users, <tvar|2>false</> for unregistered users.</translate> {{note|1=<translate><!--T:82--> This doesn't differentiate between partial and total blocks.</translate>}} |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-user-groups}} || <code>user_groups</code> || <translate>array of strings</translate> || <translate>see <tvar|1>[[Special:ListGroupRights]]</></translate> |
| {{int|abusefilter-edit-builder-vars-user-groups}} || <code>user_groups</code> || <translate><!--T:83--> array of strings</translate> || <translate><!--T:84--> see <tvar|1>[[Special:ListGroupRights]]</></translate> |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-user-rights}} || <code>user_rights</code> || <translate>array of strings</translate> || <translate>see <tvar|1>[[Special:ListGroupRights]]</></translate> |
| {{int|abusefilter-edit-builder-vars-user-rights}} || <code>user_rights</code> || <translate><!--T:85--> array of strings</translate> || <translate><!--T:86--> see <tvar|1>[[Special:ListGroupRights]]</></translate> |
||
|- |
|- |
||
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-page-id}}</span> || <span style="opacity:0.5"><code>article_articleid</code></span> || <span style="opacity:0.5"><translate>integer</translate></span> || {{deprecated-inline}} <translate>Use <tvar|1><code>page_id</code></> instead.</translate> |
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-page-id}}</span> || <span style="opacity:0.5"><code>article_articleid</code></span> || <span style="opacity:0.5"><translate><!--T:87--> integer</translate></span> || {{deprecated-inline}} <translate><!--T:88--> Use <tvar|1><code>page_id</code></> instead.</translate> |
||
|- |
|- |
||
| {{ll|Manual:Page_table#page_id|{{int|abusefilter-edit-builder-vars-page-id}}}} (found in the page's HTML source - search for wgArticleId) || <code>page_id</code> || <translate>integer</translate> || <translate>In theory this is 0 for new pages, but this is unreliable.</translate> <translate>Instead, use "<tvar|1>page_age == 0</>" to identify new page creation.</translate> |
| {{ll|Manual:Page_table#page_id|{{int|abusefilter-edit-builder-vars-page-id}}}} (found in the page's HTML source - search for wgArticleId) || <code>page_id</code> || <translate><!--T:89--> integer</translate> || <translate><!--T:90--> In theory this is 0 for new pages, but this is unreliable.</translate> <translate><!--T:91--> Instead, use "<tvar|1>page_age == 0</>" to identify new page creation.</translate> |
||
|- |
|- |
||
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-page-ns}}</span> || <span style="opacity:0.5"><code>article_namespace</code></span> || <span style="opacity:0.5"><translate>integer</translate></span> || {{deprecated-inline}} <translate>Use <tvar|1><code>page_namespace</code></> instead.</translate> |
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-page-ns}}</span> || <span style="opacity:0.5"><code>article_namespace</code></span> || <span style="opacity:0.5"><translate><!--T:92--> integer</translate></span> || {{deprecated-inline}} <translate><!--T:93--> Use <tvar|1><code>page_namespace</code></> instead.</translate> |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-page-ns}} || <code>page_namespace</code> || <translate>integer</translate> || <translate>refers to {{<tvar|1>ll|Manual:Namespace#Built-in_namespaces</>|namespace index}}</translate> |
| {{int|abusefilter-edit-builder-vars-page-ns}} || <code>page_namespace</code> || <translate><!--T:94--> integer</translate> || <translate><!--T:95--> refers to {{<tvar|1>ll|Manual:Namespace#Built-in_namespaces</>|namespace index}}</translate> |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-page-age}} || <code>page_age</code> || <translate>integer</translate> || <translate>the number of seconds since the first edit (or 0 for new pages)</translate> |
| {{int|abusefilter-edit-builder-vars-page-age}} || <code>page_age</code> || <translate><!--T:96--> integer</translate> || <translate><!--T:97--> the number of seconds since the first edit (or 0 for new pages)</translate> |
||
|- |
|- |
||
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-page-title}}</span> || <span style="opacity:0.5"><code>article_text</code></span> || <span style="opacity:0.5"><translate>string</translate></span> || {{deprecated-inline}} <translate>Use <tvar|1><code>page_title</code></> instead.</translate> |
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-page-title}}</span> || <span style="opacity:0.5"><code>article_text</code></span> || <span style="opacity:0.5"><translate><!--T:98--> string</translate></span> || {{deprecated-inline}} <translate><!--T:99--> Use <tvar|1><code>page_title</code></> instead.</translate> |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-page-title}} || <code>page_title</code> || <translate>string</translate> || |
| {{int|abusefilter-edit-builder-vars-page-title}} || <code>page_title</code> || <translate><!--T:100--> string</translate> || |
||
|- |
|- |
||
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-page-prefixedtitle}}</span> || <span style="opacity:0.5"><code>article_prefixedtext</code></span> || <span style="opacity:0.5"><translate>string</translate></span> || {{deprecated-inline}} <translate>Use <tvar|1><code>page_prefixedtitle</code></> instead.</translate> |
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-page-prefixedtitle}}</span> || <span style="opacity:0.5"><code>article_prefixedtext</code></span> || <span style="opacity:0.5"><translate><!--T:101--> string</translate></span> || {{deprecated-inline}} <translate><!--T:102--> Use <tvar|1><code>page_prefixedtitle</code></> instead.</translate> |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-page-prefixedtitle}} || <code>page_prefixedtitle</code> || <translate>string</translate> || |
| {{int|abusefilter-edit-builder-vars-page-prefixedtitle}} || <code>page_prefixedtitle</code> || <translate><!--T:103--> string</translate> || |
||
|- |
|- |
||
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-restrictions-edit}}</span> || <span style="opacity:0.5"><code>article_restrictions_edit</code></span> || <span style="opacity:0.5"><translate>string</translate></span> || {{deprecated-inline}} <translate>Use <tvar|1><code>page_restrictions_edit</code></> instead.</translate> |
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-restrictions-edit}}</span> || <span style="opacity:0.5"><code>article_restrictions_edit</code></span> || <span style="opacity:0.5"><translate><!--T:104--> string</translate></span> || {{deprecated-inline}} <translate><!--T:105--> Use <tvar|1><code>page_restrictions_edit</code></> instead.</translate> |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-restrictions-edit}} || <code>page_restrictions_edit</code> || <translate>array of strings</translate> || |
| {{int|abusefilter-edit-builder-vars-restrictions-edit}} || <code>page_restrictions_edit</code> || <translate><!--T:106--> array of strings</translate> || |
||
|- |
|- |
||
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-restrictions-move}}</span> || <span style="opacity:0.5"><code>article_restrictions_move</code></span> || <span style="opacity:0.5"><translate>string</translate></span> || {{deprecated-inline}} <translate>Use <tvar|1><code>page_restrictions_move</code></> instead.</translate> |
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-restrictions-move}}</span> || <span style="opacity:0.5"><code>article_restrictions_move</code></span> || <span style="opacity:0.5"><translate><!--T:107--> string</translate></span> || {{deprecated-inline}} <translate><!--T:108--> Use <tvar|1><code>page_restrictions_move</code></> instead.</translate> |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-restrictions-move}} || <code>page_restrictions_move</code> || <translate>array of strings</translate> || |
| {{int|abusefilter-edit-builder-vars-restrictions-move}} || <code>page_restrictions_move</code> || <translate><!--T:109--> array of strings</translate> || |
||
|- |
|- |
||
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-restrictions-upload}}</span> || <span style="opacity:0.5"><code>article_restrictions_upload</code></span> || <span style="opacity:0.5"><translate>string</translate></span> || {{deprecated-inline}} <translate>Use <tvar|1><code>page_restrictions_upload</code></> instead.</translate> |
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-restrictions-upload}}</span> || <span style="opacity:0.5"><code>article_restrictions_upload</code></span> || <span style="opacity:0.5"><translate><!--T:110--> string</translate></span> || {{deprecated-inline}} <translate><!--T:111--> Use <tvar|1><code>page_restrictions_upload</code></> instead.</translate> |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-restrictions-upload}} || <code>page_restrictions_upload</code> || <translate>array of strings</translate> || |
| {{int|abusefilter-edit-builder-vars-restrictions-upload}} || <code>page_restrictions_upload</code> || <translate><!--T:112--> array of strings</translate> || |
||
|- |
|- |
||
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-restrictions-create}}</span> || <span style="opacity:0.5"><code>article_restrictions_create</code></span> || <span style="opacity:0.5"><translate>string</translate></span> || {{deprecated-inline}} <translate>Use <tvar|1><code>page_restrictions_create</code></> instead.</translate> |
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-restrictions-create}}</span> || <span style="opacity:0.5"><code>article_restrictions_create</code></span> || <span style="opacity:0.5"><translate><!--T:113--> string</translate></span> || {{deprecated-inline}} <translate><!--T:114--> Use <tvar|1><code>page_restrictions_create</code></> instead.</translate> |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-restrictions-create}} || <code>page_restrictions_create</code> || <translate>array of strings</translate> || |
| {{int|abusefilter-edit-builder-vars-restrictions-create}} || <code>page_restrictions_create</code> || <translate><!--T:115--> array of strings</translate> || |
||
|- |
|- |
||
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-recent-contributors}}</span> || <span style="opacity:0.5"><code>article_recent_contributors</code></span> || <span style="opacity:0.5">array of strings</span> || {{deprecated-inline}} <translate>Use <tvar|1><code>page_recent_contributors</code></> instead.</translate> |
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-recent-contributors}}</span> || <span style="opacity:0.5"><code>article_recent_contributors</code></span> || <span style="opacity:0.5">array of strings</span> || {{deprecated-inline}} <translate><!--T:116--> Use <tvar|1><code>page_recent_contributors</code></> instead.</translate> |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-recent-contributors}} || <code>page_recent_contributors</code> || <translate>array of strings</translate> || <translate>This tends to be '''slow''' (see [[<tvar|1>#Performance</>|#Performance]]).</translate> <translate>Try to put conditions more likely evaluate to false before this one, to avoid unnecessarily running the query.</translate> <translate>This value is empty if the user is the only contributor to the page(?), and only scans the last 100 revisions</translate> |
| {{int|abusefilter-edit-builder-vars-recent-contributors}} || <code>page_recent_contributors</code> || <translate><!--T:117--> array of strings</translate> || <translate><!--T:118--> This tends to be '''slow''' (see [[<tvar|1>#Performance</>|#Performance]]).</translate> <translate><!--T:119--> Try to put conditions more likely evaluate to false before this one, to avoid unnecessarily running the query.</translate> <translate><!--T:120--> This value is empty if the user is the only contributor to the page(?), and only scans the last 100 revisions</translate> |
||
|- |
|- |
||
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-first-contributor}}</span> || <span style="opacity:0.5"><code>article_first_contributor</code></span> || <span style="opacity:0.5"><translate>string</translate></span> || {{deprecated-inline}} <translate>Use <tvar|1><code>page_first_contributor</code></> instead.</translate> |
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-first-contributor}}</span> || <span style="opacity:0.5"><code>article_first_contributor</code></span> || <span style="opacity:0.5"><translate><!--T:121--> string</translate></span> || {{deprecated-inline}} <translate><!--T:122--> Use <tvar|1><code>page_first_contributor</code></> instead.</translate> |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-first-contributor}} || <code>page_first_contributor</code> || <translate>string</translate> || <translate>This tends to be '''slow''' (see [[<tvar|1>#Performance</>|#Performance]]).</translate><ref><translate>Several filters (<tvar|1>[https://logstash.wikimedia.org/app/kibana#/doc/logstash-*/logstash-2017.11.22/mediawiki?id=AV_k0nzBSUnOz-leiQ1Q 1][https://logstash.wikimedia.org/app/kibana#/doc/logstash-*/logstash-2017.11.22/mediawiki?id=AV_kvnragaOKEclNGlrc 2]</>) that use this variable have showed up in the [<tvar|url>https://logstash.wikimedia.org/app/kibana#/dashboard/941a0560-b9b2-11e7-a3f7-cb9288bcae84</> AbuseFilterSlow Grafana dashboard] (requires logstash access to view).</translate> <translate>Moving this variable to towards the end of the filter seemed to help.</translate></ref> <translate>Try to put conditions more likely evaluate to false before this one, to avoid unnecessarily running the query.</translate> |
| {{int|abusefilter-edit-builder-vars-first-contributor}} || <code>page_first_contributor</code> || <translate><!--T:123--> string</translate> || <translate><!--T:124--> This tends to be '''slow''' (see [[<tvar|1>#Performance</>|#Performance]]).</translate><ref><translate><!--T:125--> Several filters (<tvar|1>[https://logstash.wikimedia.org/app/kibana#/doc/logstash-*/logstash-2017.11.22/mediawiki?id=AV_k0nzBSUnOz-leiQ1Q 1][https://logstash.wikimedia.org/app/kibana#/doc/logstash-*/logstash-2017.11.22/mediawiki?id=AV_kvnragaOKEclNGlrc 2]</>) that use this variable have showed up in the [<tvar|url>https://logstash.wikimedia.org/app/kibana#/dashboard/941a0560-b9b2-11e7-a3f7-cb9288bcae84</> AbuseFilterSlow Grafana dashboard] (requires logstash access to view).</translate> <translate><!--T:126--> Moving this variable to towards the end of the filter seemed to help.</translate></ref> <translate><!--T:127--> Try to put conditions more likely evaluate to false before this one, to avoid unnecessarily running the query.</translate> |
||
|} |
|} |
||
{| class="wikitable sortable" |
{| class="wikitable sortable" |
||
|+ <translate>Variables available for some actions</translate> |
|+ <translate><!--T:128--> Variables available for some actions</translate> |
||
! <translate>Description</translate> |
! <translate><!--T:129--> Description</translate> |
||
! <translate>Name</translate> |
! <translate><!--T:130--> Name</translate> |
||
! <translate>Data type</translate> |
! <translate><!--T:131--> Data type</translate> |
||
! <translate>Notes</translate> |
! <translate><!--T:132--> Notes</translate> |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-summary}} || <code>summary</code> || <translate>string</translate> || <translate>Summaries automatically created by MediaWiki ("New section", "Blanked the page", etc.) are created ''after'' the filter checks the edit, so they will never actually catch, even if the debugger shows that they should.</translate><ref><translate>See <tvar|1>[[phabricator:T191722]]</></translate></ref> |
| {{int|abusefilter-edit-builder-vars-summary}} || <code>summary</code> || <translate><!--T:133--> string</translate> || <translate><!--T:134--> Summaries automatically created by MediaWiki ("New section", "Blanked the page", etc.) are created ''after'' the filter checks the edit, so they will never actually catch, even if the debugger shows that they should.</translate><ref><translate><!--T:135--> See <tvar|1>[[phabricator:T191722]]</></translate></ref> |
||
|- |
|- |
||
| <s>{{int|abusefilter-edit-builder-vars-minor-edit}}</s> || <s><code>minor_edit</code></s> || <s><translate>string</translate></s> || <translate>Disabled, and set to false for all entries between 2016 and 2018.</translate><ref><translate>Deprecated with [<tvar|1>https://gerrit.wikimedia.org/r/#/c/296268/</> this commit] and disabled with [<tvar|2>https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/AbuseFilter/+/481544/</> this one].</translate></ref> |
| <s>{{int|abusefilter-edit-builder-vars-minor-edit}}</s> || <s><code>minor_edit</code></s> || <s><translate><!--T:136--> string</translate></s> || <translate><!--T:137--> Disabled, and set to false for all entries between 2016 and 2018.</translate><ref><translate><!--T:138--> Deprecated with [<tvar|1>https://gerrit.wikimedia.org/r/#/c/296268/</> this commit] and disabled with [<tvar|2>https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/AbuseFilter/+/481544/</> this one].</translate></ref> |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-old-text}} || <code>old_wikitext</code> || <translate>string</translate> ||<translate>This variable can be very large.</translate> <translate>Consider using <tvar|1><code>removed_lines</code></> if possible to improve performance.</translate> |
| {{int|abusefilter-edit-builder-vars-old-text}} || <code>old_wikitext</code> || <translate><!--T:139--> string</translate> ||<translate><!--T:140--> This variable can be very large.</translate> <translate><!--T:141--> Consider using <tvar|1><code>removed_lines</code></> if possible to improve performance.</translate> |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-new-text}} || <code>new_wikitext</code> || <translate>string</translate> || <translate>This variable can be very large.</translate> <translate>Consider using <tvar|1><code>added_lines</code></> if possible to improve performance.</translate> |
| {{int|abusefilter-edit-builder-vars-new-text}} || <code>new_wikitext</code> || <translate><!--T:142--> string</translate> || <translate><!--T:143--> This variable can be very large.</translate> <translate><!--T:144--> Consider using <tvar|1><code>added_lines</code></> if possible to improve performance.</translate> |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-diff}} || <code>edit_diff</code> || <translate>string</translate> || |
| {{int|abusefilter-edit-builder-vars-diff}} || <code>edit_diff</code> || <translate><!--T:145--> string</translate> || |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-diff-pst}} || <code>edit_diff_pst</code> || <translate>string</translate> || <translate>This tends to be '''slow''' (see [[<tvar|1>#Performance</>|#Performance]]).</translate> <translate>Checking both <tvar|1><code>added_lines</code></> and <tvar|2><code>removed_lines</code></> is probably more efficient.</translate><ref><translate>Some filters using this variable have showed up in the AbuseFilterSlow Grafana dashboard ([<tvar|url>https://logstash.wikimedia.org/app/kibana#/doc/logstash-*/logstash-2017.11.22/mediawiki?id=AV_j4TTs-DyidI0FMJNq</> example], requires logstash access).</translate> <translate>For instance, instead of using <tvar|1><code>"text" in edit_diff_pst</code></> (or even <tvar|2><code>edit_diff</code></>), consider something like <tvar|3><code>"text" in added_lines & !("text" in removed_lines)</code></></translate></ref> |
| {{int|abusefilter-edit-builder-vars-diff-pst}} || <code>edit_diff_pst</code> || <translate><!--T:146--> string</translate> || <translate><!--T:147--> This tends to be '''slow''' (see [[<tvar|1>#Performance</>|#Performance]]).</translate> <translate><!--T:148--> Checking both <tvar|1><code>added_lines</code></> and <tvar|2><code>removed_lines</code></> is probably more efficient.</translate><ref><translate><!--T:149--> Some filters using this variable have showed up in the AbuseFilterSlow Grafana dashboard ([<tvar|url>https://logstash.wikimedia.org/app/kibana#/doc/logstash-*/logstash-2017.11.22/mediawiki?id=AV_j4TTs-DyidI0FMJNq</> example], requires logstash access).</translate> <translate><!--T:150--> For instance, instead of using <tvar|1><code>"text" in edit_diff_pst</code></> (or even <tvar|2><code>edit_diff</code></>), consider something like <tvar|3><code>"text" in added_lines & !("text" in removed_lines)</code></></translate></ref> |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-newsize}} || <code>new_size</code> || <translate>integer</translate> || |
| {{int|abusefilter-edit-builder-vars-newsize}} || <code>new_size</code> || <translate><!--T:151--> integer</translate> || |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-oldsize}} || <code>old_size</code> || <translate>integer</translate> || |
| {{int|abusefilter-edit-builder-vars-oldsize}} || <code>old_size</code> || <translate><!--T:152--> integer</translate> || |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-delta}} || <code>edit_delta</code> || <translate>integer</translate> || {{tip|1=<translate>Ensure that the action being filtered is an edit, either by checking for <tvar|1><code>action === 'edit'</code></> or checking other edit-specific variables.</translate> <translate>Otherwise, <tvar|1><code>edit_delta</code></> will be <tvar|2><code>null</code></>, thus being considered less than every other number (see [[<tvar|3>#Simple comparisons</>|#Simple comparisons]]).</translate>}} |
| {{int|abusefilter-edit-builder-vars-delta}} || <code>edit_delta</code> || <translate><!--T:153--> integer</translate> || {{tip|1=<translate><!--T:154--> Ensure that the action being filtered is an edit, either by checking for <tvar|1><code>action === 'edit'</code></> or checking other edit-specific variables.</translate> <translate><!--T:155--> Otherwise, <tvar|1><code>edit_delta</code></> will be <tvar|2><code>null</code></>, thus being considered less than every other number (see [[<tvar|3>#Simple comparisons</>|#Simple comparisons]]).</translate>}} |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-addedlines-pst}} || <code>added_lines_pst</code> || <translate>array of strings</translate> || <translate>Use <tvar|1><code>added_lines</code></> if possible, which is more efficient.</translate> |
| {{int|abusefilter-edit-builder-vars-addedlines-pst}} || <code>added_lines_pst</code> || <translate><!--T:156--> array of strings</translate> || <translate><!--T:157--> Use <tvar|1><code>added_lines</code></> if possible, which is more efficient.</translate> |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-addedlines}} || <code>added_lines</code> || <translate>array of strings</translate> || <translate>includes all lines in the final diff that begin with +</translate> |
| {{int|abusefilter-edit-builder-vars-addedlines}} || <code>added_lines</code> || <translate><!--T:158--> array of strings</translate> || <translate><!--T:159--> includes all lines in the final diff that begin with +</translate> |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-removedlines}} || <code>removed_lines</code> || <translate>array of strings</translate> || |
| {{int|abusefilter-edit-builder-vars-removedlines}} || <code>removed_lines</code> || <translate><!--T:160--> array of strings</translate> || |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-all-links}} || <code>all_links</code> || array of strings || |
| {{int|abusefilter-edit-builder-vars-all-links}} || <code>all_links</code> || array of strings || |
||
Line 339: | Line 364: | ||
| {{int|abusefilter-edit-builder-vars-old-links}} || <code>old_links</code> || array of strings || |
| {{int|abusefilter-edit-builder-vars-old-links}} || <code>old_links</code> || array of strings || |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-added-links}} || <code>added_links</code> || <translate>array of strings</translate> || <translate>This tends to be '''slow''' (see [[<tvar|1>#Performance</>|#Performance]]).</translate> <translate>Consider checking against <tvar|1><code>added_lines</code></> first, then check <tvar|2><code>added_links</code></> so that fewer edits are slowed down.</translate> <translate>This follows {{<tvar|1>ll|Help:Links#External_links</>|MediaWiki's rules for external links}}.</translate> <translate>Only unique links are added to the array.</translate> <translate>Changing a link will count as 1 added and 1 removed link.</translate> |
| {{int|abusefilter-edit-builder-vars-added-links}} || <code>added_links</code> || <translate><!--T:161--> array of strings</translate> || <translate><!--T:162--> This tends to be '''slow''' (see [[<tvar|1>#Performance</>|#Performance]]).</translate> <translate><!--T:163--> Consider checking against <tvar|1><code>added_lines</code></> first, then check <tvar|2><code>added_links</code></> so that fewer edits are slowed down.</translate> <translate><!--T:164--> This follows {{<tvar|1>ll|Help:Links#External_links</>|MediaWiki's rules for external links}}.</translate> <translate><!--T:165--> Only unique links are added to the array.</translate> <translate><!--T:166--> Changing a link will count as 1 added and 1 removed link.</translate> |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-removed-links}} || <code>removed_links</code> || <translate>array of strings</translate> || <translate>This tends to be '''slow''' (see [[<tvar|1>#Performance</>|#Performance]]).</translate> <translate>Consider checking against <tvar|1><code>removed_lines</code></> first, then check <tvar|2><code>removed_links</code></> so that fewer edits are slowed down.</translate> <translate>This follows {{<tvar|1>ll|Help:Links#External_links</>|MediaWiki's rules for external links}}.</translate> <translate>Only unique links are added to the array.</translate> <translate>Changing a link will count as 1 added and 1 removed link.</translate> |
| {{int|abusefilter-edit-builder-vars-removed-links}} || <code>removed_links</code> || <translate><!--T:167--> array of strings</translate> || <translate><!--T:168--> This tends to be '''slow''' (see [[<tvar|1>#Performance</>|#Performance]]).</translate> <translate><!--T:169--> Consider checking against <tvar|1><code>removed_lines</code></> first, then check <tvar|2><code>removed_links</code></> so that fewer edits are slowed down.</translate> <translate><!--T:170--> This follows {{<tvar|1>ll|Help:Links#External_links</>|MediaWiki's rules for external links}}.</translate> <translate><!--T:171--> Only unique links are added to the array.</translate> <translate><!--T:172--> Changing a link will count as 1 added and 1 removed link.</translate> |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-new-pst}} || <code>new_pst</code> || <translate>string</translate> || |
| {{int|abusefilter-edit-builder-vars-new-pst}} || <code>new_pst</code> || <translate><!--T:173--> string</translate> || |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-new-html}} || <code>new_html</code> || <translate>string</translate> ||<translate>This variable can be very large.</translate> <translate>Consider using <tvar|1><code>added_lines</code></> if possible to improve performance.</translate> |
| {{int|abusefilter-edit-builder-vars-new-html}} || <code>new_html</code> || <translate><!--T:174--> string</translate> ||<translate><!--T:175--> This variable can be very large.</translate> <translate><!--T:176--> Consider using <tvar|1><code>added_lines</code></> if possible to improve performance.</translate> |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-new-text}} || <code>new_text</code> || <translate>string</translate> ||<translate>This variable can be very large.</translate> <translate>Consider using <tvar|1><code>added_lines</code></> if possible to improve performance.</translate> |
| {{int|abusefilter-edit-builder-vars-new-text}} || <code>new_text</code> || <translate><!--T:177--> string</translate> ||<translate><!--T:178--> This variable can be very large.</translate> <translate><!--T:179--> Consider using <tvar|1><code>added_lines</code></> if possible to improve performance.</translate> |
||
|- |
|- |
||
| <s>{{int|abusefilter-edit-builder-vars-old-html}}</s> || <s><code>old_html</code></s> || <s><translate>string</translate></s> || <translate>Disabled for performance reasons.</translate> |
| <s>{{int|abusefilter-edit-builder-vars-old-html}}</s> || <s><code>old_html</code></s> || <s><translate><!--T:180--> string</translate></s> || <translate><!--T:181--> Disabled for performance reasons.</translate> |
||
|- |
|- |
||
| <s>{{int|abusefilter-edit-builder-vars-old-text}}</s> || <s><code>old_text</code></s> || <s><translate>string</translate></s> || <translate>Disabled for performance reasons.</translate> |
| <s>{{int|abusefilter-edit-builder-vars-old-text}}</s> || <s><code>old_text</code></s> || <s><translate><!--T:182--> string</translate></s> || <translate><!--T:183--> Disabled for performance reasons.</translate> |
||
|- |
|- |
||
| Unix timestamp of change || <code>timestamp</code> || <translate>string</translate> || <translate><tvar|1>int(timestamp)</> gives you a number with which you can calculate the date, time, day of week, etc.</translate> |
| Unix timestamp of change || <code>timestamp</code> || <translate><!--T:184--> string</translate> || <translate><!--T:185--> <tvar|1>int(timestamp)</> gives you a number with which you can calculate the date, time, day of week, etc.</translate> |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-file-sha1}} || <code>file_sha1</code> || <translate>string</translate> || <ref name=upload/> |
| {{int|abusefilter-edit-builder-vars-file-sha1}} || <code>file_sha1</code> || <translate><!--T:186--> string</translate> || <ref name=upload/> |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-file-size}} || <code>file_size</code> || <translate>integer</translate> || <translate>The file size in bytes</translate><ref name=upload/> |
| {{int|abusefilter-edit-builder-vars-file-size}} || <code>file_size</code> || <translate><!--T:187--> integer</translate> || <translate><!--T:188--> The file size in bytes</translate><ref name=upload/> |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-file-width}} || <code>file_width</code> || <translate>integer</translate> || <translate>The width in pixels</translate><ref name=upload/> |
| {{int|abusefilter-edit-builder-vars-file-width}} || <code>file_width</code> || <translate><!--T:189--> integer</translate> || <translate><!--T:190--> The width in pixels</translate><ref name=upload/> |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-file-height}} || <code>file_height</code> || <translate>integer</translate> || <translate>The height in pixels</translate><ref name=upload/> |
| {{int|abusefilter-edit-builder-vars-file-height}} || <code>file_height</code> || <translate><!--T:191--> integer</translate> || <translate><!--T:192--> The height in pixels</translate><ref name=upload/> |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-file-bits-per-channel}} || <code>file_bits_per_channel</code> || <translate>integer</translate> || <translate>The amount of bits per color channel</translate><ref name=upload/> |
| {{int|abusefilter-edit-builder-vars-file-bits-per-channel}} || <code>file_bits_per_channel</code> || <translate><!--T:193--> integer</translate> || <translate><!--T:194--> The amount of bits per color channel</translate><ref name=upload/> |
||
|- |
|- |
||
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-movedto-id}}</span> || <span style="opacity:0.5"><code>moved_to_articleid</code></span> || <span style="opacity:0.5"><translate>integer</translate></span> || {{deprecated-inline}} <translate>Use <tvar|1><code>moved_to_id</code></> instead.</translate> |
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-movedto-id}}</span> || <span style="opacity:0.5"><code>moved_to_articleid</code></span> || <span style="opacity:0.5"><translate><!--T:195--> integer</translate></span> || {{deprecated-inline}} <translate><!--T:196--> Use <tvar|1><code>moved_to_id</code></> instead.</translate> |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-movedto-id}} || <code>moved_to_id</code> || <translate>integer</translate> || |
| {{int|abusefilter-edit-builder-vars-movedto-id}} || <code>moved_to_id</code> || <translate><!--T:197--> integer</translate> || |
||
|- |
|- |
||
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-movedto-title}}</span> || <span style="opacity:0.5"><code>moved_to_text</code></span> || <span style="opacity:0.5"><translate>string</translate></span> || {{deprecated-inline}} <translate>Use <tvar|1><code>moved_to_title</code></> instead.</translate> |
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-movedto-title}}</span> || <span style="opacity:0.5"><code>moved_to_text</code></span> || <span style="opacity:0.5"><translate><!--T:198--> string</translate></span> || {{deprecated-inline}} <translate><!--T:199--> Use <tvar|1><code>moved_to_title</code></> instead.</translate> |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-movedto-title}} || <code>moved_to_title</code> || <translate>string</translate> || |
| {{int|abusefilter-edit-builder-vars-movedto-title}} || <code>moved_to_title</code> || <translate><!--T:200--> string</translate> || |
||
|- |
|- |
||
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-movedto-prefixedtitle}}</span> || <span style="opacity:0.5"><code>moved_to_prefixedtext</code></span> || <span style="opacity:0.5"><translate>string</translate></span> || {{deprecated-inline}} <translate>Use <tvar|1><code>moved_to_prefixedtitle</code></> instead.</translate> |
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-movedto-prefixedtitle}}</span> || <span style="opacity:0.5"><code>moved_to_prefixedtext</code></span> || <span style="opacity:0.5"><translate><!--T:201--> string</translate></span> || {{deprecated-inline}} <translate><!--T:202--> Use <tvar|1><code>moved_to_prefixedtitle</code></> instead.</translate> |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-movedto-prefixedtitle}} || <code>moved_to_prefixedtitle</code> || <translate>string</translate> || |
| {{int|abusefilter-edit-builder-vars-movedto-prefixedtitle}} || <code>moved_to_prefixedtitle</code> || <translate><!--T:203--> string</translate> || |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-movedto-ns}} || <code>moved_to_namespace</code> || <translate>string</translate> || |
| {{int|abusefilter-edit-builder-vars-movedto-ns}} || <code>moved_to_namespace</code> || <translate><!--T:204--> string</translate> || |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-movedto-age}} || <code>moved_to_age</code> || <translate>integer</translate> || |
| {{int|abusefilter-edit-builder-vars-movedto-age}} || <code>moved_to_age</code> || <translate><!--T:205--> integer</translate> || |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-movedfrom-ns}} || <code>moved_from_namespace</code> || <translate>string</translate> || |
| {{int|abusefilter-edit-builder-vars-movedfrom-ns}} || <code>moved_from_namespace</code> || <translate><!--T:206--> string</translate> || |
||
|- |
|- |
||
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-movedfrom-title}}</span> || <span style="opacity:0.5"><code>moved_from_text</code></span> || <span style="opacity:0.5"><translate>string</translate></span> || {{deprecated-inline}} <translate>Use <tvar|1><code>moved_from_title</code></> instead.</translate> |
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-movedfrom-title}}</span> || <span style="opacity:0.5"><code>moved_from_text</code></span> || <span style="opacity:0.5"><translate><!--T:207--> string</translate></span> || {{deprecated-inline}} <translate><!--T:208--> Use <tvar|1><code>moved_from_title</code></> instead.</translate> |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-movedfrom-title}} || <code>moved_from_title</code> || <translate>string</translate> || |
| {{int|abusefilter-edit-builder-vars-movedfrom-title}} || <code>moved_from_title</code> || <translate><!--T:209--> string</translate> || |
||
|- |
|- |
||
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-movedfrom-prefixedtitle}}</span> || <span style="opacity:0.5"><code>moved_from_prefixedtext</code></span> || <span style="opacity:0.5"><translate>string</translate></span> || {{deprecated-inline}} <translate>Use <tvar|1><code>moved_from_prefixedtitle</code></> instead.</translate> |
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-movedfrom-prefixedtitle}}</span> || <span style="opacity:0.5"><code>moved_from_prefixedtext</code></span> || <span style="opacity:0.5"><translate><!--T:210--> string</translate></span> || {{deprecated-inline}} <translate><!--T:211--> Use <tvar|1><code>moved_from_prefixedtitle</code></> instead.</translate> |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-movedfrom-prefixedtitle}} || <code>moved_from_prefixedtitle</code> || <translate>string</translate> || |
| {{int|abusefilter-edit-builder-vars-movedfrom-prefixedtitle}} || <code>moved_from_prefixedtitle</code> || <translate><!--T:212--> string</translate> || |
||
|- |
|- |
||
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-movedfrom-id}}</span> || <span style="opacity:0.5"><code>moved_from_articleid</code></span> || <span style="opacity:0.5"><translate>integer</translate></span> || {{deprecated-inline}} <translate>Use <tvar|1><code>moved_from_id</code></> instead.</translate> |
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-movedfrom-id}}</span> || <span style="opacity:0.5"><code>moved_from_articleid</code></span> || <span style="opacity:0.5"><translate><!--T:213--> integer</translate></span> || {{deprecated-inline}} <translate><!--T:214--> Use <tvar|1><code>moved_from_id</code></> instead.</translate> |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-movedfrom-id}} || <code>moved_from_id</code> || <translate>integer</translate> || |
| {{int|abusefilter-edit-builder-vars-movedfrom-id}} || <code>moved_from_id</code> || <translate><!--T:215--> integer</translate> || |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-movedfrom-age}} || <code>moved_from_age</code> || <translate>integer</translate> || |
| {{int|abusefilter-edit-builder-vars-movedfrom-age}} || <code>moved_from_age</code> || <translate><!--T:216--> integer</translate> || |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-accountname}} || <code>accountname</code> || <translate>string</translate> || |
| {{int|abusefilter-edit-builder-vars-accountname}} || <code>accountname</code> || <translate><!--T:217--> string</translate> || |
||
|- |
|- |
||
|<translate>Content model of the old revision</translate> |
|<translate><!--T:218--> Content model of the old revision</translate> |
||
|<code>old_content_model</code> |
|<code>old_content_model</code> |
||
|<translate>string</translate> |
|<translate><!--T:219--> string</translate> |
||
|<translate>See <tvar|1>{{ll|Help:ChangeContentModel}}</> for information about content model changes</translate> |
|<translate><!--T:220--> See <tvar|1>{{ll|Help:ChangeContentModel}}</> for information about content model changes</translate> |
||
|- |
|- |
||
|<translate>Content model of the new revision</translate> |
|<translate><!--T:221--> Content model of the new revision</translate> |
||
|<code>new_content_model</code> |
|<code>new_content_model</code> |
||
|<translate>string</translate> |
|<translate><!--T:222--> string</translate> |
||
|<translate>See <tvar|1>{{ll|Help:ChangeContentModel}}</> for information about content model changes</translate> |
|<translate><!--T:223--> See <tvar|1>{{ll|Help:ChangeContentModel}}</> for information about content model changes</translate> |
||
|- |
|- |
||
|} |
|} |
||
Line 413: | Line 438: | ||
<translate> |
<translate> |
||
===Variables from other extensions=== |
===Variables from other extensions=== <!--T:224--> |
||
</translate> |
</translate> |
||
{| class="wikitable sortable" |
{| class="wikitable sortable" |
||
|+ |
|+ |
||
! <translate>Description</translate> |
! <translate><!--T:225--> Description</translate> |
||
! <translate>Name</translate> |
! <translate><!--T:226--> Name</translate> |
||
! <translate>Data type</translate> |
! <translate><!--T:227--> Data type</translate> |
||
! <translate>Values</translate> |
! <translate><!--T:228--> Values</translate> |
||
! <translate>Added by</translate> |
! <translate><!--T:229--> Added by</translate> |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-global-user-groups}} |
| {{int|abusefilter-edit-builder-vars-global-user-groups}} |
||
|<code>global_user_groups</code> |
|<code>global_user_groups</code> |
||
|<translate>array</translate> |
|<translate><!--T:230--> array</translate> |
||
| |
| |
||
|{{ll|Extension:CentralAuth|nsp=0}} |
|{{ll|Extension:CentralAuth|nsp=0}} |
||
Line 431: | Line 456: | ||
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-board-id}}</span> |
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-board-id}}</span> |
||
| <span style="opacity:0.5"><code>board_articleid</code></span> |
| <span style="opacity:0.5"><code>board_articleid</code></span> |
||
| <span style="opacity:0.5"><translate>integer</translate></span> |
| <span style="opacity:0.5"><translate><!--T:231--> integer</translate></span> |
||
| {{deprecated-inline}} <translate>Use <code>board_id</code> instead.</translate> |
| {{deprecated-inline}} <translate><!--T:232--> Use <code>board_id</code> instead.</translate> |
||
|{{ll|Extension:StructuredDiscussions|nsp=0}} |
|{{ll|Extension:StructuredDiscussions|nsp=0}} |
||
|- |
|- |
||
|{{int|abusefilter-edit-builder-vars-board-id}} |
|{{int|abusefilter-edit-builder-vars-board-id}} |
||
|<code>board_id</code> |
|<code>board_id</code> |
||
|<translate>integer</translate> |
|<translate><!--T:233--> integer</translate> |
||
| |
| |
||
|{{ll|Extension:StructuredDiscussions|nsp=0}} |
|{{ll|Extension:StructuredDiscussions|nsp=0}} |
||
Line 443: | Line 468: | ||
|{{int|abusefilter-edit-builder-vars-board-namespace}} |
|{{int|abusefilter-edit-builder-vars-board-namespace}} |
||
|<code>board_namespace</code> |
|<code>board_namespace</code> |
||
|<translate>integer</translate> |
|<translate><!--T:234--> integer</translate> |
||
|<translate>refers to {{<tvar|1>ll|Manual:Namespace#Built-in_namespaces</>|namespace index}}</translate> |
|<translate><!--T:235--> refers to {{<tvar|1>ll|Manual:Namespace#Built-in_namespaces</>|namespace index}}</translate> |
||
|{{ll|Extension:StructuredDiscussions|nsp=0}} |
|{{ll|Extension:StructuredDiscussions|nsp=0}} |
||
|- |
|- |
||
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-board-title}}</span> |
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-board-title}}</span> |
||
| <span style="opacity:0.5"><code>board_text</code></span> |
| <span style="opacity:0.5"><code>board_text</code></span> |
||
| <span style="opacity:0.5"><translate>string</translate></span> |
| <span style="opacity:0.5"><translate><!--T:236--> string</translate></span> |
||
| {{deprecated-inline}} <translate>Use <code>board_title</code> instead.</translate> |
| {{deprecated-inline}} <translate><!--T:237--> Use <code>board_title</code> instead.</translate> |
||
|{{ll|Extension:StructuredDiscussions|nsp=0}} |
|{{ll|Extension:StructuredDiscussions|nsp=0}} |
||
|- |
|- |
||
|{{int|abusefilter-edit-builder-vars-board-title}} |
|{{int|abusefilter-edit-builder-vars-board-title}} |
||
|<code>board_title</code> |
|<code>board_title</code> |
||
|<translate>string</translate> |
|<translate><!--T:238--> string</translate> |
||
| |
| |
||
|{{ll|Extension:StructuredDiscussions|nsp=0}} |
|{{ll|Extension:StructuredDiscussions|nsp=0}} |
||
Line 461: | Line 486: | ||
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-board-prefixedtitle}}</span> |
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-board-prefixedtitle}}</span> |
||
| <span style="opacity:0.5"><code>board_prefixedtext</code></span> |
| <span style="opacity:0.5"><code>board_prefixedtext</code></span> |
||
| <span style="opacity:0.5"><translate>string</translate></span> |
| <span style="opacity:0.5"><translate><!--T:239--> string</translate></span> |
||
| {{deprecated-inline}} <translate>Use <tvar|1><code>board_prefixedtitle</code></> instead.</translate> |
| {{deprecated-inline}} <translate><!--T:240--> Use <tvar|1><code>board_prefixedtitle</code></> instead.</translate> |
||
|{{ll|Extension:StructuredDiscussions|nsp=0}} |
|{{ll|Extension:StructuredDiscussions|nsp=0}} |
||
|- |
|- |
||
|{{int|abusefilter-edit-builder-vars-board-prefixedtitle}} |
|{{int|abusefilter-edit-builder-vars-board-prefixedtitle}} |
||
|<code>board_prefixedtitle</code> |
|<code>board_prefixedtitle</code> |
||
|<translate>string</translate> |
|<translate><!--T:241--> string</translate> |
||
| |
| |
||
|{{ll|Extension:StructuredDiscussions|nsp=0}} |
|{{ll|Extension:StructuredDiscussions|nsp=0}} |
||
Line 473: | Line 498: | ||
| {{int|abusefilter-edit-builder-vars-translate-source-text}} |
| {{int|abusefilter-edit-builder-vars-translate-source-text}} |
||
|<code>translate_source_text</code> |
|<code>translate_source_text</code> |
||
|<translate>string</translate> |
|<translate><!--T:242--> string</translate> |
||
| |
| |
||
|{{ll|Extension:Translate|nsp=0}} |
|{{ll|Extension:Translate|nsp=0}} |
||
Line 479: | Line 504: | ||
| {{int|abusefilter-edit-builder-vars-tor-exit-node}} |
| {{int|abusefilter-edit-builder-vars-tor-exit-node}} |
||
|<code>tor_exit_node</code> |
|<code>tor_exit_node</code> |
||
| <translate>boolean</translate> |
| <translate><!--T:243--> boolean</translate> |
||
| <translate>true if the action comes from a tor exit node.</translate> |
| <translate><!--T:244--> true if the action comes from a tor exit node.</translate> |
||
|{{ll|Extension:TorBlock|nsp=0}} |
|{{ll|Extension:TorBlock|nsp=0}} |
||
|- |
|- |
||
|{{int|abusefilter-edit-builder-vars-user-mobile}} |
|{{int|abusefilter-edit-builder-vars-user-mobile}} |
||
| <code>user_mobile</code> |
| <code>user_mobile</code> |
||
| <translate>boolean</translate> |
| <translate><!--T:245--> boolean</translate> |
||
| <translate>true for mobile users, false otherwise.</translate> |
| <translate><!--T:246--> true for mobile users, false otherwise.</translate> |
||
|{{ll|Extension:MobileFrontend|nsp=0}} |
|{{ll|Extension:MobileFrontend|nsp=0}} |
||
|- |
|- |
||
|{{int|abusefilter-edit-builder-vars-user-app}} |
|{{int|abusefilter-edit-builder-vars-user-app}} |
||
| <code>user_app</code> |
| <code>user_app</code> |
||
| <translate>boolean</translate> |
| <translate><!--T:247--> boolean</translate> |
||
| <translate>true if the user is editing from the mobile app, false otherwise.</translate> |
| <translate><!--T:248--> true if the user is editing from the mobile app, false otherwise.</translate> |
||
|{{ll|Extension:MobileApp|nsp=0}} |
|{{ll|Extension:MobileApp|nsp=0}} |
||
|- |
|- |
||
|{{int|abusefilter-edit-builder-vars-user-wpzero}} |
|{{int|abusefilter-edit-builder-vars-user-wpzero}} |
||
| <code>user_wpzero</code> |
| <code>user_wpzero</code> |
||
| <translate>boolean</translate> |
| <translate><!--T:249--> boolean</translate> |
||
| {{note|1=<translate>This variable is only valid when filtering an action.</translate> <translate>When examining a past edit or batch testing, it'll always be null.</translate>}} |
| {{note|1=<translate><!--T:250--> This variable is only valid when filtering an action.</translate> <translate><!--T:251--> When examining a past edit or batch testing, it'll always be null.</translate>}} |
||
|{{ll|Extension:WikimediaEvents|nsp=0}} |
|{{ll|Extension:WikimediaEvents|nsp=0}} |
||
|- |
|- |
||
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-page-views}}</span> |
| <span style="opacity:0.5">{{int|abusefilter-edit-builder-vars-page-views}}</span> |
||
| <span style="opacity:0.5"><code>article_views</code></span> |
| <span style="opacity:0.5"><code>article_views</code></span> |
||
| <span style="opacity:0.5"><translate>integer</translate></span> |
| <span style="opacity:0.5"><translate><!--T:252--> integer</translate></span> |
||
| {{deprecated-inline}} <translate>Use <tvar|1><code>page_views</code></> instead.</translate> |
| {{deprecated-inline}} <translate><!--T:253--> Use <tvar|1><code>page_views</code></> instead.</translate> |
||
|{{ll|Extension:HitCounters|nsp=0}} |
|{{ll|Extension:HitCounters|nsp=0}} |
||
|- |
|- |
||
|{{int|abusefilter-edit-builder-vars-page-views}} |
|{{int|abusefilter-edit-builder-vars-page-views}} |
||
| <code>page_views</code> |
| <code>page_views</code> |
||
| <translate>integer</translate> |
| <translate><!--T:254--> integer</translate> |
||
| <translate>the amount of page views</translate> |
| <translate><!--T:255--> the amount of page views</translate> |
||
|{{ll|Extension:HitCounters|nsp=0}} |
|{{ll|Extension:HitCounters|nsp=0}} |
||
|- |
|- |
||
|{{int|abusefilter-edit-builder-vars-movedfrom-views}} |
|{{int|abusefilter-edit-builder-vars-movedfrom-views}} |
||
| <code>moved_from_views</code> |
| <code>moved_from_views</code> |
||
| <translate>integer</translate> |
| <translate><!--T:256--> integer</translate> |
||
| <translate>the amount of page views of the source page</translate> |
| <translate><!--T:257--> the amount of page views of the source page</translate> |
||
|{{ll|Extension:HitCounters|nsp=0}} |
|{{ll|Extension:HitCounters|nsp=0}} |
||
|- |
|- |
||
|{{int|abusefilter-edit-builder-vars-movedto-views}} |
|{{int|abusefilter-edit-builder-vars-movedto-views}} |
||
| <code>moved_to_views</code> |
| <code>moved_to_views</code> |
||
| <translate>integer</translate> |
| <translate><!--T:258--> integer</translate> |
||
| <translate>the amount of page views of the target page</translate> |
| <translate><!--T:259--> the amount of page views of the target page</translate> |
||
|{{ll|Extension:HitCounters|nsp=0}} |
|{{ll|Extension:HitCounters|nsp=0}} |
||
|- |
|- |
||
| {{int|abusefilter-edit-builder-vars-is-proxy}} |
| {{int|abusefilter-edit-builder-vars-is-proxy}} |
||
| <code>is_proxy</code> |
| <code>is_proxy</code> |
||
| <translate>integer</translate> |
| <translate><!--T:260--> integer</translate> |
||
| <translate>Whether this action was performed through a proxy</translate> |
| <translate><!--T:261--> Whether this action was performed through a proxy</translate> |
||
| {{ll|Extension:AutoProxyBlock|nsp=0}} |
| {{ll|Extension:AutoProxyBlock|nsp=0}} |
||
|- |
|- |
||
|{{int|abusefilter-edit-builder-vars-sfs-blocked}} |
|{{int|abusefilter-edit-builder-vars-sfs-blocked}} |
||
| <code>sfs_blocked</code> |
| <code>sfs_blocked</code> |
||
| <translate>boolean</translate> |
| <translate><!--T:262--> boolean</translate> |
||
| <translate>Whether the IP address is blocked using the <tvar|1>stopforumspam.com</> list</translate> |
| <translate><!--T:263--> Whether the IP address is blocked using the <tvar|1>stopforumspam.com</> list</translate> |
||
| {{ll|Extension:StopForumSpam|nsp=0}} |
| {{ll|Extension:StopForumSpam|nsp=0}} |
||
|} |
|} |
||
<translate> |
<translate> |
||
=== Notes === |
=== Notes === <!--T:264--> |
||
<!--T:265--> |
|||
When <tvar|1><code>action='move'</code></>, only the <tvar|2><code>summary</code></>, <tvar|3><code>action</code></>,<tvar|4> <code>timestamp</code></> and <tvar|5><code>user_*</code></> variables are available.</translate> |
When <tvar|1><code>action='move'</code></>, only the <tvar|2><code>summary</code></>, <tvar|3><code>action</code></>,<tvar|4> <code>timestamp</code></> and <tvar|5><code>user_*</code></> variables are available.</translate> |
||
<translate> |
<translate> |
||
<!--T:266--> |
|||
The <tvar|1><code>page_*</code></> variables are also available, but the prefix is replaced by <tvar|2><code>moved_from_</code></> and <tvar|3><code>moved_to_</code></>, that represent the values of the original article name and the destination one, respectively.</translate> |
The <tvar|1><code>page_*</code></> variables are also available, but the prefix is replaced by <tvar|2><code>moved_from_</code></> and <tvar|3><code>moved_to_</code></>, that represent the values of the original article name and the destination one, respectively.</translate> |
||
<translate> |
<translate> |
||
<!--T:267--> |
|||
For example, <tvar|1><code>moved_from_title</code></> and <tvar|2><code>moved_to_title</code></> instead of <tvar|3><code>page_title</code></>. |
For example, <tvar|1><code>moved_from_title</code></> and <tvar|2><code>moved_to_title</code></> instead of <tvar|3><code>page_title</code></>. |
||
<!--T:268--> |
|||
Since MediaWiki 1.28 (<tvar|1>https://gerrit.wikimedia.org/r/#/c/295254/</>), <tvar|2><code>action='upload'</code></> is only used when publishing an upload, and not for uploads to stash.</translate> |
Since MediaWiki 1.28 (<tvar|1>https://gerrit.wikimedia.org/r/#/c/295254/</>), <tvar|2><code>action='upload'</code></> is only used when publishing an upload, and not for uploads to stash.</translate> |
||
<translate> |
<translate> |
||
<!--T:269--> |
|||
A new <tvar|1><code>action='stashupload'</code></> is introduced, which is used for all uploads, including uploads to stash.</translate> |
A new <tvar|1><code>action='stashupload'</code></> is introduced, which is used for all uploads, including uploads to stash.</translate> |
||
<translate> |
<translate> |
||
<!--T:270--> |
|||
This behaves like <tvar|1><code>action='upload'</code></> used to, and only provides file metadata variables (<tvar|2><code>file_*</code></>).</translate> |
This behaves like <tvar|1><code>action='upload'</code></> used to, and only provides file metadata variables (<tvar|2><code>file_*</code></>).</translate> |
||
<translate> |
<translate> |
||
<!--T:271--> |
|||
Variables related to the page edit, including <tvar|1><code>summary</code></>, <tvar|2><code>new_wikitext</code></> and several others, are now available for <tvar|3><code>action='upload'</code></>.</translate> |
Variables related to the page edit, including <tvar|1><code>summary</code></>, <tvar|2><code>new_wikitext</code></> and several others, are now available for <tvar|3><code>action='upload'</code></>.</translate> |
||
<translate> |
<translate> |
||
<!--T:272--> |
|||
For every file upload, filters may be called with <tvar|1><code>action='stashupload'</code></> (for uploads to stash), and are always called with <tvar|2><code>action='upload'</code></>; they are not called with <tvar|3><code>action='edit'</code></>. |
For every file upload, filters may be called with <tvar|1><code>action='stashupload'</code></> (for uploads to stash), and are always called with <tvar|2><code>action='upload'</code></>; they are not called with <tvar|3><code>action='edit'</code></>. |
||
<!--T:273--> |
|||
Filter authors should use <tvar|1><code>action='stashupload' | action='upload'</code></> in filter code when a file can be checked based only on the file contents – for example, to reject low-resolution files – and <tvar|2><code>action='upload'</code></> only when the wikitext parts of the edit need to be examined too – for example, to reject files with no description.</translate> |
Filter authors should use <tvar|1><code>action='stashupload' | action='upload'</code></> in filter code when a file can be checked based only on the file contents – for example, to reject low-resolution files – and <tvar|2><code>action='upload'</code></> only when the wikitext parts of the edit need to be examined too – for example, to reject files with no description.</translate> |
||
<translate> |
<translate> |
||
<!--T:274--> |
|||
This will allow tools that separate uploading the file and publishing the file (e.g. [[UploadWizard]] or [[upload dialog]]) to inform the user of the failure before they spend the time filling in the upload details. |
This will allow tools that separate uploading the file and publishing the file (e.g. [[UploadWizard]] or [[upload dialog]]) to inform the user of the failure before they spend the time filling in the upload details. |
||
</translate> |
</translate> |
||
Line 564: | Line 599: | ||
{{anchor|Performance}} |
{{anchor|Performance}} |
||
<translate> |
<translate> |
||
=== Performance === |
=== Performance === <!--T:275--> |
||
<!--T:276--> |
|||
As noted in the table above, some of these variables can be very slow.</translate> |
As noted in the table above, some of these variables can be very slow.</translate> |
||
<translate> |
<translate> |
||
<!--T:277--> |
|||
While writing filters, remember that the condition limit is '''not''' a good metric of how heavy filters are.</translate> |
While writing filters, remember that the condition limit is '''not''' a good metric of how heavy filters are.</translate> |
||
<translate> |
<translate> |
||
<!--T:278--> |
|||
For instance, variables like <tvar|1><code>*_recent_contributors</code></> or <tvar|2><code>*_links</code></> always need a DB query to be computed, while <tvar|3><code>*_pst</code></> variables will have to perform parsing of the text, which again is a heavy operation; all these variables should be used very, very carefully.</translate> |
For instance, variables like <tvar|1><code>*_recent_contributors</code></> or <tvar|2><code>*_links</code></> always need a DB query to be computed, while <tvar|3><code>*_pst</code></> variables will have to perform parsing of the text, which again is a heavy operation; all these variables should be used very, very carefully.</translate> |
||
<translate> |
<translate> |
||
<!--T:279--> |
|||
For instance, on Italian Wikipedia it's been observed that, with 135 active filters and an average of 450 used conditions, filters execution time was around 500ms, with peaks reaching 15 seconds.</translate> |
For instance, on Italian Wikipedia it's been observed that, with 135 active filters and an average of 450 used conditions, filters execution time was around 500ms, with peaks reaching 15 seconds.</translate> |
||
<translate> |
<translate> |
||
<!--T:280--> |
|||
Removing the <tvar|1><code>added_links</code></> variable from a single filter, and halving the cases when another filter would use <tvar|2><code>added_lines_pst</code></> brought the average execution time to 50ms.</translate> |
Removing the <tvar|1><code>added_links</code></> variable from a single filter, and halving the cases when another filter would use <tvar|2><code>added_lines_pst</code></> brought the average execution time to 50ms.</translate> |
||
<translate> |
<translate> |
||
<!--T:281--> |
|||
More specifically: |
More specifically: |
||
</translate> |
</translate> |
||
<translate> |
<translate> |
||
<!--T:282--> |
|||
* Use <tvar|1><code>_links</code></> variables when you need high accuracy and checking for "<tvar|2>http://...</>" in other variables (for instance, <tvar|3><code>added_lines</code></>) could lead to heavy malfunctioning;</translate> |
* Use <tvar|1><code>_links</code></> variables when you need high accuracy and checking for "<tvar|2>http://...</>" in other variables (for instance, <tvar|3><code>added_lines</code></>) could lead to heavy malfunctioning;</translate> |
||
<translate> |
<translate> |
||
<!--T:283--> |
|||
* Use <tvar|1><code>_pst</code></> variables when you're really sure that non-PST variables aren't enough.</translate> <translate>You may also conditionally decide which one to check: if, for instance, you want to examine a signature, check first if <tvar|1><code>added_lines</code></> contains <tvar|2><code><nowiki>~~~</nowiki></code></>;</translate> |
* Use <tvar|1><code>_pst</code></> variables when you're really sure that non-PST variables aren't enough.</translate> <translate><!--T:284--> You may also conditionally decide which one to check: if, for instance, you want to examine a signature, check first if <tvar|1><code>added_lines</code></> contains <tvar|2><code><nowiki>~~~</nowiki></code></>;</translate> |
||
<translate> |
<translate> |
||
<!--T:285--> |
|||
* In general, when dealing with these variables, it's always much better to consume further conditions but avoid computing heavy stuff.</translate> <translate>In order to achieve this, always put heavy variables as last conditions.</translate> |
* In general, when dealing with these variables, it's always much better to consume further conditions but avoid computing heavy stuff.</translate> <translate><!--T:286--> In order to achieve this, always put heavy variables as last conditions.</translate> |
||
<translate>Last but not least, note that whenever a variable is computed for a given filter, it'll be saved and any other filter will immediately retrieve it.</translate> <translate> |
<translate><!--T:287--> Last but not least, note that whenever a variable is computed for a given filter, it'll be saved and any other filter will immediately retrieve it.</translate> <translate><!--T:288--> |
||
This means that one single filter computing this variable counts more or less as dozens of filters using it. |
|||
== Keywords == |
== Keywords == <!--T:289--> |
||
</translate> |
</translate> |
||
{{note|1=<translate>Where not specifically stated, keywords cast their operands to strings</translate>}} |
{{note|1=<translate><!--T:290--> Where not specifically stated, keywords cast their operands to strings</translate>}} |
||
<translate> |
<translate> |
||
<!--T:291--> |
|||
The following special keywords are included for often-used functionality: |
The following special keywords are included for often-used functionality: |
||
</translate> |
</translate> |
||
* <translate><tvar|1><code>like</code></> (or <tvar|2><code>matches</code></>) returns true if the left-hand operand matches the [[w:Glob (programming)#Syntax|glob pattern]] in the right-hand operand.</translate> |
* <translate><!--T:292--> <tvar|1><code>like</code></> (or <tvar|2><code>matches</code></>) returns true if the left-hand operand matches the [[w:Glob (programming)#Syntax|glob pattern]] in the right-hand operand.</translate> |
||
* <translate><tvar|1><code>in</code></> returns true if the right-hand operand (a string) contains the left-hand operand.</translate> '''<translate>Note:</translate>''' <translate>empty strings are not contained in, nor contain, any other string (not even the empty string itself).</translate> |
* <translate><!--T:293--> <tvar|1><code>in</code></> returns true if the right-hand operand (a string) contains the left-hand operand.</translate> '''<translate><!--T:294--> Note:</translate>''' <translate><!--T:295--> empty strings are not contained in, nor contain, any other string (not even the empty string itself).</translate> |
||
* <translate><tvar|1><code>contains</code></> works like <tvar|2><code>in</code></>, but with the left and right-hand operands switched.</translate> '''<translate>Note:</translate>''' <translate>empty strings are not contained in, nor contain, any other string (not even the empty string itself).</translate> |
* <translate><!--T:296--> <tvar|1><code>contains</code></> works like <tvar|2><code>in</code></>, but with the left and right-hand operands switched.</translate> '''<translate><!--T:297--> Note:</translate>''' <translate><!--T:298--> empty strings are not contained in, nor contain, any other string (not even the empty string itself).</translate> |
||
* <translate><tvar|1><code>rlike</code></> (or <tvar|2><code>regex</code></>) and <tvar|3><code>irlike</code></> return true if the left-hand operand matches (contains) the [[w:Regular expression|regex]] pattern in the right-hand operand (<tvar|4><code>irlike</code></> is case '''i'''nsensitive).</translate> |
* <translate><!--T:299--> <tvar|1><code>rlike</code></> (or <tvar|2><code>regex</code></>) and <tvar|3><code>irlike</code></> return true if the left-hand operand matches (contains) the [[w:Regular expression|regex]] pattern in the right-hand operand (<tvar|4><code>irlike</code></> is case '''i'''nsensitive).</translate> |
||
<translate> |
<translate> |
||
<!--T:300--> |
|||
The system uses [[w:Perl Compatible Regular Expressions|PCRE]].</translate> |
The system uses [[w:Perl Compatible Regular Expressions|PCRE]].</translate> |
||
<translate> |
<translate> |
||
<!--T:301--> |
|||
The only PCRE option enabled is <tvar|1><code>PCRE_UTF8</code></> (modifier <tvar|2><code>u</code></> [<tvar|3>https://secure.php.net/reference.pcre.pattern.modifiers</> in PHP]); for <tvar|4><code>irlike</code></> both <tvar|5><code>PCRE_CASELESS</code></> and <tvar|6><code>PCRE_UTF8</code></> are enabled (modifier <tvar|7><code>iu</code></>). |
The only PCRE option enabled is <tvar|1><code>PCRE_UTF8</code></> (modifier <tvar|2><code>u</code></> [<tvar|3>https://secure.php.net/reference.pcre.pattern.modifiers</> in PHP]); for <tvar|4><code>irlike</code></> both <tvar|5><code>PCRE_CASELESS</code></> and <tvar|6><code>PCRE_UTF8</code></> are enabled (modifier <tvar|7><code>iu</code></>). |
||
</translate> |
</translate> |
||
Line 609: | Line 657: | ||
* <code>true</code>, <code>false</code>, <code>null</code> |
* <code>true</code>, <code>false</code>, <code>null</code> |
||
'''<translate>Examples</translate>''' |
'''<translate><!--T:302--> Examples</translate>''' |
||
<!--Note: these examples are also used in https://phabricator.wikimedia.org/diffusion/EABF/browse/master/tests/parserTests/mwexamples-keywords.t --> |
<!--Note: these examples are also used in https://phabricator.wikimedia.org/diffusion/EABF/browse/master/tests/parserTests/mwexamples-keywords.t --> |
||
{| class="wikitable" |
{| class="wikitable" |
||
Line 635: | Line 683: | ||
| <code> "o" in ["foo", "bar"]</code> |
| <code> "o" in ["foo", "bar"]</code> |
||
| True |
| True |
||
| <translate>Due to the string cast</translate> |
| <translate><!--T:303--> Due to the string cast</translate> |
||
|- |
|- |
||
| <code>"foo" regex "\w+"</code> |
| <code>"foo" regex "\w+"</code> |
||
Line 643: | Line 691: | ||
| <code>"a\b" regex "a\\\\b"</code> |
| <code>"a\b" regex "a\\\\b"</code> |
||
| True |
| True |
||
| rowspan= "2" | <translate>To look for the escape character backslash using regex you need<br /> to use either four backslashes or two <tvar|1><code>\x5C</code></>.</translate> <translate>(Either works fine.)</translate> |
| rowspan= "2" | <translate><!--T:304--> To look for the escape character backslash using regex you need<br /> to use either four backslashes or two <tvar|1><code>\x5C</code></>.</translate> <translate><!--T:305--> (Either works fine.)</translate> |
||
|- |
|- |
||
| <code>"a\b" regex "a\x5C\x5Cb"</code> |
| <code>"a\b" regex "a\x5C\x5Cb"</code> |
||
Line 650: | Line 698: | ||
<translate> |
<translate> |
||
== Functions == |
== Functions == <!--T:306--> |
||
<!--T:307--> |
|||
A number of built-in functions are included to ease some common issues.</translate> |
A number of built-in functions are included to ease some common issues.</translate> |
||
<translate> |
<translate> |
||
<!--T:308--> |
|||
They are executed in the general format <tvar|1><code>functionName( arg1, arg2, arg3 )</code></>, and can be used in place of any literal or variable.</translate> |
They are executed in the general format <tvar|1><code>functionName( arg1, arg2, arg3 )</code></>, and can be used in place of any literal or variable.</translate> |
||
<translate> |
<translate> |
||
<!--T:309--> |
|||
Its arguments can be given as literals, variables, or even other functions. |
Its arguments can be given as literals, variables, or even other functions. |
||
</translate> |
</translate> |
||
{| class="wikitable sortable" |
{| class="wikitable sortable" |
||
! <translate>name</translate> !! <translate>description</translate> |
! <translate><!--T:310--> name</translate> !! <translate><!--T:311--> description</translate> |
||
|- |
|- |
||
| <code>lcase</code> || <translate>Returns the argument converted to lower case.</translate> |
| <code>lcase</code> || <translate><!--T:312--> Returns the argument converted to lower case.</translate> |
||
|- |
|- |
||
| <code>ucase</code> || <translate>Returns the argument converted to upper case.</translate> |
| <code>ucase</code> || <translate><!--T:313--> Returns the argument converted to upper case.</translate> |
||
|- |
|- |
||
| <code>length</code> || <translate>Returns the length of the string given as the argument.</translate> <translate>If the argument is an array, returns its number of elements.</translate> |
| <code>length</code> || <translate><!--T:314--> Returns the length of the string given as the argument.</translate> <translate><!--T:315--> If the argument is an array, returns its number of elements.</translate> |
||
|- |
|- |
||
| <code>string</code> || <translate>Casts to string data type.</translate> <translate>If the argument is an array, implodes it with linebreaks.</translate> |
| <code>string</code> || <translate><!--T:316--> Casts to string data type.</translate> <translate><!--T:317--> If the argument is an array, implodes it with linebreaks.</translate> |
||
|- |
|- |
||
| <code>int</code> || <translate>Casts to integer data type.</translate> |
| <code>int</code> || <translate><!--T:318--> Casts to integer data type.</translate> |
||
|- |
|- |
||
| <code>float</code> || <translate>Casts to floating-point data type.</translate> |
| <code>float</code> || <translate><!--T:319--> Casts to floating-point data type.</translate> |
||
|- |
|- |
||
| <code>bool</code> || <translate>Casts to boolean data type.</translate> |
| <code>bool</code> || <translate><!--T:320--> Casts to boolean data type.</translate> |
||
|- |
|- |
||
| <code>norm</code> || <translate>Equivalent to <tvar|1><code>rmwhitespace(rmspecials(rmdoubles(ccnorm(arg1))))</code></>.</translate> |
| <code>norm</code> || <translate><!--T:321--> Equivalent to <tvar|1><code>rmwhitespace(rmspecials(rmdoubles(ccnorm(arg1))))</code></>.</translate> |
||
|- |
|- |
||
| <code>ccnorm</code> || <translate>Normalises confusable/similar characters in the argument, and returns a canonical form.</translate> <translate>A list of characters and their replacements can be found [[<tvar|1>phab:source/Equivset/browse/master/data/equivset.in</>|on git]], e.g. <tvar|2><code>ccnorm( "Eeèéëēĕėęě3ƐƷ" ) === "EEEEEEEEEEEEE"</code></>.</translate><ref name="T27619"><translate>Be aware of <tvar|1>[[phab:T27619]]</>.</translate> <translate>You can use <tvar|1>[[Special:AbuseFilter/tools]]</> to evaluate <tvar|2><code>ccnorm( "your string" )</code></> to see which characters are transformed.</translate></ref> <translate>The output of this function is always uppercase.</translate> |
| <code>ccnorm</code> || <translate><!--T:322--> Normalises confusable/similar characters in the argument, and returns a canonical form.</translate> <translate><!--T:323--> A list of characters and their replacements can be found [[<tvar|1>phab:source/Equivset/browse/master/data/equivset.in</>|on git]], e.g. <tvar|2><code>ccnorm( "Eeèéëēĕėęě3ƐƷ" ) === "EEEEEEEEEEEEE"</code></>.</translate><ref name="T27619"><translate><!--T:324--> Be aware of <tvar|1>[[phab:T27619]]</>.</translate> <translate><!--T:325--> You can use <tvar|1>[[Special:AbuseFilter/tools]]</> to evaluate <tvar|2><code>ccnorm( "your string" )</code></> to see which characters are transformed.</translate></ref> <translate><!--T:326--> The output of this function is always uppercase.</translate> |
||
|- |
|- |
||
| <code>ccnorm_contains_any</code> || <translate>Normalises confusable/similar characters in the arguments, and returns true if the first string contains '''any''' strings from the following arguments (unlimited number of arguments, logic OR mode).</translate> <translate>A list of characters and their replacements can be found [[<tvar|1>phab:source/Equivset/browse/master/data/equivset.in</>|on git]].</translate> |
| <code>ccnorm_contains_any</code> || <translate><!--T:327--> Normalises confusable/similar characters in the arguments, and returns true if the first string contains '''any''' strings from the following arguments (unlimited number of arguments, logic OR mode).</translate> <translate><!--T:328--> A list of characters and their replacements can be found [[<tvar|1>phab:source/Equivset/browse/master/data/equivset.in</>|on git]].</translate> |
||
|- |
|- |
||
| <code>ccnorm_contains_all</code> || <translate>Normalises confusable/similar characters in the arguments, and returns true if the first string contains '''every''' strings from the following arguments (unlimited number of arguments, logic AND mode).</translate> <translate>A list of characters and their replacements can be found [[<tvar|1>phab:source/Equivset/browse/master/data/equivset.in</>|on git]].</translate> |
| <code>ccnorm_contains_all</code> || <translate><!--T:329--> Normalises confusable/similar characters in the arguments, and returns true if the first string contains '''every''' strings from the following arguments (unlimited number of arguments, logic AND mode).</translate> <translate><!--T:330--> A list of characters and their replacements can be found [[<tvar|1>phab:source/Equivset/browse/master/data/equivset.in</>|on git]].</translate> |
||
|- |
|- |
||
| <code>specialratio</code> || <translate>Returns the number of non-alphanumeric characters divided by the total number of characters in the argument.</translate> |
| <code>specialratio</code> || <translate><!--T:331--> Returns the number of non-alphanumeric characters divided by the total number of characters in the argument.</translate> |
||
|- |
|- |
||
| <code>rmspecials</code> || <translate>Removes any special characters in the argument, and returns the result.</translate> <translate>(Equivalent to <tvar|1>s/[^\p{L}\p{N}]//g</>.)</translate> |
| <code>rmspecials</code> || <translate><!--T:332--> Removes any special characters in the argument, and returns the result.</translate> <translate><!--T:333--> (Equivalent to <tvar|1>s/[^\p{L}\p{N}]//g</>.)</translate> |
||
|- |
|- |
||
| <code>rmdoubles</code> || <translate>Removes repeated characters in the argument, and returns the result.</translate> |
| <code>rmdoubles</code> || <translate><!--T:334--> Removes repeated characters in the argument, and returns the result.</translate> |
||
|- |
|- |
||
| <code>rmwhitespace</code> || <translate>Removes whitespace (spaces, tabs, newlines).</translate> |
| <code>rmwhitespace</code> || <translate><!--T:335--> Removes whitespace (spaces, tabs, newlines).</translate> |
||
|- |
|- |
||
| <code>count</code> || <translate>Returns the number of times the needle (first string) appears in the haystack (second string).</translate> <translate>If only one argument is given, splits it by commas and returns the number of segments.</translate> |
| <code>count</code> || <translate><!--T:336--> Returns the number of times the needle (first string) appears in the haystack (second string).</translate> <translate><!--T:337--> If only one argument is given, splits it by commas and returns the number of segments.</translate> |
||
|- |
|- |
||
| <code>rcount</code> || <translate>Similar to <tvar|1><code>count</code></> but the needle uses a regular expression instead.</translate> <translate>Can be made case-insensitive by letting the regular expression start with "<tvar|2>(?i)</>".</translate> |
| <code>rcount</code> || <translate><!--T:338--> Similar to <tvar|1><code>count</code></> but the needle uses a regular expression instead.</translate> <translate><!--T:339--> Can be made case-insensitive by letting the regular expression start with "<tvar|2>(?i)</>".</translate> |
||
|- |
|- |
||
| <code>get_matches</code> || {{MW version-inline|MW 1.31+}} <translate>Looks for matches of the regex needle (first string) in the haystack (second string).</translate> <translate>Returns an array where the 0 element is the whole match and every <tvar|1><code>[n]</code></> element is the match of the n'th capturing group of the needle.</translate> <translate>Can be made case-insensitive by letting the regular expression start with "<tvar|1>(?i)</>".</translate> <translate>If a capturing group didn't match, that array position will take value of ''false''.</translate> |
| <code>get_matches</code> || {{MW version-inline|MW 1.31+}} <translate><!--T:340--> Looks for matches of the regex needle (first string) in the haystack (second string).</translate> <translate><!--T:341--> Returns an array where the 0 element is the whole match and every <tvar|1><code>[n]</code></> element is the match of the n'th capturing group of the needle.</translate> <translate><!--T:342--> Can be made case-insensitive by letting the regular expression start with "<tvar|1>(?i)</>".</translate> <translate><!--T:343--> If a capturing group didn't match, that array position will take value of ''false''.</translate> |
||
|- |
|- |
||
| <code>ip_in_range</code> || <translate>Returns true if user's IP (first string) matches specified IP ranges (second string).</translate> <translate>Only works for anonymous users.</translate> <translate>Supports both IPv4 and IPv6 addresses.</translate> |
| <code>ip_in_range</code> || <translate><!--T:344--> Returns true if user's IP (first string) matches specified IP ranges (second string).</translate> <translate><!--T:345--> Only works for anonymous users.</translate> <translate><!--T:346--> Supports both IPv4 and IPv6 addresses.</translate> |
||
|- |
|- |
||
| <code>contains_any</code> || <translate>Returns true if the first string contains '''any''' strings from the following arguments (unlimited number of arguments in logic OR mode).</translate> <translate>If the first argument is an array, it gets casted to string.</translate> |
| <code>contains_any</code> || <translate><!--T:347--> Returns true if the first string contains '''any''' strings from the following arguments (unlimited number of arguments in logic OR mode).</translate> <translate><!--T:348--> If the first argument is an array, it gets casted to string.</translate> |
||
|- |
|- |
||
| <code>contains_all</code> || <translate>Returns true if the first string contains '''every''' strings from the following arguments (unlimited number of arguments in logic AND mode).</translate> <translate>If the first argument is an array, it gets casted to string.</translate> |
| <code>contains_all</code> || <translate><!--T:349--> Returns true if the first string contains '''every''' strings from the following arguments (unlimited number of arguments in logic AND mode).</translate> <translate><!--T:350--> If the first argument is an array, it gets casted to string.</translate> |
||
|- |
|- |
||
| <code>equals_to_any</code> || <translate>Returns true if the first argument is identical (<tvar|1><code>===</code></>) to any of the following ones (unlimited number of arguments).</translate> <translate>Basically, <tvar|1><code>equals_to_any(a, b, c)</code></> is the same as <tvar|2><code><nowiki>a===b | a===c</nowiki></code></>, but more compact and saves conditions.</translate> |
| <code>equals_to_any</code> || <translate><!--T:351--> Returns true if the first argument is identical (<tvar|1><code>===</code></>) to any of the following ones (unlimited number of arguments).</translate> <translate><!--T:352--> Basically, <tvar|1><code>equals_to_any(a, b, c)</code></> is the same as <tvar|2><code><nowiki>a===b | a===c</nowiki></code></>, but more compact and saves conditions.</translate> |
||
|- |
|- |
||
| <code>substr</code> || <translate>Returns the portion of the first string, by offset from the second argument (starts at 0) and maximum length from the third argument (optional).</translate> |
| <code>substr</code> || <translate><!--T:353--> Returns the portion of the first string, by offset from the second argument (starts at 0) and maximum length from the third argument (optional).</translate> |
||
|- |
|- |
||
| <code>strlen</code> || <translate>Same as <tvar|1><code>length</code></>.</translate> |
| <code>strlen</code> || <translate><!--T:354--> Same as <tvar|1><code>length</code></>.</translate> |
||
|- |
|- |
||
| <code>strpos</code> || <translate>Returns the numeric position of the first occurrence of needle (second string) in the haystack (first string), starting from offset from the third argument (optional, default is 0).</translate> <translate>This function may return 0 when the needle is found at the begining of the haystack, so it might be misinterpreted as ''false'' value by another comparative operator.</translate> <translate>The better way is to use <tvar|1><code>===</code></> or <tvar|2><code>!==</code></> for testing whether it is found.</translate> |
| <code>strpos</code> || <translate><!--T:355--> Returns the numeric position of the first occurrence of needle (second string) in the haystack (first string), starting from offset from the third argument (optional, default is 0).</translate> <translate><!--T:356--> This function may return 0 when the needle is found at the begining of the haystack, so it might be misinterpreted as ''false'' value by another comparative operator.</translate> <translate><!--T:357--> The better way is to use <tvar|1><code>===</code></> or <tvar|2><code>!==</code></> for testing whether it is found.</translate> |
||
|- |
|- |
||
| <code>str_replace</code> || <translate>Replaces all occurrences of the search string with the replacement string.</translate> <translate>The function takes 3 arguments in the following order: text to perform the search on, text to find, replacement text.</translate> |
| <code>str_replace</code> || <translate><!--T:358--> Replaces all occurrences of the search string with the replacement string.</translate> <translate><!--T:359--> The function takes 3 arguments in the following order: text to perform the search on, text to find, replacement text.</translate> |
||
|- |
|- |
||
| <code>rescape</code> || <translate>Returns the argument with some characters preceded with the escape character <tvar|1>"\"</>, so that the string can be used in a regular expression without those characters having a special meaning.</translate> |
| <code>rescape</code> || <translate><!--T:360--> Returns the argument with some characters preceded with the escape character <tvar|1>"\"</>, so that the string can be used in a regular expression without those characters having a special meaning.</translate> |
||
|- |
|- |
||
| <code>set</code> || <translate>Sets a variable (first string) with a given value (second argument) for further use in the filter.</translate> <translate>Another syntax: <tvar|1><code>''name'' := ''value''</code></>.</translate> |
| <code>set</code> || <translate><!--T:361--> Sets a variable (first string) with a given value (second argument) for further use in the filter.</translate> <translate><!--T:362--> Another syntax: <tvar|1><code>''name'' := ''value''</code></>.</translate> |
||
|- |
|- |
||
| <code>set_var</code> || <translate>Same as <tvar|1><code>set</code></>.</translate> |
| <code>set_var</code> || <translate><!--T:363--> Same as <tvar|1><code>set</code></>.</translate> |
||
|} |
|} |
||
<translate> |
<translate> |
||
=== Examples === |
=== Examples === <!--T:364--> |
||
</translate> |
</translate> |
||
<!--Note: these examples are also used in https://phabricator.wikimedia.org/diffusion/EABF/browse/master/tests/parserTests/mwexamples-functions.t --> |
<!--Note: these examples are also used in https://phabricator.wikimedia.org/diffusion/EABF/browse/master/tests/parserTests/mwexamples-functions.t --> |
||
{| class="wikitable" |
{| class="wikitable" |
||
!<translate>Code</translate> |
!<translate><!--T:365--> Code</translate> |
||
!<translate>Result</translate> |
!<translate><!--T:366--> Result</translate> |
||
!<translate>Comment</translate> |
!<translate><!--T:367--> Comment</translate> |
||
|- |
|- |
||
| <code>length( "Wikipedia" )</code> |
| <code>length( "Wikipedia" )</code> |
||
Line 740: | Line 791: | ||
| <code>ccnorm( "w1k1p3d14" )</code> |
| <code>ccnorm( "w1k1p3d14" )</code> |
||
| WIKIPEDIA |
| WIKIPEDIA |
||
|<translate><tvar|1><code>ccnorm</code></> output is always uppercase</translate> |
|<translate><!--T:368--> <tvar|1><code>ccnorm</code></> output is always uppercase</translate> |
||
|- |
|- |
||
| <code>ccnorm( "ωɨƙɩᑭƐƉ1α" )</code> |
| <code>ccnorm( "ωɨƙɩᑭƐƉ1α" )</code> |
||
Line 768: | Line 819: | ||
|<code>norm( "F00 B@rr" )</code> |
|<code>norm( "F00 B@rr" )</code> |
||
|FOBAR |
|FOBAR |
||
|<translate><tvar|1><code>norm</code></> removes whitespace, special characters and duplicates, then uses <tvar|2><code>ccnorm</code></></translate><!-- |
|<translate><!--T:369--> <tvar|1><code>norm</code></> removes whitespace, special characters and duplicates, then uses <tvar|2><code>ccnorm</code></></translate><!-- |
||
|- |
|- |
||
| <code>convert( "zh-hant", "维基百科" )</code><br />// assume we work on a wiki with Chinese LanguageConverter class |
| <code>convert( "zh-hant", "维基百科" )</code><br />// assume we work on a wiki with Chinese LanguageConverter class |
||
Line 816: | Line 867: | ||
<translate> |
<translate> |
||
== Order of operations == |
== Order of operations == <!--T:370--> |
||
<!--T:371--> |
|||
Operations are generally done left-to-right, but there is an order to which they are resolved.</translate> |
Operations are generally done left-to-right, but there is an order to which they are resolved.</translate> |
||
<translate> |
<translate> |
||
<!--T:372--> |
|||
As soon as the filter fails one of the conditions, it will stop checking the rest of them (due to [[w:short-circuit evaluation|short-circuit evaluation]]) and move on to the next filter (except for <tvar|1>[[phab:T43693]]</>).</translate> |
As soon as the filter fails one of the conditions, it will stop checking the rest of them (due to [[w:short-circuit evaluation|short-circuit evaluation]]) and move on to the next filter (except for <tvar|1>[[phab:T43693]]</>).</translate> |
||
<translate> |
<translate> |
||
<!--T:373--> |
|||
The evaluation order is: |
The evaluation order is: |
||
</translate> |
</translate> |
||
# <translate>Anything surrounded by parentheses (<tvar|1><code>(</code></> and <tvar|2><code>)</code></>) is evaluated as a single unit.</translate> |
# <translate><!--T:374--> Anything surrounded by parentheses (<tvar|1><code>(</code></> and <tvar|2><code>)</code></>) is evaluated as a single unit.</translate> |
||
# <translate>Turning variables/literals into their respective data. (i.e., <tvar|1><code>page_namespace</code></> to 0)</translate> |
# <translate><!--T:375--> Turning variables/literals into their respective data. (i.e., <tvar|1><code>page_namespace</code></> to 0)</translate> |
||
# <translate>Function calls (<tvar|1><code>norm</code></>, <tvar|2><code>lcase</code></>, etc.)</translate> |
# <translate><!--T:376--> Function calls (<tvar|1><code>norm</code></>, <tvar|2><code>lcase</code></>, etc.)</translate> |
||
# <translate>Unary <tvar|1><code>+</code></> and <tvar|2><code>-</code></> (defining positive or negative value, e.g. <tvar|3><code>-1234</code></>, <tvar|4><code>+1234</code></>)</translate> |
# <translate><!--T:377--> Unary <tvar|1><code>+</code></> and <tvar|2><code>-</code></> (defining positive or negative value, e.g. <tvar|3><code>-1234</code></>, <tvar|4><code>+1234</code></>)</translate> |
||
# <translate>Keywords</translate> |
# <translate><!--T:378--> Keywords</translate> |
||
# <translate>Boolean inversion</translate> (<code>!x</code>) |
# <translate><!--T:379--> Boolean inversion</translate> (<code>!x</code>) |
||
# <translate>Exponentiation</translate> (<code>2**3 → 8</code>) |
# <translate><!--T:380--> Exponentiation</translate> (<code>2**3 → 8</code>) |
||
# <translate>Multiplication-related (multiplication, division, modulo)</translate> |
# <translate><!--T:381--> Multiplication-related (multiplication, division, modulo)</translate> |
||
# <translate>Addition and subtraction</translate> (<code>3-2 → 1</code>) |
# <translate><!--T:382--> Addition and subtraction</translate> (<code>3-2 → 1</code>) |
||
# <translate>Comparisons.</translate> (<code><</code>, <code>></code>, <code>==</code>) |
# <translate><!--T:383--> Comparisons.</translate> (<code><</code>, <code>></code>, <code>==</code>) |
||
# <translate>Boolean operations.</translate> (<code>&</code>, <code>|</code>, <code>^</code>) |
# <translate><!--T:384--> Boolean operations.</translate> (<code>&</code>, <code>|</code>, <code>^</code>) |
||
<translate> |
<translate> |
||
=== Examples === |
=== Examples === <!--T:385--> |
||
</translate> |
</translate> |
||
* <translate><tvar|1><code>A & B | C</code></> is equivalent to <tvar|2><code>(A & B) | C</code></>, not to <tvar|3><code>A & (B | C)</code></>.</translate> <translate>In particular, both <tvar|1><code>false & true '''| true'''</code></> and <tvar|2><code>false & false '''| true'''</code></> evaluates to <tvar|3><code>true</code></>.</translate> |
* <translate><!--T:386--> <tvar|1><code>A & B | C</code></> is equivalent to <tvar|2><code>(A & B) | C</code></>, not to <tvar|3><code>A & (B | C)</code></>.</translate> <translate><!--T:387--> In particular, both <tvar|1><code>false & true '''| true'''</code></> and <tvar|2><code>false & false '''| true'''</code></> evaluates to <tvar|3><code>true</code></>.</translate> |
||
* <translate><tvar|1><code>A | B & C</code></> is equivalent to <tvar|2><code>(A | B) & C</code></>, not to <tvar|3><code>A | (B & C)</code></>.</translate> <translate>In particular, both <tvar|1><code>true | true '''& false'''</code></> and <tvar|2><code>true | false '''& false'''</code></> evaluates to <tvar|3><code>false</code></>.</translate> |
* <translate><!--T:388--> <tvar|1><code>A | B & C</code></> is equivalent to <tvar|2><code>(A | B) & C</code></>, not to <tvar|3><code>A | (B & C)</code></>.</translate> <translate><!--T:389--> In particular, both <tvar|1><code>true | true '''& false'''</code></> and <tvar|2><code>true | false '''& false'''</code></> evaluates to <tvar|3><code>false</code></>.</translate> |
||
<translate> |
<translate> |
||
== Condition counting == |
== Condition counting == <!--T:390--> |
||
<!--T:391--> |
|||
The condition limit is (more or less) tracking the number of comparison operators + number of function calls entered. |
The condition limit is (more or less) tracking the number of comparison operators + number of function calls entered. |
||
<!--T:392--> |
|||
Further explanation on how to reduce conditions used can be found at {{ll|Extension:AbuseFilter/Conditions}}. |
Further explanation on how to reduce conditions used can be found at {{ll|Extension:AbuseFilter/Conditions}}. |
||
== Exclusions == |
== Exclusions == <!--T:393--> |
||
<!--T:394--> |
|||
Although the AbuseFilter examine function will identify "rollback" actions as edits, the AbuseFilter will not evaluate rollback actions for matching.</translate> <ref>[[phab:T24713|<translate>T24713 - rollback not matched by AF</translate>]]</ref> |
Although the AbuseFilter examine function will identify "rollback" actions as edits, the AbuseFilter will not evaluate rollback actions for matching.</translate> <ref>[[phab:T24713|<translate><!--T:395--> T24713 - rollback not matched by AF</translate>]]</ref> |
||
<translate> |
<translate> |
||
== Useful links == |
== Useful links == <!--T:396--> |
||
</translate> |
</translate> |
||
* [https://secure.php.net/reference.pcre.pattern.syntax <translate>PCRE pattern syntax</translate>] |
* [https://secure.php.net/reference.pcre.pattern.syntax <translate><!--T:397--> PCRE pattern syntax</translate>] |
||
* [[m:Edit filters benefiting to various local Wikiprojects|<translate>Edit filters benefiting to various local Wikiprojects</translate>]] |
* [[m:Edit filters benefiting to various local Wikiprojects|<translate><!--T:398--> Edit filters benefiting to various local Wikiprojects</translate>]] |
||
* {{ll|Extension:AbuseFilter/Conditions}} |
* {{ll|Extension:AbuseFilter/Conditions}} |
||
<translate> |
<translate> |
||
== Notes == |
== Notes == <!--T:399--> |
||
</translate> |
</translate> |
||
<references/> |
<references/> |
Revision as of 01:59, 27 January 2019
Template:Languages zh:Wikipedia:防滥用过滤器/操作指引 The rules are formatted much as conditionals in a C/Java/Perl-like language.
Strings
You can specify a literal by placing it in single or double quotes (for strings), or by typing it in as-is (for numbers, both floating-point and integer).
You can get linebreaks with \n
, tab characters with \t
, and you can also escape the quote character with a backslash.
Use the +
(plus) symbol to concatenate two literal strings or the values of two vars with a string value.
- Examples
"This is a string"
'This is also a string'
'This string shouldn\'t fail'
"This string\nHas a linebreak"
1234
1.234
-123
User-defined variables
You can define custom variables for ease of understanding with the assign symbol :=
in a line (closed by ;
) within a condition.
Such variables may use letters, underscores, and numbers (apart from the first character) and are case sensitive.
Example (from w:Special:AbuseFilter/79):
(
line1:="(\{\{(r|R)eflist|\{\{(r|R)efs|<references\s?/>|</references\s?>)";
rcount(line1, removed_lines)
) > (
rcount(line1, added_lines)
)
Arrays
AbuseFilter has support for non-associative arrays, which can be used like in the following examples.
my_array := [ 5, 6, 7, 10];
my_array[0] == 5
length(my_array) == 4
string(my_array) == "5\n6\n7\n10\n" //Note: the last linebreak could be removed in the future
5 in my_array == true
'5' in my_array == true
'5\n6' in my_array == true //Note: this is due to how arrays are casted to string, i.e. by imploding them with linebreaks
1 in my_array == true //Note: this happens because 'in' casts arguments to strings, so the 1 is catched in '10' and returns true.
Comments
You can specify comments using the following syntax:
/* This is a comment */
Arithmetic
You can use basic arithmetic symbols to do arithmetic on variables and literals with the following syntax:
-
— Subtract the right-hand operand from the left-hand operand.+
— Add the right-hand operand to the left-hand operand.*
— Multiply the left-hand operand by the right-hand operand./
— Divide the left-hand operand by the right-hand operand.**
— Raise the left-hand operand to the exponential power specified by the right-hand operand.%
— Return the remainder given when the left-hand operand is divided by the right-hand operand.
The type of the returned result is the same that would be returned by PHP, for which a lot of documentation may be found online. More exhaustive examples may be found in this AF parser test.
Example | Result |
---|---|
1 + 1 |
2 |
2 * 2 |
4 |
1 / 2 |
0.5 |
9 ** 2 |
81 |
6 % 5 |
1 |
Boolean operations
You can match if and only if all of a number of conditions are true, one of a number of conditions are true, or one and only one of all conditions are true.
x | y
— OR – returns true if one or more of the conditions is true.x & y
— AND – returns true if both of the conditions are true.x ^ y
— XOR – returns true if one, and only one of the two conditions is true.!x
— NOT – returns true if the condition is not true.
Examples
Code | Result |
---|---|
1 | 1
|
true |
1 | 0
|
true |
0 | 0
|
false |
1 & 1
|
true |
1 & 0
|
false |
0 & 0
|
false |
1 ^ 1
|
false |
1 ^ 0
|
true |
0 ^ 0
|
false |
!1
|
false |
Simple comparisons
You can compare variables with other variables and literals with the following syntax:
<
Template:Int>
— Return true if the left-hand operand is less than/greater than the right-hand operand respectively. Watch out: operands are casted to strings and, like it happens in PHP,null < any number === true
andnull > any number === false
.<=
Template:Int>=
— Return true if the left-hand operand is less than or equal to/greater than or equal to the right-hand operand respectively. Watch out: operands are casted to strings and, like it happens in PHP,null <= any number === true
andnull >= any number === false
.==
(or=
),!=
— Return true if the left-hand operand is equal to/not equal to the right-hand operand respectively.===
Template:Int!==
— Return true if the left-hand operand is equal to/not equal to the right-hand operand AND the left-hand operand is the same/not the same data type to the right-hand operand respectively.
Example | Result |
---|---|
1 == 2 |
false |
1 <= 2 |
true |
1 >= 2 |
false |
1 != 2 |
true |
1 < 2 |
true |
1 > 2 |
false |
2 = 2
|
true |
'' == false
|
true |
'' === false |
false |
1 == true
|
true |
1 === true
|
false |
['1','2','3'] == ['1','2','3']
|
true |
[1,2,3] === [1,2,3]
|
true |
['1','2','3'] == [1,2,3]
|
true |
['1','2','3'] === [1,2,3]
|
false |
[1,1,''] == [true, true, false]
|
true |
[] == false & [] == null
|
true |
['1'] == '1'
|
false[1] |
Built-in variables
The abuse filter passes various variables by name into the parser. These variables can be accessed by typing their name in, in a place where a literal would work. You can view the variables associated with each request in the abuse log.
Variables from AbuseFilter
Description | Name | Data type | Notes |
---|---|---|---|
Action | action |
string | One of the following: edit, move, createaccount, autocreateaccount, delete, upload[2], stashupload[3] |
Template:Int | user_editcount |
integer/null | Null only for unregistered users. |
Template:Int | user_name |
string | this is empty for "createaccount" action, use accountname instead.:
|
Template:Int | user_emailconfirm |
string | In the format: YYYYMMDDHHMMSS. Null if the email wasn't confirmed. |
Template:Int | user_age |
integer | In seconds. 0 for unregistered users. |
Template:Int | user_blocked |
boolean | true for blocked registered users, false for unregistered users. This doesn't differentiate between partial and total blocks.: |
Template:Int | user_groups |
array of strings | see Special:ListGroupRights |
Template:Int | user_rights |
array of strings | see Special:ListGroupRights |
Template:Int | article_articleid |
integer | Template:Deprecated-inline Use page_id instead.
|
Template:Ll (found in the page's HTML source - search for wgArticleId) | page_id |
integer | In theory this is 0 for new pages, but this is unreliable. Instead, use "page_age == 0" to identify new page creation. |
Template:Int | article_namespace |
integer | Template:Deprecated-inline Use page_namespace instead.
|
Template:Int | page_namespace |
integer | refers to Template:Ll |
Template:Int | page_age |
integer | the number of seconds since the first edit (or 0 for new pages) |
Template:Int | article_text |
string | Template:Deprecated-inline Use page_title instead.
|
Template:Int | page_title |
string | |
Template:Int | article_prefixedtext |
string | Template:Deprecated-inline Use page_prefixedtitle instead.
|
Template:Int | page_prefixedtitle |
string | |
Template:Int | article_restrictions_edit |
string | Template:Deprecated-inline Use page_restrictions_edit instead.
|
Template:Int | page_restrictions_edit |
array of strings | |
Template:Int | article_restrictions_move |
string | Template:Deprecated-inline Use page_restrictions_move instead.
|
Template:Int | page_restrictions_move |
array of strings | |
Template:Int | article_restrictions_upload |
string | Template:Deprecated-inline Use page_restrictions_upload instead.
|
Template:Int | page_restrictions_upload |
array of strings | |
Template:Int | article_restrictions_create |
string | Template:Deprecated-inline Use page_restrictions_create instead.
|
Template:Int | page_restrictions_create |
array of strings | |
Template:Int | article_recent_contributors |
array of strings | Template:Deprecated-inline Use page_recent_contributors instead.
|
Template:Int | page_recent_contributors |
array of strings | This tends to be slow (see #Performance). Try to put conditions more likely evaluate to false before this one, to avoid unnecessarily running the query. This value is empty if the user is the only contributor to the page(?), and only scans the last 100 revisions |
Template:Int | article_first_contributor |
string | Template:Deprecated-inline Use page_first_contributor instead.
|
Template:Int | page_first_contributor |
string | This tends to be slow (see #Performance).[4] Try to put conditions more likely evaluate to false before this one, to avoid unnecessarily running the query. |
Description | Name | Data type | Notes |
---|---|---|---|
Template:Int | summary |
string | Summaries automatically created by MediaWiki ("New section", "Blanked the page", etc.) are created after the filter checks the edit, so they will never actually catch, even if the debugger shows that they should.[5] |
minor_edit |
Disabled, and set to false for all entries between 2016 and 2018.[6] | ||
Template:Int | old_wikitext |
string | This variable can be very large. Consider using removed_lines if possible to improve performance.
|
Template:Int | new_wikitext |
string | This variable can be very large. Consider using added_lines if possible to improve performance.
|
Template:Int | edit_diff |
string | |
Template:Int | edit_diff_pst |
string | This tends to be slow (see #Performance). Checking both added_lines and removed_lines is probably more efficient.[7]
|
Template:Int | new_size |
integer | |
Template:Int | old_size |
integer | |
Template:Int | edit_delta |
integer | Template:Tip |
Template:Int | added_lines_pst |
array of strings | Use added_lines if possible, which is more efficient.
|
Template:Int | added_lines |
array of strings | includes all lines in the final diff that begin with + |
Template:Int | removed_lines |
array of strings | |
Template:Int | all_links |
array of strings | |
Template:Int | old_links |
array of strings | |
Template:Int | added_links |
array of strings | This tends to be slow (see #Performance). Consider checking against added_lines first, then check added_links so that fewer edits are slowed down. This follows Template:Ll. Only unique links are added to the array. Changing a link will count as 1 added and 1 removed link.
|
Template:Int | removed_links |
array of strings | This tends to be slow (see #Performance). Consider checking against removed_lines first, then check removed_links so that fewer edits are slowed down. This follows Template:Ll. Only unique links are added to the array. Changing a link will count as 1 added and 1 removed link.
|
Template:Int | new_pst |
string | |
Template:Int | new_html |
string | This variable can be very large. Consider using added_lines if possible to improve performance.
|
Template:Int | new_text |
string | This variable can be very large. Consider using added_lines if possible to improve performance.
|
old_html |
Disabled for performance reasons. | ||
old_text |
Disabled for performance reasons. | ||
Unix timestamp of change | timestamp |
string | int(timestamp) gives you a number with which you can calculate the date, time, day of week, etc. |
Template:Int | file_sha1 |
string | [2] |
Template:Int | file_size |
integer | The file size in bytes[2] |
Template:Int | file_width |
integer | The width in pixels[2] |
Template:Int | file_height |
integer | The height in pixels[2] |
Template:Int | file_bits_per_channel |
integer | The amount of bits per color channel[2] |
Template:Int | moved_to_articleid |
integer | Template:Deprecated-inline Use moved_to_id instead.
|
Template:Int | moved_to_id |
integer | |
Template:Int | moved_to_text |
string | Template:Deprecated-inline Use moved_to_title instead.
|
Template:Int | moved_to_title |
string | |
Template:Int | moved_to_prefixedtext |
string | Template:Deprecated-inline Use moved_to_prefixedtitle instead.
|
Template:Int | moved_to_prefixedtitle |
string | |
Template:Int | moved_to_namespace |
string | |
Template:Int | moved_to_age |
integer | |
Template:Int | moved_from_namespace |
string | |
Template:Int | moved_from_text |
string | Template:Deprecated-inline Use moved_from_title instead.
|
Template:Int | moved_from_title |
string | |
Template:Int | moved_from_prefixedtext |
string | Template:Deprecated-inline Use moved_from_prefixedtitle instead.
|
Template:Int | moved_from_prefixedtitle |
string | |
Template:Int | moved_from_articleid |
integer | Template:Deprecated-inline Use moved_from_id instead.
|
Template:Int | moved_from_id |
integer | |
Template:Int | moved_from_age |
integer | |
Template:Int | accountname |
string | |
Content model of the old revision | old_content_model
|
string | See Template:Ll for information about content model changes |
Content model of the new revision | new_content_model
|
string | See Template:Ll for information about content model changes |
Variables from other extensions
Description | Name | Data type | Values | Added by |
---|---|---|---|---|
Template:Int | global_user_groups
|
array | Template:Ll | |
Template:Int | board_articleid
|
integer | Template:Deprecated-inline Use board_id instead.
|
Template:Ll |
Template:Int | board_id
|
integer | Template:Ll | |
Template:Int | board_namespace
|
integer | refers to Template:Ll | Template:Ll |
Template:Int | board_text
|
string | Template:Deprecated-inline Use board_title instead.
|
Template:Ll |
Template:Int | board_title
|
string | Template:Ll | |
Template:Int | board_prefixedtext
|
string | Template:Deprecated-inline Use board_prefixedtitle instead.
|
Template:Ll |
Template:Int | board_prefixedtitle
|
string | Template:Ll | |
Template:Int | translate_source_text
|
string | Template:Ll | |
Template:Int | tor_exit_node
|
boolean | true if the action comes from a tor exit node. | Template:Ll |
Template:Int | user_mobile
|
boolean | true for mobile users, false otherwise. | Template:Ll |
Template:Int | user_app
|
boolean | true if the user is editing from the mobile app, false otherwise. | Template:Ll |
Template:Int | user_wpzero
|
boolean | This variable is only valid when filtering an action. When examining a past edit or batch testing, it'll always be null.: | Template:Ll |
Template:Int | article_views
|
integer | Template:Deprecated-inline Use page_views instead.
|
Template:Ll |
Template:Int | page_views
|
integer | the amount of page views | Template:Ll |
Template:Int | moved_from_views
|
integer | the amount of page views of the source page | Template:Ll |
Template:Int | moved_to_views
|
integer | the amount of page views of the target page | Template:Ll |
Template:Int | is_proxy
|
integer | Whether this action was performed through a proxy | Template:Ll |
Template:Int | sfs_blocked
|
boolean | Whether the IP address is blocked using the stopforumspam.com list | Template:Ll |
Notes
When action='move'
, only the summary
, action
, timestamp
and user_*
variables are available.
The page_*
variables are also available, but the prefix is replaced by moved_from_
and moved_to_
, that represent the values of the original article name and the destination one, respectively.
For example, moved_from_title
and moved_to_title
instead of page_title
.
Since MediaWiki 1.28 (https://gerrit.wikimedia.org/r/#/c/295254/), action='upload'
is only used when publishing an upload, and not for uploads to stash.
A new action='stashupload'
is introduced, which is used for all uploads, including uploads to stash.
This behaves like action='upload'
used to, and only provides file metadata variables (file_*
).
Variables related to the page edit, including summary
, new_wikitext
and several others, are now available for action='upload'
.
For every file upload, filters may be called with action='stashupload'
(for uploads to stash), and are always called with action='upload'
; they are not called with action='edit'
.
Filter authors should use action='stashupload' | action='upload'
in filter code when a file can be checked based only on the file contents – for example, to reject low-resolution files – and action='upload'
only when the wikitext parts of the edit need to be examined too – for example, to reject files with no description.
This will allow tools that separate uploading the file and publishing the file (e.g. UploadWizard or upload dialog) to inform the user of the failure before they spend the time filling in the upload details.
Performance
As noted in the table above, some of these variables can be very slow.
While writing filters, remember that the condition limit is not a good metric of how heavy filters are.
For instance, variables like *_recent_contributors
or *_links
always need a DB query to be computed, while *_pst
variables will have to perform parsing of the text, which again is a heavy operation; all these variables should be used very, very carefully.
For instance, on Italian Wikipedia it's been observed that, with 135 active filters and an average of 450 used conditions, filters execution time was around 500ms, with peaks reaching 15 seconds.
Removing the added_links
variable from a single filter, and halving the cases when another filter would use added_lines_pst
brought the average execution time to 50ms.
More specifically:
- Use
_links
variables when you need high accuracy and checking for "http://..." in other variables (for instance,added_lines
) could lead to heavy malfunctioning; - Use
_pst
variables when you're really sure that non-PST variables aren't enough. You may also conditionally decide which one to check: if, for instance, you want to examine a signature, check first ifadded_lines
contains~~~
; - In general, when dealing with these variables, it's always much better to consume further conditions but avoid computing heavy stuff. In order to achieve this, always put heavy variables as last conditions.
Last but not least, note that whenever a variable is computed for a given filter, it'll be saved and any other filter will immediately retrieve it. This means that one single filter computing this variable counts more or less as dozens of filters using it.
Keywords
Where not specifically stated, keywords cast their operands to strings: The following special keywords are included for often-used functionality:
like
(ormatches
) returns true if the left-hand operand matches the glob pattern in the right-hand operand.in
returns true if the right-hand operand (a string) contains the left-hand operand. Note: empty strings are not contained in, nor contain, any other string (not even the empty string itself).contains
works likein
, but with the left and right-hand operands switched. Note: empty strings are not contained in, nor contain, any other string (not even the empty string itself).rlike
(orregex
) andirlike
return true if the left-hand operand matches (contains) the regex pattern in the right-hand operand (irlike
is case insensitive).
The system uses PCRE.
The only PCRE option enabled is PCRE_UTF8
(modifier u
in PHP); for irlike
both PCRE_CASELESS
and PCRE_UTF8
are enabled (modifier iu
).
if ... then ... else ... end
... ? ... : ...
true
,false
,null
Examples
Code | Result | Comment |
---|---|---|
"1234" like "12?4"
|
True | |
"1234" like "12*"
|
True | |
"foo" in "foobar"
|
True | |
"foobar" contains "foo"
|
True | |
"o" in ["foo", "bar"]
|
True | Due to the string cast |
"foo" regex "\w+"
|
True | |
"a\b" regex "a\\\\b"
|
True | To look for the escape character backslash using regex you need to use either four backslashes or two \x5C . (Either works fine.)
|
"a\b" regex "a\x5C\x5Cb"
|
True |
Functions
A number of built-in functions are included to ease some common issues.
They are executed in the general format functionName( arg1, arg2, arg3 )
, and can be used in place of any literal or variable.
Its arguments can be given as literals, variables, or even other functions.
name | description |
---|---|
lcase |
Returns the argument converted to lower case. |
ucase |
Returns the argument converted to upper case. |
length |
Returns the length of the string given as the argument. If the argument is an array, returns its number of elements. |
string |
Casts to string data type. If the argument is an array, implodes it with linebreaks. |
int |
Casts to integer data type. |
float |
Casts to floating-point data type. |
bool |
Casts to boolean data type. |
norm |
Equivalent to rmwhitespace(rmspecials(rmdoubles(ccnorm(arg1)))) .
|
ccnorm |
Normalises confusable/similar characters in the argument, and returns a canonical form. A list of characters and their replacements can be found on git, e.g. ccnorm( "Eeèéëēĕėęě3ƐƷ" ) === "EEEEEEEEEEEEE" .[8] The output of this function is always uppercase.
|
ccnorm_contains_any |
Normalises confusable/similar characters in the arguments, and returns true if the first string contains any strings from the following arguments (unlimited number of arguments, logic OR mode). A list of characters and their replacements can be found on git. |
ccnorm_contains_all |
Normalises confusable/similar characters in the arguments, and returns true if the first string contains every strings from the following arguments (unlimited number of arguments, logic AND mode). A list of characters and their replacements can be found on git. |
specialratio |
Returns the number of non-alphanumeric characters divided by the total number of characters in the argument. |
rmspecials |
Removes any special characters in the argument, and returns the result. (Equivalent to s/[^\p{L}\p{N}]//g.) |
rmdoubles |
Removes repeated characters in the argument, and returns the result. |
rmwhitespace |
Removes whitespace (spaces, tabs, newlines). |
count |
Returns the number of times the needle (first string) appears in the haystack (second string). If only one argument is given, splits it by commas and returns the number of segments. |
rcount |
Similar to count but the needle uses a regular expression instead. Can be made case-insensitive by letting the regular expression start with "(?i)".
|
get_matches |
Template:MW version-inline Looks for matches of the regex needle (first string) in the haystack (second string). Returns an array where the 0 element is the whole match and every [n] element is the match of the n'th capturing group of the needle. Can be made case-insensitive by letting the regular expression start with "(?i)". If a capturing group didn't match, that array position will take value of false.
|
ip_in_range |
Returns true if user's IP (first string) matches specified IP ranges (second string). Only works for anonymous users. Supports both IPv4 and IPv6 addresses. |
contains_any |
Returns true if the first string contains any strings from the following arguments (unlimited number of arguments in logic OR mode). If the first argument is an array, it gets casted to string. |
contains_all |
Returns true if the first string contains every strings from the following arguments (unlimited number of arguments in logic AND mode). If the first argument is an array, it gets casted to string. |
equals_to_any |
Returns true if the first argument is identical (=== ) to any of the following ones (unlimited number of arguments). Basically, equals_to_any(a, b, c) is the same as a===b | a===c , but more compact and saves conditions.
|
substr |
Returns the portion of the first string, by offset from the second argument (starts at 0) and maximum length from the third argument (optional). |
strlen |
Same as length .
|
strpos |
Returns the numeric position of the first occurrence of needle (second string) in the haystack (first string), starting from offset from the third argument (optional, default is 0). This function may return 0 when the needle is found at the begining of the haystack, so it might be misinterpreted as false value by another comparative operator. The better way is to use === or !== for testing whether it is found.
|
str_replace |
Replaces all occurrences of the search string with the replacement string. The function takes 3 arguments in the following order: text to perform the search on, text to find, replacement text. |
rescape |
Returns the argument with some characters preceded with the escape character "\", so that the string can be used in a regular expression without those characters having a special meaning. |
set |
Sets a variable (first string) with a given value (second argument) for further use in the filter. Another syntax: name := value .
|
set_var |
Same as set .
|
Examples
Code | Result | Comment |
---|---|---|
length( "Wikipedia" )
|
9 | |
lcase( "WikiPedia" )
|
wikipedia | |
ccnorm( "w1k1p3d14" )
|
WIKIPEDIA | ccnorm output is always uppercase
|
ccnorm( "ωɨƙɩᑭƐƉ1α" )
|
WIKIPEDIA | |
ccnorm_contains_any( "w1k1p3d14", "wiKiP3D1A", "foo", "bar" )
|
true | |
ccnorm_contains_any( "w1k1p3d14", "foo", "bar", "baz" )
|
false | |
ccnorm_contains_any( "w1k1p3d14 is 4w3s0me", "bar", "baz", "some" )
|
true | |
ccnorm( "ìíîïĩїį!ľ₤ĺľḷĿ" )
|
IIIIIII!LLLLLL | |
norm( "!!ω..ɨ..ƙ..ɩ..ᑭᑭ..Ɛ.Ɖ@@1%%α!!" )
|
WIKIPEDAIA | |
norm( "F00 B@rr" )
|
FOBAR | norm removes whitespace, special characters and duplicates, then uses ccnorm
|
rmdoubles( "foobybboo" )
|
fobybo | |
specialratio( "Wikipedia!" )
|
0.1 | |
count( "foo", "foofooboofoo" )
|
3 | |
count( "foo,bar,baz" )
|
3 | |
rmspecials( "FOOBAR!!1" )
|
FOOBAR1 | |
rescape( "abc* (def)" )
|
abc\* \(def\) | |
str_replace( "foobarbaz", "bar", "-" )
|
foo-baz | |
ip_in_range( "127.0.10.0", "127.0.0.0/12" )
|
true | |
contains_any( "foobar", "x", "y", "f" )
|
true | |
get_matches( "(foo?ba+r) is (so+ good)", "fobaaar is soooo good to eat" )
|
['fobaaar is soooo good', 'fobaaar', 'soooo good'] |
Order of operations
Operations are generally done left-to-right, but there is an order to which they are resolved. As soon as the filter fails one of the conditions, it will stop checking the rest of them (due to short-circuit evaluation) and move on to the next filter (except for phab:T43693). The evaluation order is:
- Anything surrounded by parentheses (
(
and)
) is evaluated as a single unit. - Turning variables/literals into their respective data. (i.e.,
page_namespace
to 0) - Function calls (
norm
,lcase
, etc.) - Unary
+
and-
(defining positive or negative value, e.g.-1234
,+1234
) - Keywords
- Boolean inversion (
!x
) - Exponentiation (
2**3 → 8
) - Multiplication-related (multiplication, division, modulo)
- Addition and subtraction (
3-2 → 1
) - Comparisons. (
<
,>
,==
) - Boolean operations. (
&
,|
,^
)
Examples
A & B | C
is equivalent to(A & B) | C
, not toA & (B | C)
. In particular, bothfalse & true | true
andfalse & false | true
evaluates totrue
.A | B & C
is equivalent to(A | B) & C
, not toA | (B & C)
. In particular, bothtrue | true & false
andtrue | false & false
evaluates tofalse
.
Condition counting
The condition limit is (more or less) tracking the number of comparison operators + number of function calls entered.
Further explanation on how to reduce conditions used can be found at Template:Ll.
Exclusions
Although the AbuseFilter examine function will identify "rollback" actions as edits, the AbuseFilter will not evaluate rollback actions for matching. [9]
Useful links
Notes
- ↑ Comparing arrays to other types will always return false, except for the example above
- ↑ 2.0 2.1 2.2 2.3 2.4 2.5 The only variables currently available for file uploads (action='upload') are user_*, page_*, file_sha1, file_size, file_mime, file_mediatype, file_width, file_height, file_bits_per_channel (the last five were only added since the release for MediaWiki 1.27, gerrit:281503). All the file_* variables are unavailable for other actions (including action='edit').
- ↑ Since MediaWiki 1.28 (https://gerrit.wikimedia.org/r/#/c/295254/)
- ↑ Several filters (12) that use this variable have showed up in the AbuseFilterSlow Grafana dashboard (requires logstash access to view). Moving this variable to towards the end of the filter seemed to help.
- ↑ See phabricator:T191722
- ↑ Deprecated with this commit and disabled with this one.
- ↑ Some filters using this variable have showed up in the AbuseFilterSlow Grafana dashboard (example, requires logstash access). For instance, instead of using
"text" in edit_diff_pst
(or evenedit_diff
), consider something like"text" in added_lines & !("text" in removed_lines)
- ↑ Be aware of phab:T27619. You can use Special:AbuseFilter/tools to evaluate
ccnorm( "your string" )
to see which characters are transformed. - ↑ T24713 - rollback not matched by AF