User:松/Drafts/Extension:AbuseFilter/Rules format: Difference between revisions

 
(12 intermediate revisions by the same user not shown)
Line 230:
! Notes
|-
| Action || <code>action</code> || string || One of the following:edit, move, createaccount, autocreateaccount, delete, upload<ref name="upload"> 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 [[mw:gerrit:281503|gerrit:281503]]).All the file_* variables are unavailable for other actions (including action='edit').</ref>, stashupload<ref>Since MediaWiki 1.28 ([[mw:gerrit:295254|gerrit:295254]])</ref>
|-
| Unix timestamp of change || <code>timestamp</code> || string || int(timestamp) gives you a number with which you can calculate the date, time, day of week, etc.
Line 306:
| {{int|abusefilter-edit-builder-vars-summary}} || <code>summary</code> || 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.<ref>See [[phabricator:T191722]]</ref>
|-
| <s>{{int|abusefilter-edit-builder-vars-minor-edit}}</s> || <s><code>minor_edit</code></s> || <s>string</s> || Disabled, and set to false for all entries between 2016 and 2018.<ref>Deprecated with [[mw:gerrit:296268|this commit]] and disabled with [[mw:gerrit:481544|this one]].</ref>
|-
| {{int|abusefilter-edit-builder-vars-old-wikitext}} || <code>old_wikitext</code> || string || This variable can be very large.Consider using <code>removed_lines</code> if possible to improve performance.
Line 346:
| <s>{{int|abusefilter-edit-builder-vars-old-text}}</s> || <s><code>old_text</code></s> || <s>string</s> || Disabled for performance reasons.
|-
| {{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><!--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><!--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><!--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><!--T:193--> integer</translate> || <translate><!--T:194--> The amount of bits per color channel</translate><ref name=upload/>
|-
| {{int|abusefilter-edit-builder-vars-file-mime}} || <code>file_mime</code> || <translate><!--T:417--> string</translate> || <translate><!--T:418--> The file [[w:MIME|MIME]] type.</translate><ref name=upload/>
|-
| {{int|abusefilter-edit-builder-vars-file-mediatype}} || <code>file_mediatype</code> || <translate><!--T:419--> string</translate> || <translate><!--T:420--> The file media type.</translate><ref><translate><!--T:461--> See [<tvar|1>https://gerrit.wikimedia.org/g/mediawiki/core/+/d887b9ff37a4956f6db15ddeea68e6d933e108c7/includes/libs/mime/defines.php</> the source code] for a list of types.</translate></ref><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><!--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><!--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><!--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><!--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><!--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><!--T:203--> string</translate> ||
|-
| {{int|abusefilter-edit-builder-vars-movedto-ns}} || <code>moved_to_namespace</code> || <translate><!--T:421--> integer</translate> ||
|-
| {{int|abusefilter-edit-builder-vars-movedto-age}} || <code>moved_to_age</code> || <translate><!--T:205--> integer</translate> ||
|-
| {{int|abusefilter-edit-builder-vars-movedto-restrictions-edit}} || <code>moved_to_restrictions_edit</code> || <translate><!--T:422--> array of string</translate> || <translate><!--T:448--> Same as <tvar|1><code>page_restrictions_edit</code></>, but for the target of the move.</translate>
|-
| {{int|abusefilter-edit-builder-vars-movedto-restrictions-move}} || <code>moved_to_restrictions_move</code> || <translate><!--T:423--> array of string</translate> || <translate><!--T:449--> Same as <tvar|1><code>page_restrictions_move</code></>, but for the target of the move.</translate>
|-
| {{int|abusefilter-edit-builder-vars-movedto-restrictions-upload}} || <code>moved_to_restrictions_upload</code> || <translate><!--T:424--> array of string</translate> || <translate><!--T:450--> Same as <tvar|1><code>page_restrictions_upload</code></>, but for the target of the move.</translate>
|-
| {{int|abusefilter-edit-builder-vars-movedto-restrictions-create}} || <code>moved_to_restrictions_create</code> || <translate><!--T:425--> array of string</translate> || <translate><!--T:451--> Same as <tvar|1><code>page_restrictions_create</code></>, but for the target of the move.</translate>
|-
| {{int|abusefilter-edit-builder-vars-movedto-recent-contributors}} || <code>moved_to_recent_contributors</code> || <translate><!--T:426--> array of strings</translate> || <translate><!--T:452--> Same as <tvar|1><code>page_recent_contributors</code></>, but for the target of the move.</translate>
|-
| {{int|abusefilter-edit-builder-vars-movedto-first-contributor}} || <code>moved_to_first_contributor</code> || <translate><!--T:427--> string</translate> || <translate><!--T:453--> Same as <tvar|1><code>page_first_contributor</code></>, but for the target of the move.</translate>
|-
| {{int|abusefilter-edit-builder-vars-movedfrom-ns}} || <code>moved_from_namespace</code> || <translate><!--T:428--> integer</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><!--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><!--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><!--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><!--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><!--T:215--> integer</translate> ||
|-
| {{int|abusefilter-edit-builder-vars-movedfrom-age}} || <code>moved_from_age</code> || <translate><!--T:216--> integer</translate> ||
|-
| {{int|abusefilter-edit-builder-vars-movedfrom-restrictions-edit}} || <code>moved_from_restrictions_edit</code> || <translate><!--T:429--> array of string</translate> || <translate><!--T:454--> Same as <tvar|1><code>page_restrictions_edit</code></>, but for the page being moved.</translate>
|-
| {{int|abusefilter-edit-builder-vars-movedfrom-restrictions-move}} || <code>moved_from_restrictions_move</code> || <translate><!--T:430--> array of string</translate> || <translate><!--T:455--> Same as <tvar|1><code>page_restrictions_move</code></>, but for the page being moved.</translate>
|-
| {{int|abusefilter-edit-builder-vars-movedfrom-restrictions-upload}} || <code>moved_from_restrictions_upload</code> || <translate><!--T:431--> array of string</translate> || <translate><!--T:456--> Same as <tvar|1><code>page_restrictions_upload</code></>, but for the page being moved.</translate>
|-
| {{int|abusefilter-edit-builder-vars-movedfrom-restrictions-create}} || <code>moved_from_restrictions_create</code> || <translate><!--T:432--> array of string</translate> || <translate><!--T:457--> Same as <tvar|1><code>page_restrictions_create</code></>, but for the page being moved.</translate>
|-
| {{int|abusefilter-edit-builder-vars-movedfrom-recent-contributors}} || <code>moved_from_recent_contributors</code> || <translate><!--T:433--> array of strings</translate> || <translate><!--T:458--> Same as <tvar|1><code>page_recent_contributors</code></>, but for the page being moved.</translate>
|-
| {{int|abusefilter-edit-builder-vars-movedfrom-first-contributor}} || <code>moved_from_first_contributor</code> || <translate><!--T:434--> string</translate> || <translate><!--T:459--> Same as <tvar|1><code>page_first_contributor</code></>, but for the page being moved.</translate>
|-
| {{int|abusefilter-edit-builder-vars-accountname}} || <code>accountname</code> || <translate><!--T:217--> string</translate> ||
|-
|<translate><!--T:218--> Content model of the old revision</translate>
|<code>old_content_model</code>
| string
|<translate><!--T:219--> string</translate>
|<translate><!--T:220--> See <tvar|1>{{ll|Help:ChangeContentModel}}</> for information about content model changes</translate>
|-
|<translate><!--T:221--> Content model of the new revision</translate>
|<code>new_content_model</code>
| string
|<translate><!--T:222--> string</translate>
|<translate><!--T:223--> See <tvar|1>{{ll|Help:ChangeContentModel}}</> for information about content model changes</translate>
|-
|}
Line 432:
===Variables from other extensions===
 
{{Note|1=<translate><!--T:470--> Most of these variables are always set to false when examinating past edits, and may not reflect their actual value at the time the edit was made.</translate> <translate><!--T:471--> See <tvar|1>[[:phab:T102944|T102944]]</>.</translate>|2=warn}}
 
{| class="wikitable sortable"
|+
! <translate><!--T:225--> Description</translate>
! Name
! <translate><!--T:226--> Name</translate>
! <translate><!--T:227--> Data type</translate>
! Values
! <translate><!--T:228--> Values</translate>
! <translate><!--T:229--> Added by</translate>
|-
| {{int|abusefilter-edit-builder-vars-global-user-groups}}
|<code>global_user_groups</code>
| array
|<translate><!--T:230--> array</translate>
|
|{{ll|Extension:CentralAuth|nsp=0}}
Line 450:
| <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"><translate><!--T:231--> integer</translate></span>
| {{deprecated-inline}} <translate><!--T:232--> Use <tvar|1><code>board_id</code></> instead.</translate>
|{{ll|Extension:StructuredDiscussions|nsp=0}}
|-
|{{int|abusefilter-edit-builder-vars-board-id}}
|<code>board_id</code>
|<translate><!--T:233--> integer</translate>
|
|{{ll|Extension:StructuredDiscussions|nsp=0}}
Line 462:
|{{int|abusefilter-edit-builder-vars-board-namespace}}
|<code>board_namespace</code>
|<translate><!--T:234--> integer</translate>
|<translate><!--T:235--> refers to {{<tvar|1>ll|Manual:Namespace#Built-in_namespaces</>|namespace index}}</translate>
|{{ll|Extension:StructuredDiscussions|nsp=0}}
|-
| <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"><translate><!--T:236--> string</translate></span>
| {{deprecated-inline}} <translate><!--T:237--> Use <tvar|1><code>board_title</code></> instead.</translate>
|{{ll|Extension:StructuredDiscussions|nsp=0}}
|-
|{{int|abusefilter-edit-builder-vars-board-title}}
|<code>board_title</code>
| string
|<translate><!--T:238--> string</translate>
|
|{{ll|Extension:StructuredDiscussions|nsp=0}}
Line 480:
| <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"><translate><!--T:239--> string</translate></span>
| {{deprecated-inline}} <translate><!--T:240--> Use <tvar|1><code>board_prefixedtitle</code></> instead.</translate>
|{{ll|Extension:StructuredDiscussions|nsp=0}}
|-
|{{int|abusefilter-edit-builder-vars-board-prefixedtitle}}
|<code>board_prefixedtitle</code>
| string
|<translate><!--T:241--> string</translate>
|
|{{ll|Extension:StructuredDiscussions|nsp=0}}
Line 492:
| {{int|abusefilter-edit-builder-vars-translate-source-text}}
|<code>translate_source_text</code>
| string
|<translate><!--T:242--> string</translate>
|
|{{ll|Extension:Translate|nsp=0}}
Line 498:
| {{int|abusefilter-edit-builder-vars-translate-target-language}}
|<code>translate_target_language</code>
| string
| <translate><!--T:462--> string</translate>
| <translate><!--T:463--> This is the language code, like <tvar|1><code>en</code></> for English.</translate>
|{{ll|Extension:Translate|nsp=0}}
|-
| {{int|abusefilter-edit-builder-vars-tor-exit-node}}
|<code>tor_exit_node</code>
| boolean
| <translate><!--T:243--> boolean</translate>
| <translate><!--T:244--> true if the action comes from a tor exit node.</translate>
|{{ll|Extension:TorBlock|nsp=0}}
|-
|{{int|abusefilter-edit-builder-vars-user-mobile}}
| <code>user_mobile</code>
| <translate><!--T:245--> boolean</translate>
| <translate><!--T:246--> true for mobile users, false otherwise.</translate>
|{{ll|Extension:MobileFrontend|nsp=0}}
|-
|{{int|abusefilter-edit-builder-vars-user-app}}
| <code>user_app</code>
| boolean
| <translate><!--T:247--> boolean</translate>
| <translate><!--T:248--> true if the user is editing from the mobile app, false otherwise.</translate>
|{{ll|Extension:MobileApp|nsp=0}}
|-
| <span style="opacity:0.5"><translate><!--T:464--> Page views</translate>[https://translatewiki.net/wiki/Special:PrefixIndex?prefix=MediaWiki:abusefilter-edit-builder-vars-page-views/&namespace=0]</span>
| <span style="opacity:0.5"><code>article_views</code></span>
| <span style="opacity:0.5"><translate><!--T:252--> integer</translate></span>
| {{deprecated-inline}} <translate><!--T:253--> Use <tvar|1><code>page_views</code></> instead.</translate>
|{{ll|Extension:HitCounters|nsp=0}}
|-
|<translate><!--T:465--> Page views</translate>[https://translatewiki.net/wiki/Special:PrefixIndex?prefix=MediaWiki:abusefilter-edit-builder-vars-page-views/&namespace=0]
| <code>page_views</code>
| integer
| <translate><!--T:254--> integer</translate>
| <translate><!--T:255--> the amount of page views</translate>
|{{ll|Extension:HitCounters|nsp=0}}
|-
|<translate><!--T:466--> Source page views</translate>[https://translatewiki.net/wiki/Special:PrefixIndex?prefix=MediaWiki:abusefilter-edit-builder-vars-movedfrom-views/&namespace=0]
| <code>moved_from_views</code>
| integer
| <translate><!--T:256--> integer</translate>
| <translate><!--T:257--> the amount of page views of the source page</translate>
|{{ll|Extension:HitCounters|nsp=0}}
|-
|<translate><!--T:467--> Target page views</translate>[https://translatewiki.net/wiki/Special:PrefixIndex?prefix=MediaWiki:abusefilter-edit-builder-vars-movedto-views/&namespace=0]
| <code>moved_to_views</code>
| integer
| <translate><!--T:258--> integer</translate>
| <translate><!--T:259--> the amount of page views of the target page</translate>
|{{ll|Extension:HitCounters|nsp=0}}
|-
| <translate><!--T:468--> True if this action was performed through a proxy</translate>[https://translatewiki.net/wiki/Special:PrefixIndex?prefix=MediaWiki:abusefilter-edit-builder-vars-is-proxy/&namespace=0]
| <code>is_proxy</code>
| integer
| <translate><!--T:260--> integer</translate>
| <translate><!--T:261--> Whether this action was performed through a proxy</translate>
| {{ll|Extension:AutoProxyBlock|nsp=0}}
|-
|<translate><!--T:469--> Whether the IP address is blocked using the stopforumspam.com list</translate>[https://translatewiki.net/wiki/Special:PrefixIndex?prefix=MediaWiki:abusefilter-edit-builder-vars-sfs-blocked/&namespace=0]
| <code>sfs_blocked</code>
| boolean
| <translate><!--T:262--> boolean</translate>
| <translate><!--T:263--> Whether the IP address is blocked using the <tvar|1>stopforumspam.com</> list</translate>
| {{ll|Extension:StopForumSpam|nsp=0}}
|}
Line 559:
=== Notes ===
 
When <code>action='move'</code>,only the <code>summary</code>,<code>action</code>,<code>timestamp</code> and <code>user_*</code> variables are available.The <code>page_*</code> variables are also available, but the prefix is replaced by <code>moved_from_</code> and <code>moved_to_</code>, that represent the values of the original article name and the destination one, respectively.For example, <code>moved_from_title</code> and <code>moved_to_title</code> instead of <code>page_title</code>.
<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>
<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></>.
 
Since MediaWiki 1.28 ([[mw:gerrit:295254|gerrit:295254]]), <code>action='upload'</code> is only used when publishing an upload, and not for uploads to stash.A new <code>action='stashupload'</code> is introduced, which is used for all uploads, including uploads to stash.This behaves like <code>action='upload'</code> used to, and only provides file metadata variables (<code>file_*</code>).Variables related to the page edit, including <code>summary</code>, <code>new_wikitext</code> and several others, are now available for <code>action='upload'</code>.For every file upload, filters may be called with <code>action='stashupload'</code> (for uploads to stash), and are always called with <code>action='upload'</code>; they are not called with <code>action='edit'</code>.
<!--T:268-->
Since MediaWiki 1.28 (<tvar|1>[[gerrit:295254]]</>), <tvar|2><code>action='upload'</code></> is only used when publishing an upload, and not for uploads to stash.</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>
<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>
<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>
<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></>.
 
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>This will allow tools that separate uploading the file and publishing the file (e.g. [[mw:UploadWizard|UploadWizard]] or [[mw:upload dialog|upload dialog]]) to inform the user of the failure before they spend the time filling in the upload details.
<!--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>
<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.
</translate>
 
{{anchor|Performance}}
Line 593 ⟶ 569:
=== 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 <code>*_recent_contributors</code> or <code>*_links</code> always need a DB query to be computed, while <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.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 <code>added_links</code> variable from a single filter, and halving the cases when another filter would use <code>added_lines_pst</code> brought the average execution time to 50ms.More specifically:
<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>
<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>
<translate>
<!--T:281-->
More specifically:
 
*Use <code>_links</code> variables when you need high accuracy and checking for "http://..." in other variables (for instance, <code>added_lines</code>) could lead to heavy malfunctioning;
<!--T:282-->
* Use <tvar|1><code>_links_pst</code></> variables when you're needreally highsure accuracythat andnon-PST checkingvariables foraren't "<tvar|2>http://..enough.</>"You inmay otheralso variablesconditionally decide which one to check: if, (for instance, <tvar|3>you want to examine a signature, check first if <code>added_lines</code> contains <code><nowiki>~~~</nowiki>) could lead to heavy malfunctioning;</translatecode>;
<translate>
<!--T:283-->
* 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>
*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.
 
Line 713 ⟶ 677:
| <code>get_matches</code> || {{MW version-inline|MW 1.31+}} 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 <code>[n]</code> 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''.
|-
| <code>ip_in_range</code> || Returns true if user's IP (first string) matches the specified IP range (second string, in [[:enw:CIDR notation|CIDR notation]]).Only works for anonymous users.Supports both IPv4 and IPv6 addresses.
|-
| <code>contains_any</code> || Returns true if the first string contains '''any''' string from the following arguments (unlimited number of arguments in logic OR mode).If the first argument is an array, it gets casted to string.
222

edits