Commit graph

405 commits

Author SHA1 Message Date
jenkins-bot eae59db542 Merge "Fix the block options on ViewEdit" 2018-09-20 11:25:00 +00:00
Daimona Eaytoy 9144dbf4a1 Remove unused parameter
Nothing uses it, plus it wouldn't work anyway: AbuseFilterParser
constructor only uses $vars if it's instanceof
AbuseFilterVariableHolder.

Change-Id: Idbf53f6058148e9f0e73beb949e1c028a81663ce
2018-09-19 19:58:30 +02:00
jenkins-bot a813140e44 Merge "Unbreak /examine for old log entries" 2018-09-16 12:00:34 +00:00
Daimona Eaytoy fc867a1c5c Allow testing account autocreation
Bug: T204231
Change-Id: If566cfdeb4cdbb78833077da09aeef33754f88d3
2018-09-14 13:09:07 +02:00
Daimona Eaytoy 31729b044e Unbreak /examine for old log entries
For the moment, this is a simple workaround to get them back working.
Ideally we'd also need a maintenance script to update var dumps as I
wrote in the task, but it needs more thinking (see Phab).

Bug: T204236
Change-Id: Ia20a2eb495557f46f789467a96e654ec6cd3f355
2018-09-13 18:42:47 +02:00
Matěj Suchánek 6eb5d9766b Use correct variable in AbuseFilter::addLogEntries
The data was inserted to the foreign database, so the id needs
to be fetch from that one.

Change-Id: I8eef8d74fc924829447e31f4445154b01b92aa7a
2018-09-13 11:57:55 +02:00
jenkins-bot a0a4755c59 Merge "Remove unused method from parser" 2018-09-09 12:32:56 +00:00
jenkins-bot 121df619da Merge "Improve coverage for AbuseFilterTokenizer" 2018-09-09 12:30:49 +00:00
jenkins-bot 151b1f6779 Merge "Make searched filters highlighting multibyte safe" 2018-09-09 12:25:17 +00:00
jenkins-bot dee934cd5a Merge "Partly unbreak throttle action" 2018-09-09 12:03:40 +00:00
jenkins-bot e4f986a661 Merge "Add full tests for deprecated variables" 2018-09-09 11:55:03 +00:00
jenkins-bot fb864408e3 Merge "Replace wfDebug and wfDebugLog with logger" 2018-09-09 11:55:02 +00:00
Daimona Eaytoy 8885a5983e Partly unbreak throttle action
This action have ALWAYS had this problem: when creating a new filter,
the temporary ID is 'new', and the throttle ID is then 'new'.
This is used when creating/checking throttle keys to determine if the
user should be throttled. However, the 'new' key is not unique and
(although it's not the only part of the key), it may lead to
unpredictable behaviours. I'm not sure if this solves the task below,
but can probably help.
Also added a FIXME that we should handle shortly.

Bug: T195699
Change-Id: Id3b0ff524c52fb57fdd72f9608f758f8383e4320
2018-09-09 07:09:14 +00:00
jenkins-bot a3882d8c4a Merge "Only select needed columns in queries" 2018-09-05 17:11:42 +00:00
jenkins-bot a9f9742b28 Merge "Remove the last PHPCS exclusion" 2018-09-05 17:07:51 +00:00
Daimona Eaytoy e65a69b6fe Only select needed columns in queries
Using '*' is handy, but we often end up selecting too much stuff.

Change-Id: I16d791ff8de6596de4fb65b1032b225f0bd65bf3
2018-09-03 14:12:41 +02:00
jenkins-bot 7cce6d1864 Merge "Remove _age variables from cache keys" 2018-09-03 12:08:29 +00:00
Daimona Eaytoy 63803568d6 Remove the last PHPCS exclusion
Bug: T178007
Change-Id: I5ddb811c2cb15040a859a63b64873f0fa53508ee
2018-09-03 10:42:30 +02:00
Daimona Eaytoy 48989ffcda Remove PHPCS exclusion and fix it
Again, we're left with only one exclusion that I don't know how to fix.
See phab for a longer explanation.

Bug: T178007
Change-Id: I017097abef755bc65c77a5658ad92320bc42d78b
2018-09-03 09:33:29 +02:00
libraryupgrader 5cdab14eb8 build: Updating mediawiki/mediawiki-codesniffer to 22.0.0
The following sniffs are failing and were disabled:
* Squiz.PHP.NonExecutableCode.Unreachable

Change-Id: Ic3f031974008776f272d1ee77093c6d170f27ae9
2018-09-02 22:05:58 +00:00
Daimona Eaytoy bffba28713 Add full tests for deprecated variables
This test checks every deprecated variable to be identical to the
newly-named one, and to emit a debug notice. It also changes such debug
to be emitted via logger instead of wfDebug.

Bug: T201193
Bug: T173889
Change-Id: Ie55746bb7731062ae2d46d84857af2a05d78cf4c
2018-08-29 11:00:28 +02:00
Daimona Eaytoy 2f0a0a0893 Replace wfDebug and wfDebugLog with logger
Per standard on
https://www.mediawiki.org/wiki/Manual:Structured_logging. The use inside
AbuseFilterParser is removed in
Ie55746bb7731062ae2d46d84857af2a05d78cf4c.

Change-Id: Ia62287c4ff5f904557cd6d43d47a9f4d9696b94b
2018-08-29 10:57:56 +02:00
Daimona Eaytoy 39f42caffc Make searched filters highlighting multibyte safe
Avoid using preg_match's offset since it is MB-unsafe. Also, remove 'UTF-8'
from mb_ functions (it's the default), reduce code duplication, and show
the right snippet for long search patterns.

Bug: T202310
Change-Id: Ieb06bdd80b0f915609afed7c7ad95e6318058ee9
2018-08-27 07:22:22 +00:00
Daimona Eaytoy 934399de45 Remove _age variables from cache keys
As we do for user_age, since these will always change. Also, rework the
method to avoid repetition of unset().

Change-Id: Ie5ceedd89cae3813bacf6680d588bc925362c2c2
2018-08-26 16:02:32 +02:00
jenkins-bot 10c147cb92 Merge "Use === operator with strpos" 2018-08-25 21:28:28 +00:00
Daimona Eaytoy 8094a49dcf Generate upload variables using new prefixes
This wasn't changed in I5c370b54e6516889624088e27928ad3a1f48a821 but
really needs to be merged, to avoid setting wrong variables. At the
moment this is still fine due to temporary overrides in
AbuseFilter::generateTitleVars, but this should be merged ASAP anyway.

Bug: T173889
Change-Id: I2e6058a6fa122470a30cd4a96c68eccc66e18ae4
2018-08-25 19:06:35 +02:00
Daimona Eaytoy ef51e7c253 Fix the block options on ViewEdit
Align the checkbox label on the left to conform with dropdowns, avoid
two if with the same conditions, and give variables a better name. Also,
remove an unused message: with OOUI, the old design can't be reproduced.
We could add a fieldset, but then it would be greatly different from
options for other actions.

Change-Id: Ibdc993c1457636215601eb22f5202d2f6ad57bd9
2018-08-25 18:56:44 +02:00
Daimona Eaytoy 66318915db Use === operator with strpos
The condition always evaluated to true: for global filters strpos
returned 0, otherwise it returned false, which is == 0. Fortunately, in
the second case the function returned false as it should. Anyway, be
safe and use === operator as it should always be for strpos.

Change-Id: I7ffc990b2b8b9c47ebfb64d5234f561faaff5e88
2018-08-25 17:35:15 +02:00
Daimona Eaytoy 775c736512 Improve coverage for AbuseFilterTokenizer
This will make tokenizer almost fully covered. The only uncovered parts
are the one with cache and an else condition which I think won't ever be
executed, and thus added a comment for that. Also, remove an obsolete
xxx comment from ComputedVariable (fixed in
I8e420f0259ef6c9e579f7a00beb58f28af9da37d)

Bug: T201193
Change-Id: I6e9a73aa9e437f096f6a1e20d53a7cb50e5ed85d
2018-08-25 10:25:16 +02:00
Daimona Eaytoy a8b62dc828 Remove unused method from parser
AbuseFilterParser::setVarsimply calls the setVar method in
VariableHolder and is currently unused. Its only call was removed in
I80cbc4033ff96f2fe8c1da263b1877bfb4c7c0c4. After this patch we'll only
have an uncovered line in the parser, which is likely due to a bug in
the coverage check.

Change-Id: Ic860b03b2d23fec073a9294e356e074ae1b14ae5
2018-08-24 12:30:47 +02:00
jenkins-bot 055cc7b5ff Merge "Filter AbuseLog by triggering action" 2018-08-23 14:48:57 +00:00
jenkins-bot ad69ea648e Merge "Remove unused function and improve unit test" 2018-08-23 13:46:41 +00:00
jenkins-bot 81a4fdc964 Merge "Improve Ace syntax highlight" 2018-08-23 10:14:57 +00:00
Matěj Suchánek 853936316f Filter AbuseLog by triggering action
For now, there is an "Other" field which will show all but hard-coded actions.

Bug: T187971
Change-Id: If564aced2e9cd933d8cfcf7cb96166aa279f2823
2018-08-23 11:40:15 +02:00
Daimona Eaytoy 03b52c2b37 Remove unused function and improve unit test
AbuseFilterParser::setVars is only used in a parser test. In the past it
was also used in the actual code (see for instance
https://phabricator.wikimedia.org/diffusion/EABF/browse/master/;5cc8dac63ca585c288ca4c8605db810774e39666?grep=setVars), but at the moment it's pretty unuseful.
This patch removes such function and makes the unit test use literals
instead of variables to avoid calling it.

Change-Id: I80cbc4033ff96f2fe8c1da263b1877bfb4c7c0c4
2018-08-23 11:00:16 +02:00
jenkins-bot 46d78623f4 Merge "Add page_age variable to AbuseFilter" 2018-08-22 16:17:36 +00:00
Daimona Eaytoy e8a4517d6b Improve Ace syntax highlight
Several improvements, this is the list:
*Added highlighting for disabled and deprecated variables
*Simplified a bit Ace's keyword mapper
*Added highlighting for ternary operator
*Added logic to retrieve operators from AF tokenizer
*Removed $ symbol since it's not usable in declaring stuff
*Customized highlighting via CSS

Depends-On: I5c370b54e6516889624088e27928ad3a1f48a821
Change-Id: If95e34fc7260413c4fb39c18a1ef44f5a93e1a68
2018-08-22 15:23:35 +00:00
rarohde e1865fca74 Add page_age variable to AbuseFilter
Adds page_age variable that reports the number of seconds since the
first edit to the current article (or 0 for new articles).

Bug: T30844
Change-Id: I0993cecc322806382a1b567b60c0a4af69054841
2018-08-22 17:10:39 +02:00
Daimona Eaytoy 4399be933d Use OOUI infusion for the change tags field in ViewEdit
Since this is what it's meant to be for. Better, cleaner, safer.

Change-Id: Ib5f632ac708aeff62b50c91ef60c547036481834
2018-08-22 15:27:06 +02:00
jenkins-bot a762c82fe7 Merge "Add aliases for "_text" and "article_" variables" 2018-08-22 12:44:20 +00:00
jenkins-bot 5561abe296 Merge "Add a placeholder for the no-js changetags input field" 2018-08-22 12:44:19 +00:00
jenkins-bot 777a86314e Merge "Improve code coverage for AbuseFilterParser" 2018-08-22 11:15:00 +00:00
Daimona Eaytoy e526295123 Add a placeholder for the no-js changetags input field
There is already one for the js field, but we can't reuse it since "one
by one" doesn't make any sense here.

Change-Id: Iaf01e19f4006b3d578bb2201cf9108fe46d56085
2018-08-22 11:02:51 +02:00
Daimona Eaytoy 66774b8d7a Show an extract of suppression log for Special:AbuseLog
Like we do in core for similar special pages. This is really helpful
when (un)hiding an entry.

Bug: T200645
Change-Id: I16450a2573e8987e31a83ec34f3dbb16fac94f81
2018-08-21 19:19:10 +02:00
Matěj Suchánek 10ad58a6f3 Migrate AbuseFilter suppress log
Also make entries in Special:Log/suppress filterable.

Change-Id: Ic23e724997e4748c8d0da8138aa73d31b17b7064
2018-08-21 16:05:54 +00:00
Daimona Eaytoy 6bc630cfef Add aliases for "_text" and "article_" variables
Variables regarding title (full list in task description) are quite
deceiving, since they use "text" instead of "title". As proposed in the
task, this is the first patch to add aliases for those variables and
slightly deprecate the old ones. In the future we may be able to replace
every occurrence (either with a search function or directly on the
database), but even a coexistence would be enough to avoid
confusion. A wfDebug log is generated whenever a deprecated variable is
parsed. The "article_" prefix is also changed to "title_", in the same
way as above.
Also, added a hook which other extension may use to specify their
deprecated variables, which will be handled the same as core ones.

Bug: T173889
Change-Id: I5c370b54e6516889624088e27928ad3a1f48a821
2018-08-21 16:59:56 +02:00
Umherirrender 2b615cfa29 Avoid variable reuse to pass taint-check
Also set param-taint for value of WebRequest::getText

Bug: T197002
Change-Id: I9e52d24f88789c99c726e32df20840707d1b47ae
2018-08-20 19:54:20 +02:00
Daimona Eaytoy 4f3b020f5d Improve code coverage for AbuseFilterParser
Add some tests and improve others to raise coverage percentage. This
should lead to almost 100% for the AbuseFilterParser class. Aside from
this, a couple of changes:
* Remove an unused function
* Let equals_to_any return a genuine result with empty strings
* Remove an if which will never be true in skipOverBraces, since the
function is called after checking the same conditions.

Bug: T201193
Change-Id: I7020b2ed996236c38c5784d161ad98ec44163406
2018-08-20 14:38:40 +02:00
jenkins-bot 50a295a6e7 Merge "Include CheckUser in phan config" 2018-08-20 01:52:54 +00:00
jenkins-bot 55f0cd2580 Merge "Change priority order for messages in hidden abuselog entries" 2018-08-19 19:21:41 +00:00