Commit graph

1110 commits

Author SHA1 Message Date
Roan Kattouw d85252b97d DiscussionParser: Fix type hint fatal from getUserLinks()
Instead of returning false when no links in the user namespace are
found, return an empty array. They're both falsey, but this way we don't
break the type hint in generateMentionEvents(), which is the only thing
that getUserLinks() is used for anyway.

Bug: T239275
Change-Id: I93b320be07cfdae68c5e296b2caa62ea4fae5ff2
2019-11-26 17:57:16 -08:00
jenkins-bot 4b8eb663df Merge "build: Updating mediawiki/mediawiki-phan-config to 0.8.0" 2019-11-25 21:01:26 +00:00
Max Semenik 36af0f2cf1 Stop passing objects by reference
Bug: T193950
Change-Id: Ie8a2302137c5b5fc67862031ffe244c50769fa1f
2019-11-18 23:23:22 -08:00
Umherirrender f62ab66363 build: Updating mediawiki/mediawiki-phan-config to 0.8.0
Bug: T235049
Change-Id: I93844dc6fae8a3dca3ced591d43caa2f994ba2f1
2019-11-18 20:03:13 +01:00
Thiemo Kreuz 048a9e84c1 Remove duplicate private property from NotificationDeleteJob
Every job class does store it's properties in the $this->prop array
anyway.

Change-Id: Ib1c810ee367a2771e19fac25056c9e7bef22cb01
2019-10-31 18:18:08 +00:00
jenkins-bot c8eea3eb35 Merge "Add strict "array" type hints to code expecting arrays" 2019-10-28 08:48:51 +00:00
jenkins-bot 6e48f16af6 Merge "Use READ_LATEST constant and fix a soft type hint" 2019-10-24 18:37:13 +00:00
Thiemo Kreuz 0efef4faf3 Add strict "array" type hints to code expecting arrays
I found candidates for this by looking for parameters names that end
with a plural "s".

Change-Id: I61c706eb4dfbdadceb0129afd724e6ce1eb4f4a8
2019-10-24 15:18:58 +00:00
Thiemo Kreuz d79dd00e01 Use READ_LATEST constant and fix a soft type hint
Change-Id: I2123c5efe01a5b42daeec9c7b0eefce089864657
2019-10-23 12:45:51 +02:00
Thiemo Kreuz 229c3d0fdd Remove non helpful (auto-generated) comments
None of these comments explains anything that wouldn't be obvious
from the code itself.

Change-Id: Ibcf50d401999ae76f315df2d2d27097a39f41bbd
2019-10-23 12:31:35 +02:00
Marko Obrovac 6ae3efc1c3 SeenTime: Do not set the cache key to Unix epoch
Now that seen times are TTL'ed, there is little sense/incentive to set
them in the cache to the default value, since we assume the default
value if they're not in cache (which is being set here). Therefore,
setting them only increases the cache size without any gains.

Bug: T222851
Change-Id: I78a0045e4a53653196114da81c2d60328e78c269
2019-10-18 14:23:28 +02:00
Roan Kattouw ff165c0003 Make EchoSeenTime cache entries expire after 1 year
These entries weren't TTLed at all, and so we had millions of records
for inactive users that were being stored forever. If a user doesn't
view their notifications for a year, it's OK for their notifications
badge to go back to the unseen state until they click it.

(The fallback behavior on a cache miss is to act as if the seentime is
the UNIX epoch, which means that any unread notification they have is
more recent than it, and is considered unseen.)

Bug: T222851
Change-Id: I99230d2351b40751a3f2f5123c5f38693120259e
2019-10-18 12:05:52 +00:00
Roan Kattouw 79ee7582f2 Make EchoSeenTime cache type configurable
Defaults to MainStash, but can be configured to use a different cache
backend by setting $wgEchoSeenTimeCacheType to a string that keys into
$wgObjectCaches.

Bug: T222851
Change-Id: Ifb935cc8be4618f7794ee79a234fc66d5cc5728a
2019-10-18 11:32:03 +00:00
Kosta Harlan ccab496734 Remove PhanTypeMismatchArgument from call to appendContent
Breaking in
https://integration.wikimedia.org/ci/job/mwext-php72-phan-docker/16324/console

Change-Id: I9a6b06158d9083317aea46510c0c47980a25e50a
2019-10-16 10:53:12 +02:00
James D. Forrester abaff73626 build: Upgrade mediawiki-codesniffer to v28.0.0
Change-Id: Ib66b0ad1b3929bf7e49eb40a3d5463b0d8b2280b
2019-10-10 09:29:24 +00:00
jdlrobson d3c0494a17 Dormant mobile notifications overlay lives in Echo
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
2019-10-09 12:36:11 -07:00
Roan Kattouw 83f8949dc5 Stop exporting wgWikiId, use wgWikiID from core
Update usages of the variable for the capitalization difference.

Depends-On: I4d289267991f1f9a8e0710ec6ee5a2131306c510
Change-Id: Ie49e898b33765aa0723501be8c0c30622e7cbd2f
2019-09-25 18:14:40 +00:00
Kosta Harlan 15d36ccae5 Remove global usage in UserNotificationGateway
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
2019-08-30 22:58:41 +02:00
DannyS712 0b237983b8 Use Special:MyLanguage in API help links
Bug: T231269
Change-Id: I76e1e257616d8e2a43bcbe9efadead71a09bb058
2019-08-27 06:14:51 +00:00
jenkins-bot 358bdad695 Merge "Define preference for poll updates" 2019-08-06 23:14:49 +00:00
shivanshbindal9 2528e3394f Define preference for poll updates
New preference added so that user can set
* Displaying (n) total unread count in the title
* Displaying notification snippet for incoming notification

Bug: T229732
Change-Id: I35eb68dedf1e087b4668bfec404935f1244b3d0b
2019-08-06 19:42:49 +05:30
Matěj Suchánek 19c55cd7ca Improve EchoPresentationModelSection
Add documentation and recommendation to one public method
and make getTitleWithSection safer.

Change-Id: I9c17032a80e736751d21c16ca0178b54c498bded
2019-08-02 12:24:59 +02:00
Roan Kattouw a3bfd725ea Bundle logger-related config vars with ext.echo.logger module
There's no real reason for these to be in MakeGlobalVariablesScript
because they don't really depend on the request context: they were being
omitted if the user was not logged in, but we can just check the user's
logged-in status in JS instead.

Bug: T221151
Change-Id: I2df6d7e061545d342bc3068dccd5ce2f6e85fe78
2019-07-23 21:48:42 +00:00
Roan Kattouw cf760b8d84 Use Config parameter instead of deprecated ResourceLoaderContext::getConfig()
Depends-On: Ia4666914e9b07f298ee5ae30ae8c70a3e83b0910
Change-Id: I4578bfc93d8a4615d54d99340ed9cceaa8bb76da
2019-07-18 15:30:41 -07:00
Roan Kattouw d378e4e3b9 Use packageFiles instead of startup module for config vars
Remove wgEchoMaxNotificationCount and wgEchoPollForUpdates from the
startup module and put them in the ext.echo.init module.

Change-Id: I03f9a3953aa97ead1a29c13a992a02404a6d0b68
2019-07-18 15:29:27 -07:00
Dayllan Maza b3df45dc34 Add option to mute/unmute notifications on Special:Mute
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
2019-07-18 15:47:24 +00:00
Roan Kattouw e6e7541531 MentionInSummaryPresentationModel: Fix PHP error
RevisionRecord::getComment() can return null. When it does, accessing
->text on it fails.

Bug: T226681
Change-Id: I069cd5d5bef51a3e2b8f4e7b50d478cf47f65e00
2019-07-15 17:06:15 -07:00
libraryupgrader 4bf8a6736a build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 24.0.0 → 26.0.0

npm:
* set-value: 2.0.0 → 2.0.1
  * https://npmjs.com/advisories/1012
  * CVE-2019-10747
* union-value: 1.0.0 → 1.0.1
  * https://npmjs.com/advisories/1012
  * CVE-2019-10747
* mixin-deep: 1.3.1 → 1.3.2
  * https://npmjs.com/advisories/1013
  * CVE-2019-10746

Change-Id: I6d3efdf65c207b98447565e2df6f0698aaa8ea6b
2019-07-14 10:57:49 +00:00
James D. Forrester 1b2c8eebfc build: Upgrade phan-taint-check-plugin from 1.5.x to 2.0.1
Bonus: unset loop variable after mutable foreach.

Change-Id: I652fe65e4691a92175569a72f081f4553c4459c5
2019-07-11 13:40:37 +00:00
jenkins-bot a32d18d73e Merge "Make Notification count update without page reload" 2019-06-18 23:39:41 +00:00
shivanshbindal9 43bff91c68 Make Notification count update without page reload
* MVC is used to change the count of notifications on header icons.
* The Widgets are loaded after 60secs or icon click, whichever occurs first.

Bug: T219222
Change-Id: I2d034a76d5c3abe55894dd1dd10e28713344c5bb
2019-06-18 04:49:59 +05:30
Derick Alangi f402ecd31f Echo: Fix case mismatch for function/method calls
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
2019-06-11 22:46:24 +01:00
jenkins-bot 21354c66a2 Merge "Remove badgeicon module, use OOUI icon instead." 2019-06-05 19:08:33 +00:00
shivanshbindal9 c86a1a5cf3 Remove badgeicon module, use OOUI icon instead.
Now that OOUI's "alerts" icon pack includes all the icons we need, we can use it and get rid of the badgeicons module.

Bug: T139779
Change-Id: I8218530ed2cdd2d81c1fc24509f36ea2b6742bd9
2019-06-05 12:29:17 +05:30
Stephane Bisson 1ebb8e3daa Don't add CommentStoreComment as plaintext params
Follow-up Icfc8516 and I3d997f9 (migrating from deprecated Revision
to RevisionRecord)

When generating 'edit-user-talk' events, if we don't have the section-text,
we use the edit summary instead.

Revision->getComment() returns a string but RevisionRecord->getComment()
returns a CommentStoreComment. As a result of the migration, an instance
of CommentStoreComment was put into the event 'extra_data' and later
added as a plain text params during notification presentation.

This patch proposes to
1) Make sure to add the comment's TEXT to the event
2) Test that the 'section-text' is a string before using it
   as a message parameter. This will cause faulty notifications to
   render without a body instead of erroring out. We could write a
   maintenance script to fix those notifications but I don't
   think it's worth it.

Bug: T223741
Change-Id: Ie3a1c59a43b0981ec42fc77e7ebb0e8bd132dbe2
2019-05-21 11:44:54 -04:00
Hashar e3ae1a62d0 Revert "Make phan ignore JsonSerializable redefinition"
This reverts commit 13956265c1.

The Wikimedia CI jobs running phan were installing mediawiki development
dependencies which might overlap with the dependencies from the
extension. Ultimately phan failed with:

includes/RemoteSchema.php:9
PhanRedefinedInheritedInterface
\RemoteSchema inherits abstract Interface \JsonSerializable declared at
internal:0 which is also declared at
../../vendor/jakub-onderka/php-parallel-lint/src/JsonSerializable.php:4.
This may lead to confusing errors.

If7171a6d46473b0bb05e3adaeb40229e7881c2b6 adjusts the CI configuration
to no more install MediaWiki core development dependencies and solely
relies on mediawiki/vendor.git. That prevents the duplicate interface
definition.

Bug: T223397
Depends-On: If7171a6d46473b0bb05e3adaeb40229e7881c2b6
Change-Id: I794fbffe59104f138802bc6ded1a9d9a58ba9437
2019-05-21 10:34:28 +02:00
James D. Forrester 980e67d338 build: Upgrade mediawiki/mediawiki-phan-config from 0.5.0 to 0.6.0 and make pass
Change-Id: Ifc83427ccdcfc34d33a667ffde5e0cec98a0a609
2019-05-19 13:33:12 +02:00
Roan Kattouw b31119ea19 Remove unused method EchoEvent::isDismissable()
Change-Id: Ibea0c85cf9dd13cc2b6f22d27e8e3e0b927256c0
2019-05-18 17:37:54 +02:00
Roan Kattouw 05499e0446 Fix fatal "Object of class CommentStoreComment could not be converted to string"
Bug: T221163
Follows-Up: Icfc85167a636bef95daab236ab80113c1a3cf41b
Change-Id: I92811ae9e383f431ef939b004c7d10126e051bbf
2019-05-09 21:35:03 +00:00
jenkins-bot 74f7784cdf Merge "Migrate DiscussionParser::getEditExcerpt() to accept only RevisionRecord" 2019-05-09 21:24:10 +00:00
jenkins-bot c5ed6315cc Merge "Remove usage of deprecated Revision class in Echo" 2019-05-09 20:56:17 +00:00
Derick Alangi 76544df40a Migrate DiscussionParser::getEditExcerpt() to accept only RevisionRecord
Follow up on Icfc85167a636bef95daab2.

Bug: T221163
Depends-On: I31d819f4453032da8deb117254b954fba058e0a3
Change-Id: I3d997f9e8d4bd1566ec6fd8fe2d33be5161458b3
2019-05-09 20:36:05 +00:00
Thiemo Kreuz be5919f623 Make use of the PHP 7 ?? operator where it makes sense
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
2019-05-09 15:57:16 +00:00
Derick Alangi 8e5aa13a73 Remove usage of deprecated Revision class in Echo
Class Revision is deprecated and in this patch, replaces
usage with appropriate classes; RevisionRecord, RevisionStore,
etc.

Bug: T221163
Change-Id: Icfc85167a636bef95daab236ab80113c1a3cf41b
2019-05-08 19:50:58 +01:00
Stephane Bisson f5f59a503b Use wikiId both server and client side
When creating the various notification sources,
the server was indexing them with wfWikiID() but
the client was using wgDBname to find which one
is local and which are remote. On some wikis,
like TWN, wfWikiID() includes a db suffix so
the JS app on Special:Notifications is failing to
find the local source and errors.

Bug: T167336
Change-Id: Id60f723b615fb7db54a6f17b1c1be20dfe98e36c
2019-05-08 09:03:28 -04:00
Derick Alangi c4890ca86f Remove usage of deprecated database access code from Echo
Bug: T221164
Change-Id: Ib7cfe384f4104dbaeed5ba6659e81555eb810f97
2019-05-07 20:46:07 +00:00
Stephane Bisson 13956265c1 Make phan ignore JsonSerializable redefinition
Change-Id: I1cffc88a3f4ea4290892c0624a6f32e852cde1dd
2019-05-07 16:21:22 -04:00
jenkins-bot b8aaf37e4a Merge "Proactively delete echo_event rows when they become orphaned" 2019-05-02 19:45:49 +00:00
Roan Kattouw 0e4f4ffad9 Proactively delete echo_event rows when they become orphaned
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
2019-05-01 11:23:27 -07:00
Roan Kattouw 95172c2c7e Remove per-type notify-type-availability (make it category-only)
Bug: T221264
Depends-On: I74f660e88d18d5a27cc1e74f39316bb27aec1cbb
Change-Id: I12cc0312dbfd9a6923b64117e001841a7bfaaf17
2019-04-26 17:36:10 -07:00