Commit graph

318 commits

Author SHA1 Message Date
Roan Kattouw 06f0a7a6d5 NotifUser: Remove basically-unused talk notification cache
This cache was only used so that, if we're told to clear the newtalk
flag and we already know there are no edit-user-talk notifications, we
won't try to delete them. But that's not a good justification for such a
confusingly-written cache that would have been hard to convert to
getWithSetCallback(), and I'm concerned that using cached data to make
this decision could lead to inconsistencies.

Also remove the notifCountHasReachedMax() check, which made no sense: if
the user has >99 notifications, that is no justification for not marking
their user talk notifications as read when they visit their user talk
page. Whether the displayed notification count will change has no
bearing on whether these notifications should be marked as read (and now
that bundled notifications are counted individually, the displayed count
actually could change).

Bug: T164860
Change-Id: I3ff5c9b31307839b9336bd8856015db9baa52fad
2018-08-09 16:34:04 -07:00
Roan Kattouw fe17b49fcd NotificationMapper: Use batching in deleteByUserEventOffset()
Also test it more meaningfully by setting up a mock database and
asserting that the right DELETE queries are issued.

Change-Id: Id39723b92118e98d9c9f0cd7381e9396dce67c17
2018-08-08 14:57:58 -07:00
Aryeh Gregor 83be57fe01 Use setContentLang instead of setMwGlobals
This sets $wgLanguageCode appropriately.  It will also be necessary when
$wgContLang becomes a service, in which case setting the global directly
will not work correctly.

Bug: T200246
Change-Id: I4aaf1c641ec6abef214eb96c0e4b42a67488ac00
2018-07-25 19:12:09 +03:00
Max Semenik f8ef0cc7f5 Get rid of special casing for user blacklist
Makes so many things simpler and robust.

Bug: T198935
Change-Id: Ia836f8f497cae8599f85cf86a7f6b299cd012e81
Depends-On: Iff63da0d215585cfcf083e7f7ec8ed45d5b77301
2018-07-09 15:50:38 -07:00
jenkins-bot 7862759c53 Merge "Re-enable test coverage reporting, add @covers tags" 2018-06-28 17:02:18 +00:00
Kosta Harlan da2da90b48 Re-enable test coverage reporting, add @covers tags
Bug: T195136
Change-Id: I9203232e79f162aedb982b713f708cebfe9d1ae0
2018-06-28 08:32:57 -04:00
jenkins-bot 855497c3ba Merge "Avoid counting where not necessary" 2018-06-26 13:54:59 +00:00
Thiemo Kreuz cb282251a8 Avoid counting where not necessary
Change-Id: I0abbdced4474dabbdecd3bbfae194e79b7c29db1
2018-06-26 07:10:38 +00:00
Željko Filipin 6aa871293e Use new page objects from mediawiki/core in Selenium tests
Bug: T171848
Change-Id: Ib6a08c6a34ef6a4bef8a81f49fed8aae67dc67dc
2018-06-22 15:23:23 +00:00
jenkins-bot e129533772 Merge "selenium: Make it possible to run tests from Echo folder" 2018-06-22 14:34:36 +00:00
Željko Filipin 53d849b3c9 selenium: Make it possible to run tests from Echo folder
Until now, Echo tests had to be run from mediawiki/core folder.

Add an independant 'npm run selenium-test' entry point
for local development. It comes with a minimal wdio.conf.js file that contains
only non-default settings, and runs only specs from this extension.
This also makes it so that screenshots are saved to this repo's
log directory instead of core's.

Bug: T171848
Change-Id: I1396f8d856c6cb1ad9818abf4ba09a4fcefdcfdc
2018-06-22 14:17:05 +00:00
Thiemo Kreuz d04b3f2710 Make use of PHP's …::class feature
Change-Id: Ifbb70f7b9d54e2e2bb713c8a13668344ac880a72
2018-06-19 18:11:23 +00:00
Thiemo Kreuz 6aa6824f96 Update some PHPDoc tags for improved type safety
Change-Id: I7573ab01e88c86c25180bc56b3874505aa00a047
2018-06-17 19:04:54 +02:00
Umherirrender 43820a6390 Move NotificationsTest to tests/phpunit
Under this folder the test is run automatically on CI or
phpunit.php --testsuite extensions

Change-Id: I5e466c04fc5c827883882f798ba0e41d6990e423
2018-06-06 19:30:35 +00:00
jenkins-bot bb453d23e3 Merge "NotifUser: Redo caching strategy for multi-DC compatibility" 2018-06-02 17:10:20 +00:00
Roan Kattouw d90e2d1066 NotifUser: Redo caching strategy for multi-DC compatibility
To use WANObjectCache correctly in a multi-DC-safe way, we need to use
getWithSetCallback() to read data, and call delete() when it changes.
NotifUser's caching of notification counts and timestamps relied
heavily on set() calls, and so wasn't multi-DC-safe.

Changes in this commit:
* Rather than caching counts/timestamps in separate cache keys, and
  using separate cache keys for each section (alert/message/all), put
  all this data in an array and store that in a single cache key.
  This reduces the number of cache keys per user per wiki from 6 to 1.
* Similarly, use a single global cache key per user. The global check
  key for the last updated timestamp is retained, so we now have
  2 global cache keys per user (down from 7)
* Remove preloading using getMulti(), no longer needed
* Move computation of counts and timestamps into separate compute
  functions (one for local, one for global), and wrap them with
  a getter that uses getWithSetCallback().
* Use TS_MW strings instead of MWTimestamp objects internally, to
  simplify comparisons and max() operations.
* Make existing getters wrap around this new getter. They now ignore
  their $cached and $dbSource parameters, and we should deprecate/change
  these function signatures.
* In resetNotificationCounts(), just delete the cache keys. In global
  mode, also recompute the notification counts and put them in the
  echo_unread_wikis table. We could also set() the data into the cache
  at this point, but don't, because you're not supposed to mix set() and
  getWithSetCallback() calls and I don't want to find out what happens
  if you do.

Bug: T164860
Change-Id: I4f86aab11d50d20280a33e0504ba8ad0c6c01842
2018-05-30 17:49:48 -07:00
Roan Kattouw 6cdebeb6ab tests: Delete the rspec tests
They keep failing intermittently in CI.

Change-Id: I4370eb0169b9dbd3a6578a94700c85d3b53ef933
2018-05-29 16:56:09 -07:00
Roan Kattouw 36d250da85 rspec: Use environment variables for user+password
Change-Id: I20273f1be7d11614879144a495c7853b6459e8b2
2018-04-30 15:46:01 -07:00
Roan Kattouw 2988b0ac04 rspec: Update wiki password for Jenkins
Apparently this changed. We should really use the env vars for this.

Change-Id: I4c4147ff6cc64d276588a16842bf436cb45e575a
2018-04-30 15:35:29 -07:00
Kunal Mehta 23a06fa5d4 tests: Remove expectations for methods that don't exist
These trigger warnings in PHPUnit 6.

Change-Id: I01ddd139f1226c1a905763cd98cb4ddb5242f4bf
2018-04-12 16:21:09 -07:00
Aryeh Gregor 86b4ed5c56 Remove call to doLogin(), which does nothing
I805520e5 is removing all callers from core.

Change-Id: I56025a9c64406f44cb157a17e308da358de0da47
2018-04-11 17:11:27 +03:00
Max Semenik 6f6e5062fe Don't ping from user talk links in summary
As discussed at T189034

Change-Id: I86f36ab55c0e03ba3bbd2ea1ee94ce3056d91e30
2018-03-08 14:36:58 -08:00
Max Semenik 9874e2d024 Allow to avoid pinging from summaries by prefixing with :
Bug: T189067
Change-Id: I0596c575a42754d2b86fd2164e15b5f46b9bca9d
2018-03-07 20:56:48 +00:00
Željko Filipin 67f0bb4763 Update README file for Selenium tests
Bug: T187862
Change-Id: I43e0a91966b07377dbbc487c5b3980c34cf53ad3
2018-02-27 13:57:52 +01:00
jenkins-bot d814e9c4bf Merge "Ping users mentioned in edit summaries" 2018-02-23 18:44:46 +00:00
Max Semenik 467b13fe89 Ping users mentioned in edit summaries
Disabled by default for now.

Bug: T32750
Change-Id: I8012b82b6e27cc2612fb2302d0c9feb3f3623d62
2018-02-22 12:37:35 -08:00
addshore 1bb986c407 Use overrideMwServices in DiscussionParserTest
Bug: T135023
Change-Id: Ibcef80224c998239f57a9353fa97ba6129fc53b1
2018-02-01 16:14:59 +00:00
jenkins-bot 1ea8a2dc55 Merge "Add @covers tags" 2018-01-24 01:29:07 +00:00
Kunal Mehta 59a125fc38 Add @covers tags
Change-Id: Ib8cf432b58470c9218519639379c83254acef1c8
2018-01-23 16:44:45 -08:00
Phantom42 ac6622711b Fix multiple PHP class declarations in one file in tests
All files containing more than one PHP class were split into
multiple files.

extension.json was updated to match new class locations.

phpcs `OneObjectStructurePerFile.MultipleFound` rule was
re-enabled.

Bug: T177809
Change-Id: I6fc2ec9cc35e6bac5a7c44d94b0f1b1b40e6dba5
2018-01-22 16:27:07 +02:00
WMDE-Fisch 9635657ab4 When running Selenium tests, use wd/hub
Now it works on Mac, Windows and Linux.

Change-Id: Idf984c89f541a44ad522ff4d765dc58ada407797
2018-01-18 15:02:42 +01:00
Max Semenik 62703e4dc8 Don't use deprecated DatabaseMysql
Bug: T120333
Change-Id: I3150bcd9aeefa154fc064bcc8078419521e6340c
2018-01-16 10:58:52 -08:00
Željko Filipin 58e9dda85c ESLint parserOptions is reduntand when es6 env is used
Bug: T171848
Change-Id: I27ad1fc514d7420f18601990beaf1411cd6d8687
2018-01-11 14:03:09 +01:00
Željko Filipin 30511cccdc Selenium test: alerts and notices are visible after logging in
The first Selenium test in Node.js using WebdriverIO.

Bug: T171848
Change-Id: Ie6bdc0f164e24c35db8a922df57428ec4d5452d3
2018-01-05 15:16:22 +00:00
Amir Sarabadani 30a5b88ea1 Use ExtensionRegistry instead of class_exists
Bug: T183096
Change-Id: I963704cdcfdbc97727f435eb16998c16c692ed01
2017-12-29 00:12:30 +01:00
Umherirrender 08cb7a470a Change doc type from DatabaseBase to IDatabase
Change-Id: I853b7cef85fdd77c28a947a8f3601f84ba17359a
2017-12-22 23:20:13 +01:00
jenkins-bot 611fdde4d9 Merge "Remove Ruby browser tests" 2017-12-22 11:54:46 +00:00
daniel 774610c0d4 Check for IDatabase (not DatabaseBase) in tests
Change-Id: Ia94fcae2a1dd28761b4e2f40fa1491f8401ad491
2017-12-21 19:52:10 +00:00
Matthew Flaschen 47c45866de Remove Ruby browser tests
The continuous integration infrastructure for these is being removed
(or never existed), and our team decided not to invest the time to
convert them to node.js.

Bug: T171848
Change-Id: I0faeecb2635f24c40c83aa689b670e69aa381431
2017-12-20 12:29:01 +01:00
David Barratt 6593a0a427 Prevent loading or saving of zeros in the database.
When intval() fails, the function returns a zero. We should remove
the failures from the blacklist.

Bug: T178512
Change-Id: I89ad680a287da16c2fbd6aa4d53a725142429144
2017-11-17 12:34:54 -05:00
Ed Sanders 892ba8e5fe build: Update eslint and other linters
Change-Id: I68b74742bea0c3d4c8e359fd7850beaa6bbc4190
2017-10-17 13:53:08 +01:00
Roan Kattouw 98370e8c83 ContainmentSet: Use strict comparison for array_search()
Otherwise, if $list->getValues() contains the number 0,
any non-numerical string will match, because 'foo'==0 is true.

This, in combination with a broken maintenance script that had
inserted 0s into some users' blacklist, broke all notifications
for those users.

Bug: T177825
Change-Id: If8700b4d0de0fdba876eb9d5cc4997e185dfeb3c
2017-10-14 16:31:13 -07:00
Umherirrender eba147a1b4 Always return false on EchoUserNotificationGateway::markRead
Also rename some variables.
$res indicate a ResultSet, not a bool

Change-Id: I4f0276cbe01a0391b4bd2616e111067b40363fea
2017-10-06 22:22:33 +00:00
libraryupgrader 7a23ddf4b0 build: Updating mediawiki/mediawiki-codesniffer to 13.0.0
Change-Id: I7b19fab3b1100c4973600ec95ee24160e141c5ac
2017-09-24 09:49:43 +00:00
Brad Jorsch 1f9eedf40f Remove reference to deprecated IDatabase->nextSequenceValue()
The method was deprecated and made unnecessary in Ib308190c.

Change-Id: I47aca6a7c77821119f52e639d0e74a1e6302532a
2017-09-06 13:05:14 -04:00
Željko Filipin ffaf7586dd Rake test target now runs RuboCop, RSpec and Cucumber/Selenium tests.
Bug: T164479
Change-Id: I73a075f1aa8ce3d6321f5b1eeb62fe27d1d021f0
2017-09-04 16:02:48 +00:00
Kunal Mehta 9095d5bcb5 Use namespaced ScopedCallback
The non-namespaced version is deprecated since 1.28

Change-Id: Iac0b120ccda77065a480e9461e7fcbd19d55f1db
2017-08-21 14:05:11 -07:00
MusikAnimal fdd1fe6d22 Duplicate new table from core, patch 349457
With 349457, anytime a revision is created, a corresponding record
is created in the new ip_changes table. This may cause tests to fail
if they don't drop the ip_changes table between individual tests.

https://gerrit.wikimedia.org/r/#/c/349457/

Change-Id: I48f0b64f19f9582b40540fa1b42a39d281979625
2017-08-11 15:51:03 -04:00
Kunal Mehta aaf061c725 build: Updating mediawiki/mediawiki-codesniffer to 0.9.0
The following sniffs are failing and were disabled:
* MediaWiki.Commenting.FunctionComment.ExtraParamComment
* MediaWiki.Commenting.FunctionComment.MissingParamComment
* MediaWiki.Commenting.FunctionComment.MissingParamName
* MediaWiki.Commenting.FunctionComment.MissingParamTag
* MediaWiki.Commenting.FunctionComment.MissingReturn
* MediaWiki.Commenting.FunctionComment.ParamNameNoMatch
* MediaWiki.Commenting.FunctionComment.WrongStyle
* MediaWiki.FunctionComment.Missing.Protected
* MediaWiki.FunctionComment.Missing.Public
* MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName
* MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment

Change-Id: I8401abf121a7413fa191d7bc535e0ddd6cf8c3f7
2017-06-22 14:13:28 +00:00
Kunal Mehta 5d2cde1022 Implement per-user notification blacklists
- Disabled by default, is a gated preference by wg variable
- User specifies blocks in Echo preferences
- Uses a TextArea with username separated by new lines as input
- Still allows notifications to come through on a user's talk page
- Cache the blacklist and whitelist

Requested at
<https://meta.wikimedia.org/wiki/2016_Community_Wishlist_Survey/Categories/Miscellaneous#Allow_users_to_restrict_who_can_send_them_notifications>.

Bug: T150419
Change-Id: Ibf548da4aa600bdc7848cba1947436e56ac48a4a
2017-05-24 16:09:04 -05:00