Knowledge

:Edit filter/Traps and pitfalls - Knowledge

Source 📝

767:
Filter logs can disappear under these circumstances: 1) If an edit is saved and then rev-deleted or oversighted, then the filter log disappears from view (including from sysops). 2) Oversighters can remove the logs of either saved or unsaved edits. Edit filter counters will always increment,
722:
is either 0 or 1. However, the division operation in fact doesn't discard the remainder. That means, if the numerator is not divisible by the denominator, the result will be a float. In the above case, use
702:
do not implicitly cast arrays to string and will return the length of the array (i.e., number of lines), not the character count, instead. The cast needs to be explicit, i.e.,
474:
It then removes any repeating characters that are next to one another, leaving one character remaining. For example: string "ABC12345555556" would become "ABC123456".
548:
You may be asking yourself, "what happened here?" Take a look below to see how the norm() function's execution order modifies string_example step-by-step:
312:
Suppose that Alice, as her first edit, adds the string "Hello, world! ~~~~" to a page that has only ever been edited by Bob. She then makes 20 more edits.
165:. This may cause false positives and issues if many anonymous users unrelated to one another match the filter conditions when saving edits. 471:
It begins by replacing confusing characters, or characters that are often used to spoof or maliciously bypass edit filter conditions.
82: 296: 121: 62: 663:. Other operations will implicitly cast an array to a string first. This could give an unintuitive result. For example, 67: 309:
will have different values from what they would have been had the filter actually tripped at the time of the change.
57: 771: 562://This is the initial string that we originally assigned to string_example. Now we run the norm() function to it... 77: 574://The first task (replacement of confusing characters) would result in the '@' being replaced by the letter 'A'. 996: 117: 647:, unless you also want to activate the tag for manual use. Mistakenly activated tags may be deactivated from 213: 682:
On the other hand, if you want to compute the amount of text added (removed), you might be tempted to use
316: 306: 598://The third task removes all special characters, meaning that the comma (',') in this string is removed. 458: 628: 730: 125: 896: 302: 221: 484:
This can lead to unexpected results if one is unaware of the function's specific execution order:
201: 933: 52: 17: 916: 675:
is 1, 2, 3, or 4, the expression will be evaluated to true as well. In the above case, use
762: 709: 477:
All special characters (such as _, +, :, #, $ . %, {, etc.) are then stripped and removed.
8: 107: 35: 586://The second task would remove the repeated 'A' and 'C' characters, leaving one of each. 99: 944:
When examining recent changes. Examining old filter hits will show the correct values.
654: 776:
For historical reasons, some variable names do not fit the general naming pattern:
463:
The norm() function performs the following modifications to the string value to it
954: 136:
When applying a throttle to an edit filter, it is important that you do so using
381: 217: 87: 205: 990: 256:
when setting up a bot password. Instead, just specify the groups explicitly:
648: 644: 480:
Lastly, all whitespace characters are stripped and removed from the string.
42: 180:
variable when applying a throttle, unless the filter specifically targets
768:
therefore, a filter may have fewer visible logs than the number of hits.
634: 161:, not by username. All logged out editors share one user id, which is 187: 131: 252:
but this will not work as expected if the user did not grant
150:
variables wherever possible (as opposed to using either or).
212:
may be limited. For example, it looks like we could exclude
890: 639:
Tags are created automatically when a filter is saved. Do
902: 659:
The only operation that really works with arrays is
743:is true. This is especially problematic when using 342:Hello, world! ] (]) 21:07, 14 November 2019 (UTC) 988: 747:: if the action being filtered is not an edit, 751:will evaluate to true. Remember to check that 116:This page covers some common mistakes made by 610://The last task would then remove the space. 172:alone throttles logged in editors by their 200:rights. If the user has logged in using a 465:in the following specific execution order 315:One week later, we look at her edit with 297:Test/examine interface and recent changes 622://The resulting string will be "AABBC". 14: 989: 915:The title was shamelessly stolen from 772:Inconsistent naming of some variables 677:equals_to_any(page_namespace, 12, 34) 669:string(page_namespace) in "12\n34\n" 25: 725:equals_to_any(page_namespace, 0, 1) 122:Knowledge:Edit filter/Documentation 23: 319:. Some results may be surprising: 196:variable only contains the user's 182:logged out or anonymous users only 120:. For the full documentation, see 24: 1008: 968:a filter log entry, if any exists 739:is smaller than any number, i.e. 643:use the interface at the top of 459:norm() and repeating characters 977:This is actually the value of 971: 959: 947: 938: 922: 909: 13: 1: 785:Pre-save transform variables 731:Numeric comparisons with null 7: 704:strlen(string(added_lines)) 317:Special:AbuseFilter/examine 307:Special:AbuseFilter/examine 10: 1013: 389:and other keywords have a 97: 784: 781: 679:as a workaround instead. 667:is in fact equivalent to 405:contains "foo" or "bar": 83:Reporting false positives 897:Knowledge:Village stocks 763:Disappearing filter logs 716:page_namespace / 2 === 0 710:Be careful with division 550: 486: 432: 407: 367:page_recent_contributors 303:Special:Abusefilter/test 258: 226: 204:, or is editing with an 126:mw:Extension:AbuseFilter 934:Special:UserGroupRights 627:When in doubt, use the 928:All these groups have 782:Page content variables 714:One might expect that 655:Be careful with arrays 176:. Do not use only the 78:Requested edit filters 68:How to create a filter 36:Edit filter management 997:Knowledge edit filter 932:rights, according to 799:Transformed variable 749:edit_delta < -5000 690:or similar. However, 688:strlen(removed_links) 331:At /examine or /test 174:underlying IP address 18:Knowledge:Edit filter 917:C Traps and Pitfalls 118:edit filter managers 684:strlen(added_lines) 382:Order of operations 276:"extendedconfirmed" 235:"extendedconfirmed" 157:alone throttles by 741:null < -1234567 671:. Therefore, when 665:page_namespace in 339:Hello, world! ~~~~ 301:Some variables at 214:extended confirmed 88:Tags documentation 73:Traps and pitfalls 930:extendedconfirmed 888: 887: 753:action === "edit" 379: 378: 96: 95: 1004: 981: 980: 975: 969: 963: 957: 951: 945: 942: 936: 931: 926: 920: 913: 882:new_wikitext_pst 879: 872: 862: 855: 848: 843: 838: 828: 821: 816: 811: 806: 779: 778: 758: 754: 750: 746: 742: 738: 726: 721: 717: 705: 701: 697: 693: 689: 685: 678: 674: 670: 666: 662: 623: 620: 617: 614: 611: 608: 605: 602: 599: 596: 593: 590: 587: 584: 581: 578: 575: 572: 569: 566: 563: 560: 557: 554: 544: 541: 538: 535: 532: 529: 526: 523: 520: 517: 514: 511: 508: 505: 502: 499: 496: 493: 490: 454: 451: 448: 445: 442: 439: 436: 426: 423: 420: 417: 414: 411: 404: 396: 393:precedence than 388: 322: 321: 292: 289: 286: 283: 280: 277: 274: 271: 268: 265: 262: 255: 248: 245: 242: 239: 236: 233: 230: 211: 195: 179: 171: 164: 156: 149: 143: 110: 26: 1012: 1011: 1007: 1006: 1005: 1003: 1002: 1001: 987: 986: 985: 984: 979:added_lines_pst 978: 976: 972: 964: 960: 952: 948: 943: 939: 929: 927: 923: 914: 910: 905: 893: 875: 870: 858: 853: 846: 841: 836: 826: 820:added_lines_pst 819: 814: 809: 804: 774: 765: 756: 752: 748: 744: 740: 736: 733: 724: 719: 715: 712: 703: 699: 695: 691: 687: 683: 676: 672: 668: 664: 660: 657: 637: 631:to assist you. 625: 624: 621: 618: 615: 612: 609: 606: 603: 600: 597: 594: 591: 588: 585: 582: 579: 576: 573: 570: 567: 564: 561: 558: 555: 552: 546: 545: 542: 539: 536: 533: 530: 527: 524: 521: 518: 515: 512: 509: 506: 503: 500: 497: 494: 491: 488: 461: 456: 455: 452: 449: 446: 443: 440: 437: 434: 428: 427: 424: 421: 418: 415: 412: 409: 402: 394: 386: 384: 299: 294: 293: 290: 287: 284: 281: 278: 275: 272: 269: 266: 263: 260: 253: 250: 249: 246: 243: 240: 237: 234: 231: 228: 209: 193: 190: 177: 169: 162: 154: 147: 141: 134: 114: 113: 106: 102: 92: 48: 43:Tags management 22: 21: 20: 12: 11: 5: 1010: 1000: 999: 983: 982: 970: 958: 946: 937: 921: 907: 906: 904: 901: 900: 899: 892: 889: 886: 885: 873: 868: 856: 850: 849: 844: 839: 834: 823: 822: 817: 812: 807: 801: 800: 797: 794: 791: 787: 786: 783: 773: 770: 764: 761: 732: 729: 720:page_namespace 718:will check if 711: 708: 673:page_namespace 656: 653: 636: 635:Creating a tag 633: 629:debugging tool 613:string_example 601:string_example 589:string_example 577:string_example 565:string_example 553:string_example 551: 531:string_example 510:string_example 489:string_example 487: 482: 481: 478: 475: 472: 460: 457: 433: 408: 383: 380: 377: 376: 374: 371: 368: 364: 363: 361: 359: 355: 354: 351: 348: 347:user_editcount 344: 343: 340: 337: 333: 332: 329: 326: 298: 295: 259: 227: 222:administrators 189: 186: 168:Throttling by 153:Throttling by 133: 130: 112: 111: 103: 98: 94: 93: 91: 90: 85: 80: 75: 70: 65: 60: 55: 49: 47: 46: 39: 31: 29: 15: 9: 6: 4: 3: 2: 1009: 998: 995: 994: 992: 974: 967: 962: 956: 950: 941: 935: 925: 918: 912: 908: 898: 895: 894: 883: 878: 874: 869: 866: 861: 857: 852: 851: 847:edit_diff_pst 845: 840: 835: 832: 825: 824: 818: 813: 808: 803: 802: 798: 796:Sent variable 795: 792: 789: 788: 780: 777: 769: 760: 735:Like in PHP, 728: 707: 680: 652: 650: 646: 642: 632: 630: 549: 543:/* TRUE */ 522:/* FALSE */ 485: 479: 476: 473: 470: 469: 468: 466: 431: 430:Instead use: 406: 400: 392: 372: 369: 366: 365: 362: 360: 357: 356: 352: 349: 346: 345: 341: 338: 335: 334: 330: 327: 324: 323: 320: 318: 313: 310: 308: 304: 257: 254:editprotected 225: 223: 219: 215: 208:application, 207: 203: 199: 185: 183: 175: 166: 160: 151: 146: 139: 129: 127: 123: 119: 109: 105: 104: 101: 89: 86: 84: 81: 79: 76: 74: 71: 69: 66: 64: 63:Documentation 61: 59: 56: 54: 51: 50: 45: 44: 40: 38: 37: 33: 32: 30: 28: 27: 19: 973: 965: 961: 949: 940: 924: 911: 881: 876: 871:new_wikitext 864: 859: 830: 810:new_wikitext 805:old_wikitext 775: 766: 734: 713: 681: 658: 649:Special:Tags 645:Special:Tags 640: 638: 626: 547: 483: 464: 462: 429: 425:/* WRONG! */ 398: 397:. This does 390: 385: 314: 311: 300: 264:contains_any 251: 247:/* WRONG! */ 202:bot password 197: 191: 181: 173: 167: 158: 152: 144: 137: 135: 115: 72: 41: 34: 815:added_lines 759:like that. 755:when using 571:"AA AB,BCC" 559:"A@ AB,BCC" 498:"A@ AB,BCC" 435:added_lines 410:added_lines 403:added_lines 358:user_groups 336:added_lines 270:user_groups 241:user_rights 210:user_rights 194:user_rights 188:user_rights 58:Noticeboard 53:Edit filter 757:edit_delta 745:edit_delta 132:Throttling 953:See also 865:new_links 860:all_links 854:old_links 842:edit_diff 727:instead. 583:"A AB,BC" 401:check if 991:Category 891:See also 837:new_html 831:disabled 827:old_html 595:"A ABBC" 325:Variable 108:WP:EF/TP 100:Shortcut 955:T102944 877:new_pst 619:"AABBC" 607:"AABBC" 540:"AABBC" 328:At save 282:"sysop" 216:users, 198:current 159:user id 696:length 692:strlen 661:length 450:"|bar" 422:"|bar" 391:higher 220:, and 903:Notes 880:(not 863:(not 700:count 519:"ABC" 444:"foo" 438:rlike 416:"foo" 413:rlike 387:rlike 373:Alice 288:"bot" 224:with 206:OAuth 16:< 737:null 698:and 525:norm 504:norm 375:Bob 305:and 218:bots 192:The 155:user 148:user 140:the 138:both 124:and 966:Not 793:New 790:Old 641:not 399:not 370:Bob 353:20 145:and 993:: 884:) 706:. 694:, 686:, 651:. 537:== 516:== 467:: 238:in 184:. 178:ip 170:ip 142:ip 128:. 919:. 867:) 833:) 829:( 616:= 604:= 592:= 580:= 568:= 556:= 534:) 528:( 513:) 507:( 501:; 495:= 492:: 453:) 447:+ 441:( 419:+ 395:+ 350:0 291:) 285:, 279:, 273:, 267:( 261:! 244:) 232:( 229:! 163:0

Index

Knowledge:Edit filter
Edit filter management
Tags management
Edit filter
Noticeboard
Documentation
How to create a filter
Traps and pitfalls
Requested edit filters
Reporting false positives
Tags documentation
Shortcut
WP:EF/TP
edit filter managers
Knowledge:Edit filter/Documentation
mw:Extension:AbuseFilter
bot password
OAuth
extended confirmed
bots
administrators
Special:Abusefilter/test
Special:AbuseFilter/examine
Special:AbuseFilter/examine
debugging tool
Special:Tags
Special:Tags
Knowledge:Village stocks
C Traps and Pitfalls
Special:UserGroupRights

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.