Commit graph

369 commits

Author SHA1 Message Date
Reedy a101ce674c Fix and disable some phpcs exclusions
Change-Id: I2ecaf71c8836d627f20629d667b78ffbf420e4ee
2022-11-12 17:58:13 +00:00
Reedy 5611662f06 Namespace Model
Depends-On: Id28792658de950b99a8786f881563476def59eba
Change-Id: Ib57ea2db947285946f31fa9912b37181044df9d3
2022-11-10 14:25:42 -07:00
thiemowmde cfa424f16b Make use of the ?? and ??= operators where it makes sense
?? is an older PHP 7.0 feature.
??= was added in PHP 7.4, which we can finally use.

Change-Id: If4145c48eb374aa8e5deeb38aecb27c6c8905382
2022-11-09 14:40:52 +01:00
Fomafix 096e4a709f Use short array destructuring instead of list()
Introduced in PHP 7.1. Because it's shorter and looks nice.

Change-Id: I395e791aed6cc99b7ce1273f51c292e29360443a
2022-11-08 16:41:24 +00:00
Reedy c85fe25fe7 Namespace Mapper
Change-Id: I8a02082466ef39db32ffa7562b02db61929346cd
2022-11-04 18:05:34 +00:00
Reedy 0f0c6c4fa6 Namespace Iterator
Change-Id: I87fa703da9e7725370d72c58fc40eb204a309e67
2022-11-02 16:51:39 -06:00
Reedy 3609edf153 Namespace Cache
Change-Id: I8ead3ee485528f08f71c21cf401880bf369dbeac
2022-11-02 16:37:48 -06:00
jenkins-bot f4a68c4c77 Merge "Namespace Controller" 2022-11-02 22:34:13 +00:00
jenkins-bot 32d58a5751 Merge "Clean up test case" 2022-11-02 21:44:48 +00:00
daniel 16425ff5ee Clean up test case
- Don't manipulate $wgHooks directly, use setTemporaryHook.
- Avoid premature access to MediaWikiServices from data providers
- use overrideSettings instead of setMwGlobals

Needed-By: I0ebba9a29f81b0d86ad8fd84d478fb244f9e9c15
Change-Id: I52b9251793a5d559658fcf1e0d20f5a497e5fc43
2022-11-02 21:55:56 +01:00
Reedy d3cc06cc6a Namespace Controller
Change-Id: Ice356e774c153c353eb6ed71b8a02afd1ad1e654
2022-11-02 14:52:29 -06:00
Reedy fb4478454d Namespace Gateway
Change-Id: I7501be6e57cec92b2b4175b8772d213c7fd031d4
2022-11-02 14:52:04 -06:00
Reedy 7619a76877 Namespace Echo Formatters
Change-Id: I5bf398cdb76a577543f6526ac1bee4a73897103d
2022-11-01 21:20:06 -06:00
Reedy 56dfaea949 Convert 9 hooks subscribers to HookHandlers
Bug: T315938
Change-Id: I4d061216da8a492fd0d28518d55e67f92e38ee78
2022-10-31 17:15:17 -06:00
Thiemo Kreuz db79d76d83 Use PHPUnit's shortcuts where it makes sense
Notably: any() is the default anyway. It doesn't really make the
tests more specific or better readable when we repeat it all the
time.

Change-Id: I56d201bfce454587b00015b7208f313dd8ed9624
2022-10-26 11:53:57 +02:00
jenkins-bot 7b68f3328b Merge "Namespace Api classes" 2022-10-15 18:04:20 +00:00
Brian Wolff dbe112dfa8 Tests: More complete mock to prevent php 8.1 warning
fixes:
ContainmentSetTest::testCachedListInnerListIsOnlyCalledOnce
strtr(): Passing null to parameter #1 ($string) of type string is deprecated

Change-Id: I9bb916383eda1176a2d56c06770a60c28431dfda
2022-10-03 11:50:04 -07:00
Reedy 38a9330753 Namespace Api classes
Change-Id: I414234f10c16b8ccaa7ddbaf8e9033e70dfceab8
2022-10-03 00:05:21 +01:00
Umherirrender c81dad3efc Replace deprecated WikiPage::factory/newFromID
Replaced WikiPage::newFromID with newFromTitle,
because a Title object exists and could be reused

Bug: T297688
Change-Id: Ide30f259477ed8e0b48df31f5a23cafeb38d7316
2022-06-03 23:25:37 +02:00
Reedy b64c1f3642 Move EchoPush\Api namespace to MediaWiki\Extension\Notifications\Push\Api
Bug: T305667
Change-Id: I6168b386f532c83333cdc6700ba7e2917385a39c
2022-04-25 13:56:16 +01:00
Reedy c76761eff3 Move EchoPush namespace to MediaWiki\Extension\Notifications\Push
Bug: T305667
Change-Id: I5a7846a0fc383bddbf6511d6ba73c8be7d7760c7
2022-04-25 13:56:09 +01:00
Reedy f9c1a0fedb Namespace Hooks class
Change-Id: If948e7d376b40cf29480a9fcbf72a65a0eebacb7
2022-04-25 13:55:41 +01:00
Umherirrender c650698ac5 Call IDatabase::timestamp before inserting echo_unread_wikis
The default timestamp of 00000000000000 cannot represent as timestamp,
because it gets a negative timestamp -00011130000000

This is needed for proper cross-RDBMS support

This reapply a change from I46206e0b3a687dff3168a81cf0020e669133e876,
reverted with I1c8c409b7820512b3e31246a7f3d8c1cf4db209c.

Bug: T244898
Change-Id: I109b783de0a8d60ccb161b280ce5fa09e145017b
2022-04-11 23:12:02 +00:00
Amir Sarabadani ea21714241 Remove mocking of numRows
Deprecated and to be deleted

Bug: T286694
Change-Id: Id678f8366e7a9c18696083b2e331d2dce7d8a8eb
2022-03-15 17:36:29 +00:00
Umherirrender 6af1473ca6 Replace deprecated wfReadOnly()
Bug: T283978
Change-Id: I5c796a0473599c71848b6079874bc7a969ee6f88
2022-02-11 23:39:06 +01:00
Umherirrender ffeee975a4 Replace deprecated User::newFromIdentity with UserFactory
Moved the factory deeper into the code right before the one usage it
still needed a full user object

Narrow done method arguments from User to UserIdentity
and use the identity directly

Change-Id: Ic118f23ef504c7fda892480df61ea68c10915f78
2022-02-11 20:35:49 +00:00
Umherirrender 9bf6ceb738 Replace deprecated JobQueueGroup::singleton()
Change-Id: I298d8507f4ec706c235087b726b7b230ed5e9ac6
2022-01-25 22:24:53 +01:00
jenkins-bot a8af58f362 Merge "Parse section titles in notifs as if they weren't at the start of line" 2022-01-24 05:43:44 +00:00
Bartosz Dziewoński 3493317d79 Parse section titles in notifs as if they weren't at the start of line
The section titles are wikitext extracted from inside heading markup
like `== … ==`, so start-of-line markup like `*` should not be parsed.

Bug: T299572
Change-Id: Ie3995b943e5fe20ad86041d6be755f14f32eb01e
2022-01-21 00:07:53 +01:00
Umherirrender 8e974de839 Adjust doc for EchoNotification::readTimestamp
And simplify the null check
Fix tests to provide null and not the empty string

Change-Id: Ic0f2dc09525f1542c7e62da97ac0f3fe936ff67e
2022-01-05 20:29:03 +01:00
vladshapik a3c55f6272 Avoid using User::getOption() method
Replace User::getOption() with UserOptionsLookup::getOption() since this method will be hard-deprecated.

Bug: T296083
Change-Id: I0ecdc63b0344bc4c24196cc5edb3d02b6a7ed615
2021-12-10 13:37:45 +01:00
libraryupgrader 2c3d370846 build: Updating mediawiki/mediawiki-codesniffer to 38.0.0
Change-Id: I10e9f9f6ddd9539ff95636902219c0e9fa35fc0f
2021-10-24 02:46:52 +00:00
Alexander Vorwerk 449f82faa3 MediaWikiTestCase -> MediaWikiIntegrationTestCase
MediaWikiTestCase has been renamed to MediaWikiIntegrationTestCase in 1.34.

Bug: T293043
Change-Id: I68efac2c458748fa3ab16c4c652bd2c4af9cbb75
2021-10-12 00:42:10 +02:00
Matěj Suchánek 628122e155 Fix camelCase of getUserEnabledEventsBySections
Change-Id: I14b6750f7f3cc5334e3143f0e85ca033681b4e35
2021-08-20 17:03:28 +00:00
jenkins-bot 5cfc33d546 Merge "Add notifiertypes parameter to ApiEchoNotifications" 2021-08-19 05:06:57 +00:00
Matěj Suchánek 199c9084d4 Move isBundleExpandable to EchoAttributeManager
It's an attribute, so it is definitely the manager's
responsibility. Unit test case included.
(EchoDataOutputFormatter really calls for becoming a service.)

Change-Id: If2658dd8c107246158cd93cbb233d8af62fd4424
2021-08-18 18:23:22 -07:00
Michael Holloway 5eb4c6cd1d Add notifiertypes parameter to ApiEchoNotifications
Previously, ApiEchoNotifications returned only events which were
enabled for the `web` notifier type. With this change, the notifier
type or types to consider can be specified by argument to the new
`notifiertypes` parameter.

This change is required so that the apps can request notification
content from the API for push notifications.

Bug: T287909
Change-Id: I2d1155e113f2defb0f02416a7a659c3ee162d3a6
2021-08-17 10:27:14 -04:00
Matěj Suchánek ab8ea040ca Use constant in EchoAttributeManager::getNotificationSection
And as a bonus, add a unit test case to solve the todo.

Change-Id: Ic2e13eae6583155230be6c184db4836f28378483
2021-08-11 11:27:55 +02:00
jenkins-bot 66bb02fd8b Merge "Disable EchoGetEventsForRevision hook handlers while running tests" 2021-08-04 17:42:25 +00:00
jenkins-bot ec9ea8fc81 Merge "Tweaks to EchoTalkPageFunctionalTest" 2021-08-04 16:47:55 +00:00
jenkins-bot 5566f84378 Merge "Turn push notification token list into a circular buffer." 2021-07-30 14:46:10 +00:00
Dmitry Brant 6c5a88107c Turn push notification token list into a circular buffer.
At the moment we support a maximum of 10 tokens per user for subscribing
to push notifications, stored as a basic list that runs out when the
limit is reached.  There may, however, be some edge cases where an app
registers a token and then forgets to unregister it (and repeats this 10
times), after which time it will be unable to register any new token.

This changes the token list to behave more like a circular buffer, by
simply deleting the oldest token before inserting the new one. This way
an app could register a new token even in the rare case of forgetting
the previous ten.

Change-Id: I387de63460882e4e56d1aa6db1f78d73a0495208
2021-07-29 17:22:57 -04:00
Bartosz Dziewoński ee860bc577 Disable EchoGetEventsForRevision hook handlers while running tests
Extensions using this hook (e.g. DiscussionTools) cause test failures
otherwise.

Change-Id: I21159d03eebaf46ad94f4273ba698a59b8019185
2021-07-26 13:56:44 +02:00
libraryupgrader 17a644263a build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0
  The following sniffs are failing and were disabled:
  * PSR12.Functions.ReturnTypeDeclaration.SpaceBeforeReturnType

npm:
* svgo: 2.3.0 → 2.3.1
  * https://npmjs.com/advisories/1754 (CVE-2021-33587)
* postcss: 7.0.35 → 7.0.36
  * https://npmjs.com/advisories/1693 (CVE-2021-23368)
* trim-newlines: 3.0.0 → 3.0.1
  * https://npmjs.com/advisories/1753 (CVE-2021-33623)

Change-Id: Id866782d39ac02a329bd79539f2d52392fffd296
2021-07-24 01:48:06 +00:00
Bartosz Dziewoński 762a2e192a Tweaks to EchoTalkPageFunctionalTest
* Fix off-by-one counting
* Fix asserting properties on the wrong event (first one instead of
  last one), luckily they are identical

Change-Id: Ib1a02476554b29b2a1d0bfdfa89859d71d7691b1
2021-07-21 23:25:54 +02:00
jenkins-bot a6dbadb006 Merge "Avoid using User::setOption()" 2021-07-17 10:29:45 +00:00
ZabeMath 3befbe0a69 Avoid using User::setOption()
User::setOption() is deprecated and should be replaced with UserOptionsManager::setOption()

Bug: T277818
Change-Id: I001301fb95635c421a0bbb921fd909c5312dc896
2021-07-17 09:52:53 +00:00
DannyS712 0099c45e54 AttributeManager: accept UserIdentity objects
Inject a UserOptionsLookup to replace deprecated
User::getOption()

Change-Id: I177f6d3486f987073e5d745077f0abfe9ae85aca
2021-06-29 06:41:47 +00:00
DannyS712 68f7a9a985 Use WikiPage::doUserEditContent() instead of ::doEditContent()
::doUserEditContent() is available since 1.36 as a replacement
for ::doEditContent(), which has been deprecated. Extension
already requires MediaWiki 1.37+, so the method is always
available.

Bug: T255507
Change-Id: Iee5de356dbccd453a3083e0a58859b4cd83a946b
2021-06-24 05:30:07 +00:00
Umherirrender 9ccc7af208 Remove PHP 5.3 $this closure workaround
Change-Id: I84024efc7bb27292bcfb7dd5c586b094828c5d0a
2021-05-15 01:58:55 +02:00
James D. Forrester 4dd2a651e1 phpcs: Auto-fix MediaWiki.Usage.StaticClosure.StaticClosure
Change-Id: I6a02902ffaa8a9b497d60b573a0b8e3dbc207ee5
2021-05-04 09:06:42 -07:00
libraryupgrader b3f948c59c build: Updating composer dependencies
* mediawiki/mediawiki-codesniffer: 35.0.0 → 36.0.0
* php-parallel-lint/php-parallel-lint: 1.2.0 → 1.3.0

Change-Id: I4b2fb7f46b6c0a5c33a6ad25f085de8ae13eb084
2021-05-04 09:05:15 -07:00
Petr Pchelko 4750dbe3de Use ApiTestBase::doRequestWithToken
The old ApiTestCase::getTokenList relied on CSRF
token API deprecated in 1.26. Many years have passed,
it's time to swtich to new mechanisms.

Needed-By: I58aedec6942ac5d3c21574cb0072f00ef365098c
Change-Id: Iafe7a48eb0cdf8c2f1ec7fdee232c3f394fa15a3
2021-04-20 13:53:16 -07:00
jenkins-bot cd663b0fac Merge "TalkPageFunctionalTest: Only count our own events" 2021-03-09 09:01:34 +00:00
jenkins-bot 29cd094a6c Merge "Do not directly construct UserrightsPage in tests" 2021-03-05 10:11:57 +00:00
Petr Pchelko f4ea1fd8d7 Do not directly construct UserrightsPage in tests
Directly constructing SpecialPages is bad, they're not @newable
and core can change constructor signatures without deprecation
and break the tests.

Change-Id: Ifc82d29a00d3fd136c44e0699e6bbfa11b8cf2a6
2021-03-04 15:17:11 -07:00
Bartosz Dziewoński 7dbc4f6ce8 TalkPageFunctionalTest: Only count our own events
We're working on code in DiscussionTools that generates Echo events for
adding talk page comments (I7e0996843cdd70141e19d5c7ce66122204efa1b7),
and it was causing this test to fail.

Change-Id: I3099473a3113962911b9c77ede290142857a51b2
2021-03-04 16:29:57 +00:00
Jeena Huneidi 008ad5afe1 Remove deprecated User method getGroups
Replaces the deprecated user method getGroups with
UserGroupManager->getUserGroups.

Bug: T275148
Change-Id: Ie6215886c911382008b667e8e5b3298facfcd6a2
2021-02-26 21:47:58 -08:00
Jeena Huneidi 596729d852 Make AttributeManager a service
Adds AttributeManager to EchoServices so that dependencies of
AttributeManager can be injected.

Bug: T275148
Change-Id: I4fa5084d72914d16b6d218e7dd3521f5a1919b80
2021-02-26 12:58:23 -08:00
jenkins-bot fd61cf3082 Merge "Replace use of newMutableRevisionFromArray within new MutableRevisionRecord" 2021-02-03 22:52:56 +00:00
jenkins-bot a517f9ed2a Merge "Use monitored getTestUser() in tests if possible" 2021-02-03 14:37:30 +00:00
Peter Ovchyn f352b3406c Replace use of newMutableRevisionFromArray within new MutableRevisionRecord
Bug: T272560
Change-Id: I171537c3346a7dd4aeb4fc612d7dd9fba5d64679
2021-02-02 22:42:06 +02:00
Thiemo Kreuz df6d65a6cf Use monitored getTestUser() in tests if possible
Change-Id: I584d8883f14b2651927890d353b738a02771abea
2021-01-29 18:00:57 +00:00
Thiemo Kreuz 0f954929a7 Remove comments that literally repeat the code
This also fixes a remaining `var` that should be `private`.

Change-Id: Ifa37a097a9d60bd22a16bc626d4b4271b8df2da7
2021-01-29 13:55:41 +01:00
Umherirrender fba5bcec19 Improve function and property documentation in tests
Change-Id: I90a0c9e7b1ac17edeed5f706a8f968f6d67df56f
2021-01-23 12:54:27 +01:00
jenkins-bot 2f15134088 Merge "push: die with error if providertokens param is empty" 2020-11-10 18:24:46 +00:00
mbsantos 86d45a66ca push: die with error if providertokens param is empty
Bug: T267263
Change-Id: Icf98189726602dd8e43e1f9daf19e3f73efb91b0
2020-11-10 16:50:37 +01:00
jenkins-bot 6135c62518 Merge "Avoid enqueueing delayed jobs if not supported." 2020-11-02 16:52:31 +00:00
jgiannelos 4f4786c62c Avoid enqueueing delayed jobs if not supported.
Change-Id: Ibb065f77a67bf47daafb6caaf8a338d0bcd479e7
2020-11-02 16:06:09 +01:00
libraryupgrader f5ff16571e build: Updating mediawiki/mediawiki-codesniffer to 32.0.0
The following sniffs are failing and were disabled:
* MediaWiki.Commenting.FunctionComment.ObjectTypeHintParam
* MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationPrivate
* MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationProtected
* MediaWiki.Commenting.PropertyDocumentation.MissingVar
* MediaWiki.Usage.ExtendClassUsage.FunctionConfigUsage

Additional changes:
* Dropped .inc files from .phpcs.xml (T200956).

Change-Id: I46e3dacb3da1266ff52d614003ad911feeb7504e
2020-10-29 14:24:24 +00:00
jenkins-bot cf0e87d18e Merge "Fix DiscussionParser failing in certain languages" 2020-10-29 00:16:32 +00:00
jgiannelos c97b8e6851 Implement delayed echo notifications
* EchoEvent now supports `extra` params for job delay and deduplication
* When Echo identifies this type of param it creates a
  DelayedEchoNotificationJob that will be executed after `delay` seconds

Change-Id: Ib0c6789dfe42e9703a67835909e5932c0054089f
2020-10-28 12:11:15 +01:00
Thiemo Kreuz 8880df4123 Fix DiscussionParser failing in certain languages
It appears like the initial \h in this non-Unicode regular
expression matches parts of an UTF-8 character, destroying it.
This makes the final preg_match() in this method fail, when
$output is going to be used as a pattern.

Bug: T264922
Change-Id: Iaf240bc2e0808c2f57c1f8bab2589d3207915afe
2020-10-27 20:03:18 +01:00
DannyS712 b708ba2462 UserNotificationGatewayTest: Mock User objects
Since its a unit test, the use of User::newFromId
prevents attempts in core to migrate to
the UserFactory.

Change-Id: If5e76f2ae570ef4ae58cb77b5281c4446a1cadff
2020-10-02 03:44:07 +00:00
Matthias Mullie a969c6d312 Make tests match actual expected format for user-locators
EchoAttributeManager::getUserCallable casts to array,
which means that even a non-array value (e.g. a simple callback)
becomes an array and NotificationController::evaluateUserCallable
will handle it just fine. But tests seemed to thing it was wrong.

Change-Id: Ia1e1e4015ebbc4d79bba5274e802911f222692c0
2020-09-30 15:54:54 +00:00
daniel 7170b0f35f Use MockHttpTrait
Use the mock HTTP request, in preparation for I1702c11928f87

Depends-On: I8ce17da7315b87b8dd0e502e601b9ac488089456
Needed-By: I1702c11928f8760bb41b41f4c7c04d7af03f62e2
Bug: T262443
Change-Id: I390856b4609635cee22253071f21ce63ff716791
2020-09-29 09:05:50 +00:00
DannyS712 357c8224ae NotificationsTest: No need to set $wgUser
Bug: T243732
Change-Id: I85e25ebc636a1cfce8a06614adad8d7afb68965f
2020-09-15 01:01:11 +00:00
jgiannelos 4abfbd3c96 Normalize eps_topic
* DB changes
 - Create a table for push topics NameTableStore
 - Add a foreign key on subscriptions to normalize push topics

* Implement NameTableStore to normalize topics
* Update DB query joins to include topic from foreignkey
* Adapt code to use IDs instead of the actual topic

Bug: T261756
Change-Id: Ia7589f4a607993352d45b2dd3bcb3867d12d6e97
2020-09-14 15:52:23 -04:00
Ostrzyciel a585ad635a Explicitly provide sysop user in unit tests that need it
Currently Echo assumes the default user used when ->editPage() is
called to be a sysop user… which is kind of the case? It passed null
to WikiPage::doEditContent() which in turn falls back to the default
user (127.0.0.1). In a test that relies on the user to be a sysop, it's
better to provide the user explicitly to avoid confusion.

This is to clean up the confusion introduced by ->editPage()'s doc
block, see: I9f77474f40e0f6901aa2c6f846e471b822636aa5

Change-Id: I7a79e0eaa1617e4d87a8d615a5391723c0e30b6a
2020-09-13 08:16:45 +00:00
Michael Holloway 3513c642dd Create push subscription manager group/right to clean up dead subs
Creates a new push-subscription-manager group and an associated
right, manage-all-push-subscriptions. The purpose of this is to
allow privileged accounts to purge expired subscriptions from the
database on behalf of other users. A user with this right will be
permitted to delete any subscription from the DB based on the token
alone. For all other users, deletion requests will be limited to
those associated with the requesting user's central ID.

This right will be granted to a bot account on Metawiki associated
with the Wikimedia push notifications service, and the push
notifications service account will make push subscription delete
requests to the API for subscriptions for which vendor APIs return bad
subscription responses.

Additionally, the providertoken parameter to ApiPushSubscriptionDelete
is updated to allow multiple providertoken values.

Bug: T259148
Change-Id: Ia6c17588ee94e6be74e5e3a75eb33e38f172fc93
2020-08-20 17:08:48 -04:00
Mateus Santos c188dac23f push: send apns topic when present
1) send apns topic when present in subscription metadata
2) check if subscription metadata is a valid JSON string
3) make epp_id column at echo_push_provider table auto_increment,
otherwise it will fail when trying to add a second row in the table

Bug: T259394
Change-Id: I785435e9f2d4ba9c14977d431d271f0fa2d0c795
2020-08-18 13:21:20 +00:00
jenkins-bot aa1f1801e4 Merge "Create and enforce a config setting for max subscriptions per user" 2020-08-13 17:03:05 +00:00
Thiemo Kreuz e5fead8b42 Use more canonical (object)[] instead of new stdClass
Both styles create the exact same object. Casting an array to an
object creates an stdClass object as well. The main benefit of this
syntax is that there is much less repetition. Everything is one
token instead of individual lines, where each line might contain a
typo.

Change-Id: Id43fa2c4b6bd5d9dbc60008427d4a9e14ae3811c
2020-08-13 09:58:14 +00:00
Michael Holloway 15d48278be Create and enforce a config setting for max subscriptions per user
Creates a EchoPushMaxSubscriptionsPerUser config setting (default: 0)
that controls the maximum number of subscriptions a user may associate
with the user's central user ID.

The setting is enforced in EchoPush\SubscriptionManager::create().

To allow creating push subscriptions for development, set
$wgEchoPushMaxSubscriptionsPerUser to a positive integer value in
LocalSettings.php:

 $wgEchoPushMaxSubscriptionsPerUser = 10;

Bug: T259150
Change-Id: Ib97b6b6cbb8161dd75dad92c54b4fe4fff80c421
2020-08-12 17:58:11 -04:00
Thiemo Kreuz 9d988e50b4 Use more specific PHPUnit assertions for type checks
Change-Id: I22d3cddfb5d3d3f2ac49d075e885a3241b8360bc
2020-08-10 12:54:10 +02:00
Ed Sanders 1b40b69481 Make default snippet length (150) a constant
Change-Id: Idb53b226618fa0d625c7e4713c780538bd6a76ea
2020-07-23 13:00:44 +01:00
jenkins-bot a2c6b21925 Merge "Update hooks to use PageSaveComplete" 2020-06-30 10:40:51 +00:00
Umherirrender 3c53d6acb9 phpcs: Break long lines
Use the codesniffer default of length = 120

Change-Id: Ifbfd56b20432e54805d3a9bce22cda888c1fc74d
2020-06-27 12:05:03 +02:00
DannyS712 28a5eafe8c Update hooks to use PageSaveComplete
Extension requires MW 1.35+, always available

Bug: T250566
Change-Id: I1131a50f03002337d6b6eac18fdcb6adaaa896ce
2020-06-26 15:59:04 +00:00
Michael Holloway a2412732f6 Push: Add additional job params for logging
Adds additional job parameters to help diagnose the apparent issue of
jobs being performed twice on Beta.

Bug: T255068
Change-Id: Ib257a24056539487e1110fe286fa4535c3fec94a
2020-06-17 17:58:21 -04:00
Michael Holloway 1d31fd753a Push: Submit requests to configured service endpoint
Finishes the implementation of the stubbed NotificationServiceClient.
Sends push notification request messages to the endpoint configured in
the EchoPushServiceBaseUrl setting. For example, to send messages to an
instance of mediawiki/services/push-notifications running on the host
machine while running MediaWiki in Docker, add the following line to
LocalSettings.php:

 $wgEchoPushServiceBaseUrl = 'http://172.17.0.1:8900/v1/message';

Bug: T252899
Change-Id: Icab7825e9080d6b1a4cfc5e12fed1da221ce4610
2020-06-08 13:37:24 +00:00
Michael Holloway a5bcc65504 Fix push subscription retrieval
Updates the push subscription query to retrieve a provider string rather
than only its numeric internal ID.

Change-Id: I910173409e48e8b6a6739d3122165c40b0d52b7f
2020-06-08 13:58:42 +02:00
Michael Holloway ce7a46f7ed Add push notifier
Provides a basic push notifier implementation. Since the push service is
not yet in place, all it does for now is log debug output when a
notification is to be sent.

To register the push notifier, add the following configuration to
LocalSettings.php:

 $wgEchoNotifiers['push'] = [ 'EchoPush\\PushNotifier', 'notifyWithPush' ];
 $wgDefaultNotifyTypeAvailability['push'] = true;
 $wgNotifyTypeAvailabilityByCategory['system']['push'] = false;
 $wgNotifyTypeAvailabilityByCategory['system-noemail']['push'] = false;

We'll register the notifier in configuration for now, rather than
hard-coding the default in extension.json, in order to have control over
when and where it rolls out (beta vs. prod, as well as which wikis).

Since the push notifier implementation depends on jobs being processed
by the job queue, I also recommend adding the following configuration
setting to ensure that all pending jobs are processed at the end of each
web request:

 // ensure all pending jobs are processed when a web request completes
 $wgJobRunRate = PHP_INT_MAX;

Bug: T252899
Change-Id: Ie7f222443045d30620ff297b006104ef18a074a8
2020-06-02 13:40:04 -04:00
Michael Holloway a3674974f1 Add push subscription management
Adds DB tables for storing push subscriptions, some DB interaction code
for retrieving them within MediaWiki, and a set of API modules for
managing them from the outside world.

When testing this patch, be sure to run maintenance/update.php to create
the new tables, and set $wgEchoEnablePush = true in LocalSettings.php
to enable the API new API module.

N.B. The current DB schema is centered on app push subscriptions. Web
push subscriptions require slightly different handling, since they are
provided by browsers as a JSON blob rather than a token string. How to
handle web push subscriptions is a question we can defer until the time
comes to add web push support.

Subscription data is stored in the echo_push_subscription table, with
provider names normalized into the echo_push_provider table. We expect to
be looking up subscriptions by central user ID, so that column is indexed.
The subscription data also includes a column to store SHA256 digests of
the subscriber tokens. This is for use as a unique key constraint, since
we expect every push token to be univerally unique, and the token values
themselves may be too large to reasonably index in MySQL.

Bug: T252899
Change-Id: I3928761b3fba12e54ff4850e9a05c68ec7772f62
2020-06-02 13:40:00 -04:00
Roan Kattouw 28f432b150
Add dynamic secondary action to mute/unmute page-linked notifications
Also adds an API module for muting and unmuting pages (and users).

Bug: T46787
Bug: T115264
Change-Id: Icf4e4bfa9fd7fa27b4c40892e3d5ce000eb22d5a
2020-05-27 15:20:08 +02:00
Kosta Harlan 1560528dc7 Add page linked event title muted list
* Add a section on the preference form to allow users to mute articles
  from generating "page linked" notices
* The preference will save the article title as an article ID

Depends-On: Ia0ddf78646ec4c8ae0b84b6d5b46ef5e51c8e8c1
Bug: T46787
Change-Id: I67f751eae5fdc5bccff7fe3047227d432c1cb8d5
2020-05-06 12:38:55 +02:00
Daimona Eaytoy 1be7adf0a8 tests: Avoid calling Title::__construct
Change-Id: Icfe39e0835b4779bf538c2aea9a15cacbdcd6ff5
2020-03-14 18:41:08 +00:00
Umherirrender a933412ea5 Use MediaWikiServices::getMessageCache
This required MediaWiki 1.34 (already set in extension.json)

Change-Id: Ib9f9fe6581c3019fa32dff53acf33edb4266e44d
2020-03-14 14:04:32 +01:00
DannyS712 72f30649d5 Pass a user when creating a new ParserOptions
Bug: T246861
Change-Id: Ie6b6504d3b78a33ecb89a5c431bc225622d715c2
2020-03-04 21:53:33 +00:00
Daimona Eaytoy c256faf968 Remove hack for PHPUnit's Stub interface
This partly reverts commit c19c88567b.

Bug: T192167
Depends-On: Ia12658554c94497a204b7f65f1a6f7b1fa0310ac
Change-Id: I4ef736d87d05f74920ce88f57b0ad824986adb26
2020-01-23 12:34:48 +00:00