This code will be enabled when Iba1d7863171268066bf7597182c57a0a2041497f
relinquishes the responsibility for rendering the Echo notification badge
and wiring up of the related JS.
It makes 3 assumptions:
1) Minerva will expose a VERSION property on the skins.minerva.scripts module
to tell Echo it can begin control of the functionality
2) A new hook `SkinMinervaReplaceNotificationsBadge` will run on the server side
allowing Echo extension to render the Notifications badge in Minerva.
3) A new client side hook (echo.mobile) will fire whenever the Echo dialog is opened or
closed.
All code relating to Echo inside MobileFrontend and Minerva is
moved here.
CSS for the modules is kept in Minerva as skinStyles
This code remains dormant until Iba1d7863171268066bf7597182c57a0a2041497f lands.
It pre-registers a "to-be-created" hook SkinMinervaReplaceNotificationsBadge that
substitutes the Minerva badge.
It also watches the export value of skins.minerva.scripts for a VERSION value - when
this appears it will take the signal that it should manage the frontend code.
In the new system the mobile specific code is limited to the mobile version of
Minerva. The desktop version of Echo loads on Minerva desktop - presenting an
opportunity in future to consolidate both implementations to use the same component.
The mobile version of Vector and Timeless for example will load the mobile overlay
(with existing styling issues that we don't need to worry about right now given
we don't officially support skins other than Minerva as mobile)
Testers:
* Check require( 'ext.echo.mobile' )(); inside initMobile
inside ext.echo.init does not fire until
Iba1d7863171268066bf7597182c57a0a2041497f is checked out.
Depends-On: I1a66939d2b596094b419de40b370e79f09c85581
Bug: T221007
Change-Id: I09c27a084100b223662f84de6cbe01bebe1fe774
With I40fc8a709de96aceee14a10c973cd5b0a9a6f063 UserrightsPage
now requires the PermissionManager service to be injected.
Change-Id: Ibf3728c1e143787fb35b88ad8a8d5aabc8fadcb8
As noted in Ic22075bb5e, UserNotificationGatewayTest relies on the presence of
globals. When Ic22075bb5e is merged, UserNotificationGatewayTest will fail in
CI. This patch injects the configuration object into UserNotificationGateway.
Change-Id: I9c15a588a76a41a3ebfb59dac7f0761f756008ff
The hook (SpecialMuteModifyFormFields) is used to append
the option to mute/unmute echo notifications from a specified user.
Special:Mute handles posting and saving the fields, the only
requirement is that the field name is the same as the property
that wants to be modified, in this case 'echo-notifications-blacklist'
Bug: T220163
Depends-On: I2b3eee0802cb086091f35ecce13ae77a8e7d518d
Change-Id: I77b3ccfdce9b501eb8ecd58c0d7bbecb78029a7e
Changed `selenium-daily` npm script to only run tests tagged `@daily`
and removed `it.skip` on tests failing in beta cluster.
Bug:T227009
Change-Id: Id2edbfd941df098d326fa30ed9dc9f68e228f021
PHP doesn't care much about the name (in terms of case sensitivity)
but I think we should make sure the names of the method should be as
they're in their definition.
Change-Id: I6e38d8be64efaec4200471f2d3007275d7ddecec
To my knowledge in all the places I'm touching in this patch the new
code is functionally identical to the old one.
Change-Id: I0ffa96d2f9cb9bf932f68b689244051c96c17ad9
Class Revision is deprecated and in this patch, replaces
usage with appropriate classes; RevisionRecord, RevisionStore,
etc.
Bug: T221163
Change-Id: Icfc85167a636bef95daab236ab80113c1a3cf41b
When deleting echo_notification or echo_email_batch rows, also delete
the corresponding echo_event rows if no other echo_notification rows
or echo_email_batch rows refer to them.
Bug: T221262
Change-Id: I416ff107bd000a0cfac102408c993f8bec2d0286
Added a test that creates a new user and checks that they have a welcome message when notices is clicked.
Bug: T217051
Change-Id: Ia5808ebcedcd91f740cce646f4aa0576ef6d378f
* Clear echo_event before the test. Otherwise it contains
a 'thank-you-edit' event that offsets everything.
* Use standard $this->db
* Use standard ~~~~ signature
Bug: T67336
Change-Id: Idd09aa107d01038d03b689d9086f65a9fb7b653a
It was sort of checked in an implicit and roundabout way, in the sense
that the preferences page checks this and forces the relevant
preferences to on or off. But this was difficult to discover, and it's
not clear if this works correctly when defaults change.
Instead, explicitly check whether the requested notify type is available
for the event's category. Also rewrite the entire method to use
array_filter().
Change-Id: I9502a42fc705b2e56ef5edab433f1804f2924359
When pages are deleted or undeleted, their associated
Echo notifications also need to be marked as deleted
or undeleted. This is done by looking up the
echo_target_page table.
With this change, echo_event.event_page_id is also included
in the search. This way, all the events that don't use
target pages are also moderated when needed.
Bug: T217452
Change-Id: I277fca68ce088ab564e76ed9dfb2134ab3be4c4a
When the location on disk of an icon is known,
load its content and turn it into a data uri
for the <img> tag.
Otherwise (when it's only configured with a url),
use the url in the <img> tag.
Bonus: the rasterized icons were a bit blurry
and they are now crisp.
Bug: T55479
Change-Id: I8b5d7f09d8181f22927b8d4712505212ea1a10b1
PHPUnit 4 on HHVM is unable to create a mock for a class that uses variadic
arguments in one of its methods. Details at I0e027f5ec66 in core.
To work around this, IDatabase will continue to document it the old-fashioned
way so that Phan can analyse it correctly, and also so that PHPUnit can
mock it properly.
Change-Id: I4b8f2b8a8bb54b71d8b4836c3663f1a646ece1bd
This trait was using private fields from its host classes
($this->event, $this->language). It created a weird coupling
situation where the host class uses the trait and the trait
uses the host class. Effectively a circular dependency.
Also, phan is complaining about it in
I65ae6adc10941c05a2646e551b1baa829e4e8654
Change-Id: Ib2796b7ca62ecd7ece19583d7ca83e4252a5d878
These work now that I4c0d629da254ac2aaf31aae35bd2efc7bc064ac6 is merged.
Bug: T194632
Bug: T218388
Change-Id: If8031d488a67c423c7d4f4d3bf0f5e4126d3212a
Note, per T194632#5018823 it appears that replacing instances of
Benutzer:Schnark with User:Schnark cause the test to pass, so we should re-add
this test case once we've figure out why that's happening.
Bug: T194632
Change-Id: I8000c037c515283e46d4b530f8d91bdef35c7ace
Also remove fetchNewestByUserBundleHash() because it's now unused,
and remove the echo_notification_user_hash_timestamp index which
existed specifically to support that function's DB query.
Bug: T143763
Change-Id: I74be8f156bc14d0e189d328953d17dc26cdb697b
No longer used in the new bundling system.
Also removes indexes that contain bundle_base.
Bug: T143763
Bug: T131415
Change-Id: Ibf94cdc471a11cb14995fee6a55af0d227b50aa5
Added a test that checks if the flyout window appears when the alerts badge is
clicked.
Bug: T217051
Change-Id: I5afbb6928a42ddf1c71dec13c4559189d7c31f28
This patch contains a series of different clean-ups in test classes.
Some documentation is added as well as soft and hard type hints. Note
all this is exclusively done in tests. So if the CI is fine with it,
it can't be wrong. Right? ;-)
Change-Id: Ibcf1f65f48ac0fb41837c47672dddfd70302e9fd
The @expectedException annotation got deprecated in PHPUnit 7.5, and
removed in PHPUnit 8.0. This was done because the annotation does have
two disadvantages:
* The class name is encoded in string, where it is not easy to find for
all IDEs and tools.
* it did not allow to say exactly *when* the exception is expected.
Change-Id: I96862a18874f36355e817accd64d8703c1965c86
The codebase already used the …::class feature in many places. So this
is more for consistency than anything. The …::class feature makes it
much easier to do refactoring in the future.
Note this patch is exclusively touching tests. That should make it
relatively easy to review this. As long as the CI is fine with it, it
should be ok. Right? ;-)
Change-Id: I4d2adee76b4adbc83b2061161fd4e863ba833fcb
Specify which notification types allow notifying the event agent in
$wgEchoNotifications, and stop specifying it in the event_extra data.
Putting 'notifyAgent' => true in event_extra will still work, but is
discouraged.
Change-Id: I4f558654ec23757dd4ecd6986eb3e9a5593f5386
These are updated in deferred updates and should not rely on the same
User instance being used in those updates. This also avoids convoluted
logic in User to set the new edit count for various cases.
Change-Id: I0ad3d17107efc7b0e59f1dd54d5733cd1572a2b7
* Reduce responsibility of resolve() methods to only supplying
the resolves values.
Moved logic for populating the cache and clearing the queue
to the base class, and made 'lookups' private.
* The second parameter to LocalCache::add() is unused, and never passed.
Removed to avoid confusion.
* The getTargets() method is unused. Removed.
* The getLookups() method is unused. Removed.
* The internal 'lookups' member was being used both for its keys and its
values, but never at the same time. This seemed risky, especially in
EchoRevisionLocalCache::resolve() where the associative array was passed
directly to the 'where' clause of IDatabase::select(), which shouldn't
espect keys when creating the 'IN' clause.
Using only values would keep value types flexible, but would require
use of the less efficient in_array().
Keeping both keys and values and calling array_values() would work.
Using only keys also works and is simpler, so long only ints are used.
* The tests were swapping 'targets' MapCacheLRU with a HashBagOStuff.
Following-up 4939bff7, this was forgotten, but works because the two
called methods (get and set) exist in both, but still seems odd.
Fixed by using TestingAccessWrapper to act on the existing object
instead of swapping it out.
* Improved tests by asserting more of the observed behaviour and impact.
Change-Id: I530eeac8bf3b407b8c633e0e20c7d35cc49f7a9f
This fixes some issues I found while updating this code base, e.g.
this removes types a method really does not return.
Change-Id: I19457e7bf88945eec958bf53e0b76a7585715a45
There are about 200 of such generic "array" type hints in this code base,
the majority in @param tags. I started with what I found most relevant:
@var and @return tags. I might continue working on this later, but
wanted to stop for now to keep this patch moderately small.
Change-Id: Iff0d9590a794ae0f885466ef6bb336b0b42a6cd3
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
Also test it more meaningfully by setting up a mock database and
asserting that the right DELETE queries are issued.
Change-Id: Id39723b92118e98d9c9f0cd7381e9396dce67c17
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
Makes so many things simpler and robust.
Bug: T198935
Change-Id: Ia836f8f497cae8599f85cf86a7f6b299cd012e81
Depends-On: Iff63da0d215585cfcf083e7f7ec8ed45d5b77301
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
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
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
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
When intval() fails, the function returns a zero. We should remove
the failures from the blacklist.
Bug: T178512
Change-Id: I89ad680a287da16c2fbd6aa4d53a725142429144
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
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
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
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
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
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
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
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
Freeze time to avoid a race condition
where a second is ticking in the middle
of a unit test.
Bug: T154188
Change-Id: I6b0c8ae06360e6da016d97361cc2ccdeaf2e4343
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
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
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
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
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
- 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
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
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
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
While manual rebasing the bundle patch the wrong
line was removed.
Also improves tests to check for notifyAgent.
See I1069aeb5523db8710da4e8e21065bf447d031e3c
Change-Id: I33ddeccea153d6f6ae97e5c60e8b47dc24fb4833
Avoid duplicate by looking if the notification
already exist.
Change-Id: Ie519d13cd0ab03919f70da90d58c82a214c74b49
Depends-On: I79194c41d6b2fd84ad658909a2941d9d3d28d94e
Bug: T128249
Adds new notification type and icon for successful mentions.
Complements existing test to consider successful mentions.
Bug: T139623
Change-Id: I7a77b40e8b14c95cadb9023065ee916247feacf9
- Adds global "$wgEchoMentionStatusNotifications"
to activate mention status notifications.
(must be set before extension is loaded)
- Adds notification types and icon for some basic mention
failures.
- Adds failure and stats for anonymous IP.
- Adds check for links to user subpages.
- Adds config var for max mention notifications allowed.
- Bundles notifications.
- Refactors test for the event generation and adds tests
for unknown users, user links with subpages and failures
for too many mentions.
Bug: T136326
Change-Id: I388bdc3714feb9a2865a5ad10dbeabb0a6a09a4f
Followup to I639b9d9906d3ff37021cb9b5ed3cb401354b5bd9
* Remove deprecated formatter
* Log a warning and fail gracefully
when an event type does not support
Echo presentation model.
Bug: T121612
Change-Id: Ic5712c4ce265b6faabce7a4028b4294fe3c73f18
To allow individual notifications to be
marked as read/unread or moderated,
bundles are created by grouping associated
notifications when they are fetched for display
instead of when they are created.
From a product perspective, this change doesn't
introduce moderation or expandable bundles but
it counts each individual notifications.
For instance, the bundled notification
"3 new topics on PageA" now counts as 3
notifications.
Bug: T93673
Bug: T120153
Change-Id: Iacd098573efd92bb1e3fcd7da4cd40cea9522f15
This script was supposed to be run in production in 2013, but that
never happened. It was also never added to update.php.
* Use makeTitleSafe instead of newFromText, for correctness
* Fetch the columns that the update generator needs
* Replace wrapper for private method with closure
* Make the maintenance script logged
Bug: T136427
Bug: T50059
Change-Id: I6c2972120189f035483b5ca49610c008c4ba2c88