Commit graph

329 commits

Author SHA1 Message Date
Paladox b3081e1798 Update mediawiki/mediawiki-codesniffer to 0.5.1
Change-Id: I4b2055a76db4362a8136e3fd595228cf07d083a9
2016-08-23 16:18:27 +02:00
Bartosz Dziewoński a11a02d833 Make static function bufferTagsToSetByAction() really static
Follow-up to f3ac71de38.

Change-Id: Ie6865fe0c08ad0ce5e9a5a3b59c9b427228fb554
2016-07-27 22:22:39 +02:00
Aaron Schulz a2baec187a Convert deferred update to using AutoCommitUpdate
Change-Id: Ife8164fc1bce00e53a89ccec6e445f721fbfa93f
2016-07-21 23:16:12 -07:00
jenkins-bot d56498efa1 Merge "Ignore _VIEWS in getStashKey()" 2016-07-18 19:10:24 +00:00
Aaron Schulz d4cb5f2275 Make getFilter() public for extension hooks
Bug: T139657
Change-Id: Id1c196e8ead6cd280129e7e3aa6741edcf4fa551
2016-07-15 14:55:13 -07:00
Aaron Schulz 8da016fe26 Ignore _VIEWS in getStashKey()
Change-Id: I9830fa237073f57285435c65fe4838d23ab1d024
2016-07-15 07:03:05 -07:00
Bartosz Dziewoński 1826d39620 Use custom error code for all edit and upload API responses
The error code 'abusefilter-disallowed' or 'abusefilter-warning' is
used, depending on whether the filter only warns (and will allow the
action when retried) or prevents the user from performing the action.
The API response has been extended with some additional properties.

* For simple filters with no custom messages where the only action is
  'disallow' or 'warn', the error code is the same as before.
* For filters with different actions, different error codes would
  previously be returned; 'abusefilter-disallowed' will be returned
  for them all, with the actions taken listed in the
  .abusefilter.actions property of the API response.
* For filters with custom messages, the message key would previously
  be used as the error code; now 'abusefilter-disallowed' or
  'abusefilter-warning' is used, with the message available in the
  .message property of the API response.

Also cleaned up some dead "forwards-compatibility" code and made a
recently introduced public method private.

The new functionality depends on Ifac8995a4d16d11840cee814177fc2808bc2072c
in MediaWiki core, older MediaWiki versions behave mostly as before.

The new .message property contains both the key and the parameters
duplicated from .abusefilter, so that the client doesn't have to know
what AbuseFilter is - it'll be able to just display the given
message with the given parameters. My specific use case is the upload
dialog in core (core shouldn't have to know about any extensions).

See also TitleBlacklist change I97c1f5c6bbbdfc0b8ea9914bb075d5299c14df8f.

Bug: T137961
Change-Id: I5780eae96930211191ecd874aacf53fdacb58f89
2016-07-11 19:20:19 +00:00
Aaron Schulz f3ac71de38 Fix $filters and $tagsToSet static variable handling
* Make $filters act as a proper process cache with
  lazy-loading and renamed it to $filterCache.
  This avoids warnings that appeared in e91939fb3f.
* Make sure tags are applied on stash hits by storing
  and reloading the static variable.
* Only check the cache for "edit" actions to avoid
  filling the statsd and logging data with noise.
* Remove some unused class variables.

Bug: T138529
Change-Id: I8230fef0ad0db7ae63086470189204e319382cca
2016-06-30 00:50:34 +00:00
Aaron Schulz 9fed0a2b76 Avoid using computed variables to determine stash keys
These variables are not used as "inputs" and are expensive to
compute (the main reason for caching to begin with).

Bug: T138550
Change-Id: I75849ca8eab941f75ebb82313d07d946bc095ae9
2016-06-28 21:17:45 +00:00
Aaron Schulz 4091c87bad Remove "minor_edit" variable
This is almost never used and greatly complicates edit stash hooks.
It now always set to false.

Change-Id: I7f13773766e12f3d4b86451fdf3ae23e067ac373
2016-06-27 13:07:14 -07:00
Aaron Schulz e91939fb3f Cache AbuseFilter::checkAllFilters during edit stashing
This should improve page save times when manual edit summaries are
not used (and in a few cases, where they are).

Also fix a few annoying IDEA errors with block comments.

Bug: T137698
Depends-On: I2e407a3ac8b74e77bf88b1e34c1519f4dea63b80
Change-Id: I972e9147a5e52a941f478eaf1e96dc3ef8bdfe94
2016-06-14 04:26:14 -07:00
jenkins-bot 8517f8fb47 Merge "Use msg() from Context instead of wfMessage() where possible" 2016-06-12 02:06:47 +00:00
Gergő Tisza ed5cc1b5fc Update for AuthManager
Repeats I61e4327ef3c7a31b19feef727de7d683f69e260b (which had to be
reverted due to a problem with an ancestor patch) without any
significant change.

Bug: T110448
Bug: T135360
Change-Id: I1688cf9fbcb04bb56d075c9f0876bd0ffeced4f6
2016-06-06 19:54:26 +00:00
Gergő Tisza 6a2627e944 Change some globals to work better with extension registration
Rename $wgAbuseFilterAvailableActions / $wgAbuseFilterRestrictedActions
to $wgAbuseFilterActions / $wgAbuseFilterRestrictions and make
them an associative array instead of a plain one, as that works more
sanely with extension registration. (The renaming helps to give more
useful errors to sites using the old config.)

Change-Id: I790d39c2849922d7daf7479f298cd90cf30af129
2016-06-06 19:53:53 +00:00
Gergő Tisza 8cc1aa78bf Revert extension registration and following changes
Reverts:
* e71808f4c4 ("Add extension.json, empty php entry point")
* 8c937957c0 ("Update for AuthManager")

Bug: T136929
Change-Id: Iefc88cb4e981113119f850ca70b9486675bf8a8d
2016-06-03 14:57:55 +00:00
Glaisher f735ec943b Use msg() from Context instead of wfMessage() where possible
Also fix doc.

Change-Id: Ie2ea588280df43bc523021a69e118a6dbb90c223
2016-06-01 17:44:33 +05:00
Gergő Tisza 8c937957c0 Update for AuthManager
Bug: T110448
Bug: T135360
Change-Id: I61e4327ef3c7a31b19feef727de7d683f69e260b
2016-05-28 18:42:28 +00:00
Aaron Schulz 43a538fe03 Fixes to filter profiling
* Defer the slow profiling updates to post-send
* Convert to the object stash, so that all DCs see
  the same values

Change-Id: I08316c6a3192bd69248cf5ab5a3ed8185341c313
2016-04-13 23:21:32 +02:00
jenkins-bot fa22bdae6f Merge "Mostly unbreak profiling of number of conditions used by filters" 2016-04-11 12:56:36 +00:00
jenkins-bot 0ef2bd0dac Merge "Add $wgAbuseFilterProfile to enable filter profiling" 2016-04-11 12:56:33 +00:00
jenkins-bot e8b947d3c1 Merge "Revert "Removed filter profiling using $wgMemc"" 2016-04-11 12:56:30 +00:00
Bartosz Dziewoński e0ff347e29 Interpret data correctly in getMoveVarsFromRCRow()
$params[0] is the full prefixed page title, with namespace.
$params[1] is whether the move was with or without a redirect.

Bug: T121963
Change-Id: I880bb227f2fc97394a68187e7b8391acf5aeaf5e
2016-04-09 01:29:27 +00:00
Bartosz Dziewoński ca0b0c081d Mostly unbreak profiling of number of conditions used by filters
We were only recording the total number of conditions used by all filters,
then treating it as if it was the per-filter number, resulting in crazy
stupid values. We were also not clearing this when a filter was edited.

(This does not fix the remaining problems mentioned on the task.)

Bug: T53294
Change-Id: I4f9f88f94469b977fe60c554b76e94edacac3462
2016-04-08 19:51:16 +02:00
Bartosz Dziewoński 337cad30d9 Add $wgAbuseFilterProfile to enable filter profiling
Follow-up to b60829a60c.

I'll fix up message translations on Translatewiki when this is merged.

Bug: T132189
Change-Id: I1ecaedd7489b264ed621309b6fbfb63b9287a437
2016-04-08 16:53:45 +00:00
Bartosz Dziewoński 39261ff5cd Revert "Removed filter profiling using $wgMemc"
This reverts commit afb78deb84.

I'll guard this behind a global and fix up the localisation messages
in a separate commit. This is a straight revert.

Bug: T132189
Change-Id: Iff4aa6d7d543db8f47c5f81f3c206dafcd5373dc
2016-04-08 16:53:34 +00:00
Bartosz Dziewoński 6298c91bde Remove executable bit from files
find . -perm /111 -type f | grep -v .git | xargs chmod ago-x

Change-Id: I1e5994ba0a74eafdeff262017f90d4c0f09f3ab4
2016-04-08 14:00:52 +00:00
Bartosz Dziewoński 8858cdd42a Add more file_* variables for file metadata
* file_mime
  The MIME type of the file, e.g. 'image/png'.

* file_mediatype
  The media type of the file, one of 'UNKNOWN', 'BITMAP', 'DRAWING',
  'AUDIO', 'VIDEO', 'MULTIMEDIA', 'OFFICE', 'TEXT', 'EXECUTABLE', 'ARCHIVE'.

* file_width
  Width of the image in pixels, or 0 if it's inapplicable (e.g. for
  audio files).

* file_height
  Height of the image in pixels, or 0 if it's inapplicable (e.g. for
  audio files).

* file_bits_per_channel
  Bits per color channel of the image, or 0 if it's inapplicable (e.g.
  for audio files). The most common value is 8.

Bug: T131643
Change-Id: Id355515a18d3674393332c0f4094e34f9f522623
2016-04-04 23:40:03 +02:00
Glaisher bbd3574731 Don't add 'anononly' flag for Abuse filter blocks
Bug: T131362
Change-Id: I6421293195d2d86574f8ecda9b467e1fedabc3ba
2016-03-31 20:42:30 +05:00
Glaisher ffcb4d945d Migrate (un)block logging to new system
Also
* Fix a bug where action-reverts doesn't work for anons
since the userid is always 0 for them, instead use the username.
* Start adding block log flags consistently with core

Bug: T124789
Change-Id: Ic6680dad891e2169b392fcfefc1e313af85bc92f
2016-03-21 15:26:59 +05:00
Brad Jorsch 888be5af64 Avoid unstubbing $wgUser when unsafe during filter failures
It'll be logging info for an anonymous user anyway, this just makes it
explicit.

Bug: T124367
Change-Id: I3c221d9af26b57b83e1be4db1698ca99fed9093c
Depends-On: I0b018a623fc833ca95d249ee21667a8f5690d50e
2016-02-03 16:07:25 -05:00
Siebrand Mazeland ce1396aea7 Add support for PHP CodeSniffer checks
Also fix any remaining errors and warnings.

Change-Id: Ie49c6172e6bbf8040e5524d33d2f719e96784745
2016-01-06 09:59:47 -08:00
Niklas Laxström b4748f25ad Remove unnecessary check for MW_SUPPORTS_CONTENTHANDLER
This extension already requires 1.23+

Change-Id: Id9f0c44cdd55ec024eb9cacb4d5b6e02546aea07
2015-11-23 11:17:39 +01:00
Aaron Schulz 4e83dcea4f Avoid pointless range scan for 'load-recent-authors'
This was just set the present time anyway and this
code is called from EditFilterMergedContent, before
the edit in question was saved either.

Bug: T116557
Change-Id: I2f84cff0ad4f65b6c2572a89a267cf42d4a96f94
2015-10-26 13:34:30 -07:00
jenkins-bot 55fe95e066 Merge "Don't add a log entry if the block wasn't inserted" 2015-10-23 07:15:02 +00:00
Glaisher 8f2029b1ea Don't add a log entry if the block wasn't inserted
$block->insert() would fail if there was an existing block
so these are not really inserted.
See for example:
https://www.mediawiki.org/w/index.php?title=Special:Log/block&page=User%3ARohitverma1

Change-Id: If2c4b34a97a0de9d9efc8b650881f04306c74915
2015-10-20 22:45:50 +05:00
jenkins-bot 07f95f4a33 Merge "Update getWithSetCallback() callers to the newer signature" 2015-10-17 22:40:35 +00:00
Aaron Schulz b90296d3a5 Update getWithSetCallback() callers to the newer signature
Change-Id: If97c1a7c25e1e28aaca9a105d50ed8e1bf2ef7ff
2015-10-16 23:48:20 -07:00
Brad Jorsch a926b2b44f Use new User::newSystemUser() when available
See core change I2c736ad72d946fa9b859e6cd335fa58aececc0d5.

Change-Id: I3f20b408c039937c1f08c9232c336268ba13895d
2015-09-17 11:55:15 -04:00
umherirrender 6c56c93c93 Do not produce self-closing <div/>
Validator says:
Self-closing syntax (/>) used on a non-void HTML element.

Change-Id: I9af3e3c22ce8918f0a15053d2dfa0b924c258aa7
2015-08-11 14:02:59 +02:00
addshore 093b2dba8a Remove use of deprecated wfRunHooks
Change-Id: I58776ddaae3dfb70a4ab4e83dfba544670b66fef
2015-08-06 18:15:42 +01:00
jenkins-bot be09eabbdd Merge "Conversion to using getMainStashInstance()" 2015-07-15 08:23:58 +00:00
Timo Tijhof fbbdce5d38 Clean up scary code
Change-Id: If4dd95c2b6e55a680c9faf03455288340e8164fb
2015-06-28 02:22:04 +01:00
Timo Tijhof abb31b0023 Fix "Fatal error: Call to undefined method WikiPage::getCount"
This was removed in MediaWiki 1.25 (90d90dad6e).

Bug: T104100
Change-Id: I25edf9e9f10cd3e14e02e63cab86fb5164af8d1a
2015-06-28 02:18:52 +01:00
Aaron Schulz 9ffa400322 Conversion to using getMainStashInstance()
Bug: T97620
Change-Id: I7fc2c0a42bf295d71b9e0721ab4261290334cdec
2015-06-24 20:18:22 +00:00
Aaron Schulz afb78deb84 Removed filter profiling using $wgMemc
* This is very slow as there can easily be hundreds of filters,
  each doing 6 memcached queries. Xenon flamegraphs show a lot
  of time spent in this method, slowing down editing.

Change-Id: I31e4502bbd45cc284db3cd89eb34ad365c59905b
2015-05-19 08:14:33 -07:00
Aaron Schulz 60d1eebb6b Conversion to using WAN cache
* Also removed some code duplication
* Use getConnectionRef in checkAllFilters so that the
  DB connection can be reused

Bug: T93141
Change-Id: I17c5a976b6c45029cde4ed34ad82d69e365ae8c5
2015-05-12 22:55:05 -07:00
jenkins-bot 3409e62df1 Merge "Fix for legacy testwiki AFL entries (1 to 154)" 2015-03-25 22:31:13 +00:00
Jeff Janes 942a95e80e PostgreSQL: Fix magic-value code for AbuseFilter
When importing filters, the code is using the magic value
of 'new' for the af_id field, which is of type bigint, to
indicate a not-yet-inserted record.

In MySQL, comparing a bigint to 'new' is legal but always false,
while in PostgreSQL it is illegal, and led to errors when checking
if the filter is hidden.

Fix this by adding special-case code to filterHidden so that it
always returns false for 'new' records. In PostgreSQL this fixes
the error, and in MySQL it avoids a pointless trip to the database.

Should be back patched to 1.23 and 1.24

Bug: T89514
Change-Id: Ib4b5585ac9889a1760ec930c555e7809a424538e
2015-03-25 22:07:55 +00:00
Alex Monk f5c4a724dc Fix for legacy testwiki AFL entries (1 to 154)
Also clean up an easy-for-users-to-break check for these legacy entries

Tested on mw1017

Change-Id: I7c1a45e39f188f4509fe4a601d2fd524717c00f8
2015-03-21 23:20:14 +00:00
Chad Horohoe 0715c05ed9 Remove obvious function-level profiling
Change-Id: I85f65a65abb5b91b44441caa21fb9c5e8edb2ebe
2015-02-04 10:26:04 -08:00