Commit graph

279 commits

Author SHA1 Message Date
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
Brad Jorsch d7a77b0aba Fix usage of $db->nextSequenceValue()
The return value from the method is only suitable for passing to
$db->insert(). To get the inserted ID, you need to call $db->insertId()
even if $db->nextSequenceValue() returned non-null.

Bug: T164900
Change-Id: I466fd372804927b3ad72125c7a69d253bd7a24f8
2017-05-10 17:46:07 -04:00
Ed Sanders 571223a206 build: Update eslint to 0.4.0 and make pass
Change-Id: I30dd0e1ee56dbcbb7c60608a401179e2d37557ff
2017-05-04 20:57:37 +00:00
jenkins-bot a9d4fb257b Merge "Echo should notify user about mention on wikitext page" 2017-05-03 16:22:44 +00:00
jenkins-bot a3fd1af768 Merge "Echo should notify a new user with welcome message" 2017-04-26 16:11:02 +00:00
jenkins-bot 80cdc85d67 Merge "Switch TestingAccessWrapper to librarized version" 2017-04-20 19:28:11 +00:00
Gergő Tisza 39ba452b32 Switch TestingAccessWrapper to librarized version
Bug: T163434
Change-Id: Ib5aeffb793cfd84201ca397a96689e0b81f3265f
Depends-On: I52cc257e593da3d6c3b01a909e554a950225aec8
2017-04-20 11:34:57 +00:00
Bartosz Dziewoński 0d23ba8bbe Fix browser tests
Some browser tests were broken by 945fccf009.
The badge element is now technically rendered offscreen, with only the
:before and :after pseudoelements being onscreen. Because of this, Selenium
thinks that the badges are invisible, and this breaks various things in
totally unexpected ways.

* article_page.rb: Store references to the parent <li> elements of badges.
  This might not be necessary but I don't know how to access them otherwise.
* badge_steps.rb: When clicking the badges, click the parent <li> element
  rather than the not-really-invisible <a>. Effectively, the <a> gets
  clicked anyway, since they overlap.
* no_javascript.feature/no_javascript.rb: Wait for page load before
  checking that we're on the right page. The wait is no longer
  implicit, since Selenium thinks we're clicking the <li> rather than
  <a> (links are special-cased).
* notification_steps.rb:
  * Check whether the badges exist on the page, rather than whether they
    are visible.
  * Use a weird hack to read badge text. Apparently you can't read the text
    of elements that Selenium thinks are invisible.
    http://stackoverflow.com/questions/20888592/gettext-method-of-selenium-chrome-driver-sometimes-returns-an-empty-string

Bug: T161941
Change-Id: Ic6bcd1088249109e49a47cc9007e6ee002d3d8ba
2017-04-19 22:27:02 +02:00
Elena Tonkovidova 286aeed94a Echo should notify user about mention on wikitext page
Bug: T146916
Change-Id: Id25dbc289fd3fe0fcb92bc4ec85f7851dc72026e
2017-04-18 16:53:18 +00:00
Elena Tonkovidova 69dd622894 Echo should notify a new user with welcome message
Bug: T146916
Change-Id: I5656286c91b2407a4d481531e563b41d245b5b14
2017-04-18 18:30:33 +02:00
Leszek Manicki e45705fd84 Run MWEchoThankYouEditTest on clean DB tables
Other tests (possibly from other enabled extensions) could also,
by chance, create Echo notifications for the user MWEchoThankYouEditTests
uses. In order to those tests be reliable, they should make sure
there is no notification data in the database prior to running tests.

Bug: T161087
Change-Id: I870a50b1f831795731235fa8ec97477b3e470b50
2017-03-22 16:32:49 -04:00
Ed Sanders d4d325e7e6 Use words for describing notification counts in HTML text node
The text is hidden by CSS so this will not affect regular users.

Bug: T160277
Change-Id: Iabb557a6ea2de82b488a5a40c9b5fd966270f1b0
2017-03-12 19:37:23 +00:00
WMDE-Fisch eb81a1c0f1 Avoid unintended mentions when changing content
When content is changed and the change contains the signature
of the user, the method checking for reasonable mentions in
that changes did not consider multiple signatures.

The patch fixes that and adds a test for it.

Bug: T154406
Change-Id: I86303f42e97d16c68e3235b0e2d13542ceedf1fe
2017-03-01 11:58:08 +00:00
jenkins-bot 387d0dc010 Merge "DiscussionParserTest only create users when needed" 2017-02-24 13:17:03 +00:00
WMDE-Fisch 71e3b66cc0 Remove test for internal diff engine acceptance
Since the internal diff engine is now always used this test
seems to be unnecessary.

Bug: T93625
Change-Id: I536474dc6231138293c9efc813a1bc2cc1e6f3b0
2017-02-24 11:32:37 +00:00
addshore 6d4021915f DiscussionParserTest only create users when needed
This speeds up the tests from 2 mins to 50 seconds for me.
(with a slow setup, no caching etc.)

Bug: T158120
Change-Id: I8adb6c8fe783d1be8841a1139bb141da3b046f9d
2017-02-24 11:10:22 +01:00
Umherirrender 3a72d87838 Remove unused DiscussionParser::stripIndents
Change-Id: I75fbcae70655c6db2873fd5e22d11a3c2cbf2f84
2017-02-22 18:05:07 +01:00
WMDE-Fisch d6f011aa1a Fix mentions failing editing empty pages
For the used diff engines an empty/new page is equivalent
to an empty line. When adding content that includes an
empty line the content will be split into two parts. The
interpreted diff will then consist of one addition, one
copied line and another addition.

Is the ping in the first addition and the signature in the
second addition the DiscussionParser does not send mentions.

The patch introduces a special case when interpreting diffs
if content is added to empty content. This will also skip
execution off diff engines since the interpretation is trivial.

Bug: T155998
Change-Id: Id5e44bc3245940c1f77c80f036db637756542552
2017-02-10 14:39:13 +00:00
Stephane Bisson 3e3c82a167 Use fake timer in Echo unit tests
Freeze time to avoid a race condition
where a second is ticking in the middle
of a unit test.

Bug: T154188
Change-Id: I6b0c8ae06360e6da016d97361cc2ccdeaf2e4343
2017-01-04 16:43:55 -05:00
Stephane Bisson 61b602e961 Fix unread notification count caching
Purge all cache when unread count changes and
repopulate on read.

Also fix client-side estimation when
marking a foreign notification as read.

Bug: T151389
Change-Id: I62def3d40a5640e26c234bb0335bc506dbf864a0
2016-12-09 09:23:59 -05:00
James D. Forrester 8c810dff48 build: Update mediawiki/mediawiki-codesniffer to 0.7.1
Also added "composer fix" command.

Change-Id: I25cb61b3b92798f1259d1575a336e2b056d5764f
2016-12-05 15:54:30 -08:00
Ed Sanders c8d24ebd17 build: Replace jscs/jshint with eslint
Change-Id: Iee1d1b20ed31e636bfb8fc8cf9b18ff328bf608c
2016-11-23 15:25:59 -08:00
Moriel Schottlender 7b4bb11c2a Add proper QUnit tests
Change-Id: I7a4abf068a32d9cf65eb464eb036f72f319c54ff
2016-09-29 15:28:30 -07:00
Moriel Schottlender 2875e3e5dd UnreadNotificationCounter should always normalize the count
Whether we estimate or not, the actual stored count should always be
normalized within the range of 0-cap. Estimation should always skip if
the current count is at the cap; in that case, the count can only be
changed when we get the value from the API through setCount() (used
when the value is known, rather than estimated.)

Change-Id: Ie8b81a4433e8254ee0e90f59e5b25d727158eecf
2016-09-23 16:22:56 -07:00
Jakob Warkotsch 3da89ea4d9 Send notification for mentions on changes
This sends out a notification when a user gets mentioned in a change as
long as a signature is added in the same section.

Bug: T138938
Change-Id: Ie183fbb8150bd9451a5b0a9fea0227e3241b26a0
2016-09-14 12:36:22 +02:00
jenkins-bot 5fd9831c07 Merge "Send mentions when editing multiple sections in between sections." 2016-09-14 10:06:36 +00:00
Catrope bba984c002 Revert "Make seen/unseen badge more consistent across wikis"
Has bugs, and will likely cause deployment problems.
This'll need to be reverted in wmf.19 at least
until we fix it up.

This reverts commit 00e0b9f45d.

Change-Id: Ia9d220ebcb607f96dee6bc856755305ed8501fcc
2016-09-13 14:21:32 -07:00
Stephane Bisson b3c07eedeb Remove etp_user
Target page entries used to exist for each user
that was notified for an event. They were
removed as the notifications were marked as read.

Now they remain so that the association between
pages and events can be used for moderation
regardless of the notifications read status.

This patch removes everything about
echo_target_page.etp_user from sql and php code.

Bug: T143959
Change-Id: Ib57510e6b0e9202a7e035f8ea59955dca8a0b24a
2016-09-09 09:32:28 -04:00
Moriel Schottlender 00e0b9f45d Make seen/unseen badge more consistent across wikis
- Add a 'hasUnseen' data to the xwiki bundle so the badge can
  consider its value when changing its color even without the
  bundle being opened.
- Check and store seenTimes from all sources that the xwiki
  has in a new JS object that the SeenTimeModel can store

Bug: T134855
Change-Id: Ifdcee88b4378cdc7acb4ae5c0cbc60b76339757e
2016-09-08 12:40:15 -07:00
WMDE-Fisch 4ac1711be8 Send mentions when editing multiple sections in between sections.
This patch fixes mentions not being send when multiple sections were added
in between sections.

Since we only want to send mentions when userlinks and signature are present
in the same section a new method was added extracting sections and the related
content from an addition. The results are checked whether a section content
contains a signature and might be relevant for mentions.

Bug: T141863
Change-Id: I434c664552bbadbeef6e897e20703e813f5a4c52
2016-09-08 15:15:14 +02:00
Stephane Bisson c75d974004 Provide title when parsing wikitext
Bug: T141460
Change-Id: I802c9c4bf964a060e44f25a487b5aec6f7d8c6b6
2016-09-01 16:48:56 -04:00
Roan Kattouw fb1afa15e8 Fix call to irrelevant function in testFetchByUserOffset
testFetchByUserOffset should be testing fetchByUsreOffset(),
not fetchNewestByUserBundleHash().

Change-Id: Ie8c29714c4054999d14ebf0a3884912950be3837
2016-08-25 16:55:17 -07:00
Roan Kattouw ce3d6b2f49 Remove unused method EchoEventMapper::fetchByUserBundleHash
Bug: T143763
Change-Id: Iad63e8866eeccf316b3efe3a44888256c0c407d8
2016-08-23 19:22:01 -07:00
jenkins-bot f48b44bacd Merge "Log edits in multiple sections that could trigger mentions." 2016-08-19 22:00:43 +00:00
jenkins-bot d35c5825d8 Merge "Always use php based diff in EchoDiscussionParserTest" 2016-08-19 15:11:38 +00:00
addshore 5dd9858f4e Always use php based diff in EchoDiscussionParserTest
The previous check here meant that different
setups could run these tests with current diff
engines thus these tests could result in different
successes / failures.

Change-Id: I62a52dee1dd1ecd2ebd36e1aa540245e90a57ddd
2016-08-19 13:34:54 +01:00
WMDE-Fisch 66ecc1f0e7 Log edits in multiple sections that could trigger mentions.
This patch logs multiple section edits that could trigger mentions.

Since we only want to send mentions when userlinks and signature are present
in the same section a new method was added extracting sections and the related
content from an addition. The results are checked whether a section content
contains a signature and might be relevant for mentions.

Bug: T141863
Change-Id: Ib06cd855b2c7fbd51d8ab6602882cb38aadf8350
2016-08-18 14:58:00 +02:00
WMDE-Fisch c81e1b93d2 Fix mention failures not beeing sent.
While manual rebasing the bundle patch the wrong
line was removed.

Also improves tests to check for notifyAgent.

See I1069aeb5523db8710da4e8e21065bf447d031e3c

Change-Id: I33ddeccea153d6f6ae97e5c60e8b47dc24fb4833
2016-08-15 14:25:22 +02:00
jenkins-bot cf3e03edc9 Merge "Revert "Allow self mentions"" 2016-08-12 01:48:03 +00:00
Mattflaschen 59568789fa Revert "Allow self mentions"
This reverts commit 0e23463185.

Change-Id: I4389c7b93b2bbc117931a263b58a8f1cc30dca6c
2016-08-12 01:41:08 +00:00