This section explains how to create a filter and conduct some preliminary testing, so that you don't flood the history page.
Edit filters are very powerful tools - do not underestimate the damage errors can cause. If you're new to this, make sure you get appropriate input from editors more experienced with edit filters. |
'some string' rlike 'myregexp'
to test your regexp - true expressions evaluate to 1, false will show nothing.Because these filters are run on every single edit, a poorly worded filter has the strong potential to severely slow down editing or even cause some larger pages to time out. However, some very minor changes in how the conditions are ordered can greatly decrease the running time of the filters. Making use of the order of operations in this way can make the difference between a good filter and one that must be disabled for performance reasons.
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. The evaluation order is:
(
and )
) is evaluated as a single unit.article_namespace
to 0)norm
, lcase
, etc.)+
and -
(defining positive or negative value, e.g. -1234
, +1234
)!x
)2**3 → 8
)3-2 → 1
)<
, >
, ==
)&
, |
, ^
, in
)When using keywords such as rlike, in, or contains, the filter must go through the entire string variable to look for the string you're searching for. Variables such as old_wikitext have the tendency to be very large. Sometimes you will be able to approximate these variables by using smaller ones such as added_lines or removed_lines, which the filter can process much faster. Also, using a check for old_size can also help to ensure that you're not going to even try checking a large block of wikitext.
You should always order your filters so that the condition that will knock out the largest number of edits is first. Usually this is a user groups or a user editcount check; in general, the last condition should be the regex that is actually looking for the sort of vandalism you're targeting.
This article uses material from the Wikipedia English article Instructions, which is released under the Creative Commons Attribution-ShareAlike 3.0 license ("CC BY-SA 3.0"); additional terms may apply (view authors). Content is available under CC BY-SA 4.0 unless otherwise noted. Images, videos and audio are available under their respective licenses.
®Wikipedia is a registered trademark of the Wiki Foundation, Inc. Wiki English (DUHOCTRUNGQUOC.VN) is an independent company and has no affiliation with Wiki Foundation.