Commit graph

1276 commits

Author SHA1 Message Date
Derick Alangi 3971e32f1b Code improvements for includes/ **only** directory
This code improvements seeks to improve on code readability, consistency,
maintainability and efficiency.

Change-Id: I4f07886044e9a75824f9e7ddad039f3112b1c4a1
2019-03-05 18:58:52 +01:00
jenkins-bot b93e548d91 Merge "Fix off-by-one edit count for ThankYouEdit notification" 2019-03-05 01:58:46 +00:00
Stephane Bisson 408721a357 Fix off-by-one edit count for ThankYouEdit notification
Incrementing user edit count was moved to a deferred update in
I0d6d7ddd91bbb21995142808248d162e05696d47
That causes the notification to lag behind, and the thank you notification is
sent for your first edit on the second, you 10th on the 11th, etc.

This change simply assumes one more edit than the current count unless it is
running from the CLI (this is needed for the test to continue to work).

Since the update job is mergeable, it is possible that a certain value will
be skipped and the notification for it never sent. See task for moe details.

Bug: T209541
Change-Id: Iea61b0f525be25f63f50582933a16a79a52e141f
2019-03-04 20:39:22 -05:00
Roan Kattouw ae75a8118a Remove notification_bundle_base
No longer used in the new bundling system.
Also removes indexes that contain bundle_base.

Bug: T143763
Bug: T131415
Change-Id: Ibf94cdc471a11cb14995fee6a55af0d227b50aa5
2019-03-04 13:22:17 -08:00
Roan Kattouw b73522549d Migrate and remove event_page_namespace and event_page_title
By running updateEchoSchemaForSuppression.php as an updater.
The patch-*.sql files already existed, they were added
in 2013(!) by 34fbeaf8c but never applied.

Bug: T136427
Bug: T50059
Change-Id: Ied049681df4bab325f069c3a68cf704ee9a8f2c9
2019-03-04 13:12:52 -08:00
jenkins-bot a838836a23 Merge "Use explicit columns and avoid SELECT *" 2019-03-04 21:12:28 +00:00
jenkins-bot 8de5066b24 Merge "Convert caching to WANObjectCache" 2019-03-04 15:06:35 +00:00
Umherirrender 1b5308ba81 Use explicit columns and avoid SELECT *
Change-Id: Ibde033784aee5adc13fae6f1d395d9464f54fefd
2019-03-02 22:39:53 +01:00
Umherirrender 8ce0cc171d Fix UserMerge integration for use with table prefix
This fixes tests, because EchoHooks has "echo_event.*" which is invalid
with table prefixes, like done in unit tests
Added EchoEvent::selectFields() for future use and to replace more
SELECT *

Bug: T217487
Change-Id: I51cb46812431635d11780633dc7d807cd04f813d
2019-03-02 22:05:22 +01:00
Umherirrender 8da7e5b04a Pass string as field to IDatabase::selectField and ::selectRowCount
It is documented as string, because it can only select one field,
not a list of fields

Change-Id: Iad8ff691e642220359f45f97359aa624261af673
2019-03-02 17:29:29 +00:00
jenkins-bot 19cef58454 Merge "NotificationDeleteJob: Remove unused variable $targetMapper" 2019-03-02 03:43:50 +00:00
Roan Kattouw db6c1f076d NotificationDeleteJob: Remove unused variable $targetMapper
Change-Id: Iaf5e3ae53ae55820dca9c7b7d96506154af0f75d
2019-03-01 17:05:10 -08:00
Aaron Schulz bb0ca321df Convert caching to WANObjectCache
Change-Id: I6c0315aa6e24c573cf9a8410ff21471ed3da60d1
2019-02-28 21:56:38 -08:00
jenkins-bot c9b2770c8c Merge "Declare class properties in Formatter and WikiRequest" 2019-02-28 23:41:34 +00:00
Umherirrender 79b2611bbc Use local vars in LabelIconWidget
Change-Id: I037b02c7336d68f520e028a16df0edd0237458d8
2019-02-23 21:26:35 +01:00
Thiemo Kreuz 8fd66d4281 Make use of the …::class feature in production code
This codebase already used the …::class feature a lot. This is more
about making the code consistent and easier to refactor in the future.

Change-Id: If5b2456b825aae753ed97445160ec191c18df8e3
2019-02-20 19:13:54 +00:00
Thiemo Kreuz e649551e5e Simplify a few overly complex code snippets
* preg_match_all already returns the number of matches. We can just use
  this number instead of counting it.
* Checking for a strlen() of 0 is a little tooo expressive, because we
  don't really care about the actual length of the string.

Change-Id: I0537a7740e5d369b79364f24aecf71c4e8fa7db1
2019-02-19 20:39:26 +00:00
Umherirrender fdc2b42b2b Declare class properties in Formatter and WikiRequest
Change-Id: Iaf4c2f7bb75896d3daafbb445f7b5f6341543f8e
2019-02-18 19:25:56 +00:00
jenkins-bot 3fd6549ced Merge "Improve param docs and add @var to clarify types" 2019-02-17 01:29:48 +00:00
Matěj Suchánek cd4e510201 Fix undeclared var
Credit goes to Umherirrender who pointed this out.

Change-Id: I4d590b3574ea1310fa795cfd94a129e3046e6e3c
2019-02-15 21:25:27 +01:00
Umherirrender cdae062d47 Improve param docs and add @var to clarify types
Change-Id: I44f872b3a2921e75aab8e22fec57735f17ee1d8b
2019-02-15 21:23:02 +01:00
libraryupgrader 5bd2eaf70e build: Updating mediawiki/mediawiki-codesniffer to 24.0.0
Change-Id: Ifd3dde125bae36b1076576ddc0c8b09eadd18a72
2019-02-06 13:01:32 +00:00
Matěj Suchánek 8994407a7d Remove duplicate notifications after merging users
Bug: T103747
Change-Id: Ic2612e5d7861ef7c6a22ab66fd3b9d6ea71f959f
2019-01-16 18:38:34 +01:00
jenkins-bot 729111443e Merge "Display the full title in notifications about mention in summary" 2019-01-07 22:10:51 +00:00
Matěj Suchánek ed171889bf Avoid double escaping of select options
Since the correct transformation method is unclear, change them to plain message keys.

Bug: T211876
Change-Id: I055c089574e7dcf5d634da402290a2ad024126f9
2019-01-05 11:06:20 +01:00
jenkins-bot b6fab8150a Merge "Add missing use for Wikimedia\Rdbms\Database" 2019-01-02 21:22:48 +00:00
Umherirrender d042257d40 Add missing use for Wikimedia\Rdbms\Database
Change-Id: I0c4beb49d1042c3ebe09b3d6e036b1028426715f
2019-01-02 19:40:58 +01:00
Umherirrender 795d48d539 Required argument follows optional
Remove default value, it is already list in param doc

Change-Id: Icbea3afce6abfbc075136798959521046ce86ab0
2019-01-02 14:52:14 +01:00
Matěj Suchánek cb1051ce19 Display the full title in notifications about mention in summary
It always puzzles and confuses me when I get this notification without the namespace.

Change-Id: I03711575d8ddbdfb07879982640dfdcb7b69b3ab
2018-12-31 16:43:56 +01:00
Thiemo Kreuz 0a6e548e4e Some more specific array and array[] type hints
Change-Id: I2c518410df779683dfd70aacd5084f55d6766498
2018-12-17 11:45:39 +01:00
Edward Chernenko 33e77eb7c2 (cosmetic) Fix typo in comment of abortNewMessagesAlert()
Change-Id: Ieb46771b66f655319ad3653edb1bdac08b824c4f
2018-11-16 03:24:08 +03:00
Mogmog123 b96093284a Clean up back-compatible code in NotificationController.php
Change-Id: Icb4cb98c1dfbd79e5f0c9a4ae91568fea9e19dcd
2018-11-14 09:54:10 +00:00
jenkins-bot 6b0eb59c5d Merge "Replace two regular expressions with cheap string manipulations" 2018-11-07 22:37:56 +00:00
jenkins-bot f75d5d120f Merge "Add method scope visibility" 2018-11-02 23:55:06 +00:00
Umherirrender 81183a6d86 Add method scope visibility
Change-Id: Id4fe59155d6e0fa2ef1ccf4dc46ee1f109265246
2018-11-02 18:47:39 +01:00
jenkins-bot 92ed4e312c Merge "Make notifyAgent a per-type property rather than per-event" 2018-11-02 15:09:19 +00:00
Rafid Aslam 134ad74fdc Change HTTP links to mediawiki.org to use HTTPS
Several links that link to mediawiki.org still use
"http" protocol which isn't a safe protocol. This commit
changes http links that link to mediawiki.org to use
"https" protocol instead.

Bug: T189687
Change-Id: Ie8a8fca4148181c9d1fe4379993aae3aaacf5ed9
2018-10-30 23:52:50 +07:00
Roan Kattouw de536d09d9 Make notifyAgent a per-type property rather than per-event
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
2018-10-29 15:41:51 -07:00
jenkins-bot 155d582026 Merge "Avoid use of IDatabase::delete() return values" 2018-10-28 21:42:10 +00:00
jenkins-bot 512a0904c5 Merge "Avoid use of IDatabase::insert() return value" 2018-10-28 21:42:07 +00:00
jenkins-bot f84c49a9f9 Merge "Avoid use of IDatabase::update return value" 2018-10-26 23:39:32 +00:00
Aaron Schulz bbf0e1fade Avoid use of IDatabase::insert() return value
Change-Id: I36a18d9ff315928555bef7ab93283ec72aeef9f7
2018-10-26 15:44:57 -07:00
Aaron Schulz 9aa1344808 Avoid use of IDatabase::delete() return values
Change-Id: If5e28fc640199c22dfe8ae3ab3ffadf4859fa7a1
2018-10-26 15:25:15 -07:00
Aaron Schulz 9a0ce7d4d7 Avoid use of IDatabase::update return value
Change-Id: I0739c2dcd22aa0536257e534dd1eb0d44d3f016b
2018-10-26 13:56:30 -07:00
Aaron Schulz 9cca289625 Avoid use of IDatabase::update return value
Change-Id: I6780b4ca7051daee38d9155632a556455c434b67
2018-10-26 12:46:58 -07:00
Zoranzoki21 3f42e2956f Fix HTTP links to HTTPS for www.mediawiki.org
Bug: T189687
Change-Id: I1990cabfa813f7eabe935ce81644d568f99215ea
2018-10-23 20:58:50 +00:00
Thiemo Kreuz 5cf0e6273f Add missing limits to explode() where possible
For the algorithms in question this does not make any difference. Excess
elements are thrown away anyway. This is for performance.

Change-Id: I645e389b3f993bc8015fd729b9302aa25471f833
2018-10-20 09:11:19 +00:00
Thiemo Kreuz 8c51f5bd45 Avoid count()ing where not necessary
If all the code needs to know is if an array is empty or not, using
count() creates more confusion than anything.

Change-Id: I253308505fe5af5b5c56d85169789271967298ba
2018-10-19 10:04:24 +02:00
James D. Forrester 8e0878df3a Update references to re-namespaced RevisionStore
Change-Id: If19981aba01ef9aac68bcd731d6912ea827fcfe5
2018-10-12 11:14:14 -07:00
jenkins-bot 319789827c Merge "Use \h instead of \s in regular expressions" 2018-10-11 22:11:58 +00:00
Thiemo Kreuz 44f861496f Replace two regular expressions with cheap string manipulations
Note that the array of matches returned by preg_match changes when
PREG_OFFSET_CAPTURE is set. That's why the additional [0] (for the
match) and [1] (for the offset) are needed.

Bug: T203930
Change-Id: I89f9ea3bef49fe9128fd42805695982f012ecba9
2018-10-11 10:59:04 +02:00
Alangi Derick 873df84e49 Fix php tag in SpecialDisplayNotificationsConfiguration.php
Change-Id: Ib95e906ae9659e7613cd78ae24225cc5e4350758
2018-10-08 18:49:06 +01:00
Stephane Bisson 9f37ba0511 Handle revision not found
Some Echo events include 'revid' in their extra info.
It can be used to check if a revision is minor in order
to respect the 'enotifminoredits' preference.

This patch ensures that it is not trying to call a function on
a null revision reference and it logs to debug to help
troubleshooting.

Also encapsulate the "is minor" check to a private function
to (hopefully) make the relationship with the preference
more clear.

Bug: T204795
Change-Id: I28a4c54f610dccc1356f6af0de9c2623d7bf94f0
2018-10-05 09:11:58 -04:00
jenkins-bot a88c189301 Merge "Remove expensive regular expression that doesn't have any effect" 2018-10-04 13:23:28 +00:00
Umherirrender d6e85e1300 Fix loggroup name in NotificationController::getUsersToNotifyForEvent
Using {closure} seems not helpful

Change-Id: I67ee2d6e48226cc079cb290ca7dd63407eb85883
2018-09-30 14:22:35 +02:00
jenkins-bot e29ecab5e0 Merge "Don't override checkmatrix defaults set elsewhere" 2018-09-25 20:50:04 +00:00
Thiemo Kreuz acba72e011 Remove expensive regular expression that doesn't have any effect
See, this last part of the compiled regular expression is wrapped in
an (…)*, which means it is entirely optional. It does not make any
difference if this part is found or not. The compiled regular
expression matches with or without any of these "line ending"
fragments being present.

I can not really figure out what the intention of this was. A line
ending anchor ($) is not missing – I'm pretty sure about this.
Otherwise it could not detect signatures that are wrapped in more
than a single HTML tag, for example.

Instead of fixing it I decided to remove it. The tests should show
this code was not needed.

The motivation for this patch is to improve performance. This part of
the regular expression is quite heavy and can cause a lot of
backtracking for literally zero benefit.

Bug: T203930
Bug: T204291
Change-Id: Ia5323b401b947edeb7094d7eec131ba6c80edf70
2018-09-25 18:15:49 +02:00
Thiemo Kreuz 17762b3b29 Use \h instead of \s in regular expressions
\h matches only horizontal whitespace, but no newlines. This is what
we want in all these cases, because nothing of this (headlines,
signatures, timestamps) is even allowed to span multiple lines in
wikitext. The tests should show this still succeeds.

The idea is to make these regular expressions more strict so they
don't run in so much expensive backtracking.

Bug: T203930
Bug: T204291
Change-Id: I805f8cb082edcd26713ef41d3ae5b61194c131e5
2018-09-25 18:09:51 +02:00
Thiemo Kreuz 0c7bd7dbc8 Wrap unknown \A escape sequence in single quotes
In double quoted strings PHP tries to understand all kinds of escape
sequences, but \A is not one of them. Such sequences are left untouched,
including the backslash.

In single quoted strings, there are no escape sequences. All are left
untouched, which is what we want in case of a regular expression.

TL;DR: The resulting string is the same in both cases. I'm touching this
because my IDE shows a warning about the unknown \A escape sequence.
It must be either turned into "\\A" or '\A'.

Change-Id: Ie1e84c67c344faf77bc86a0b28dc82d31c3a7dbe
2018-09-25 18:05:40 +02:00
Max Semenik b82b54f0a6 Don't override checkmatrix defaults set elsewhere
Bug: T174220
Change-Id: I3c9bc06ff78040f88f7f870671c838dad4e3ad6d
2018-09-20 17:15:09 -07:00
Stephane Bisson 330810614d ApiCrossWiki: Handle needsToken() returning false
false ?? null evaluates to false, so for non-write modules we were
passing false as the token type instead of null, which breaks.

Bug: T204758
Change-Id: Ief25150ce8f4b4b64a224f97f3fd528883b2f326
2018-09-18 17:21:50 -04:00
Brian Wolff 983a01bdff Build: Make pass phan-taint-check 1.5.0
Disable some errors related to different members of an array
having different taints, and phan-taint-check conflating them.

Bug: T202383
Change-Id: Ic6c2c5bb7c6092d581e646358d836f55d5cf3222
2018-09-14 02:04:03 +00:00
jenkins-bot 9eebe652a7 Merge "Fix HTML escaping on Special:DisplayNotificationsConfiguration" 2018-09-05 12:56:57 +00:00
jenkins-bot b6f4e9d133 Merge "Make markasread parameter work cross-wiki" 2018-09-05 12:40:34 +00:00
jenkins-bot 4c2e69fadb Merge "Add cross-wiki proxying to the action=markasread API" 2018-09-05 12:40:30 +00:00
jenkins-bot 9cc47ceac8 Merge "Rename ApiCrossWikiBase -> ApiCrossWiki and make it a trait" 2018-09-05 12:35:29 +00:00
Bartosz Dziewoński 4b8916c405 Fix HTML escaping on Special:DisplayNotificationsConfiguration
The labels for individual options are treated as HTML, not as text.

Change-Id: I5c2ae2d3a1dcaa3b85a2b47ed05952db28ea508e
2018-09-03 21:16:37 +02:00
Roan Kattouw 7a816f8d26 Make markasread parameter work cross-wiki
Add a markasreadwiki parameter, and use cross-wiki API proxying to mark
the specified notification(s) as read on the originating wiki.

This allows notifications to be marked as read when the primary link is
followed, even if the primary link points to a different wiki.

Bug: T179765
Change-Id: Id7e1e11997173e1578e33cd189dc0f93a5e4ba63
2018-09-03 10:59:31 -07:00
Roan Kattouw 55a5823d45 Add cross-wiki proxying to the action=markasread API
Add support for POST requests and tokens to EchoForeignRequest
and ApiCrossWiki, and add the ApiCrossWiki trait to ApiEchoMarkRead.

Change-Id: Idadaacd0d0c4a957bf2499049fc105a60c73bc52
2018-09-03 08:07:39 -07:00
libraryupgrader 4728b3332c build: Updating mediawiki/mediawiki-codesniffer to 22.0.0
And updating CoC link to use Special:MyLanguage (T202047).

Change-Id: Ic18c7ae9b70c18ffb321967aae7e9a684acfc625
2018-09-03 01:46:10 +00:00
jenkins-bot c9afa64579 Merge "Always place items outside menu if there's less than two of them" 2018-08-30 21:10:31 +00:00
Roan Kattouw a90890582a Rename ApiCrossWikiBase -> ApiCrossWiki and make it a trait
That way we'll be able to mix it into non-query modules as well.

Unfortunately, PHP traits don't let overridden methods call their
original versions, which had to be worked around in a few places:
- $this->foreignNotifications can't be initialized in the constructor
  any more, so it's now lazy-created through $this->getForeignNotifications()
- Adding the 'wikis' parameter to getAllowedParams() now happens by
  calling getCrossWikiParams() rather than calling the parent
- Overriding getForeignQueryParams() can't call the parent anymore, so
  instead we just inline it

Change-Id: I415e6d921819fc1f7869c7d2f8bb62830a84c2a1
2018-08-29 18:03:16 -07:00
jenkins-bot a5d17463d4 Merge "Escape messages used in HTMLSelectField 'options'" 2018-08-29 10:52:44 +00:00
James D. Forrester 918a19efac Drop $wgNotificationReplyName, instead let just show the e-mail
This is what MediaWiki itself does. It's not great, and isn't any more
translatable than a config setting, but consistency isn't valueless. In
future, with T202326 we may wish to vary this, but for now this is
simpler.

Change-Id: I76fca8ee255c65ab9b7e988d44de0d0fbd3c84b7
2018-08-29 01:03:54 +00:00
James D. Forrester 92b2df6f3e Use $wgNoReplyAddress rather than $wgPasswordSender for generic Reply-To
Change-Id: I4712d4fe02caf019a3b45f6efe82453eec59a50f
2018-08-28 21:54:47 +00:00
James D. Forrester d2ab6527e9 Drop $wgNotificationSenderName
Instead just use the system message `emailsender` like we do for all other
e-mails, which is thus translatable.

Change-Id: I7e58a3a4e224d551c6fae4a76fcba19fe838d3e9
2018-08-28 18:06:59 +00:00
jenkins-bot 229471d1b0 Merge "Fix page-linked notifications" 2018-08-28 00:14:22 +00:00
Roan Kattouw a01ebbc045 Fix page-linked notifications
These were broken because e8632ab0f6 in MW core stopped passing a
triggering user to LinksUpdate.

This commit takes the user from the Revision object instead. In weird
cases that might be different from what LinksUpdate says, but
page-linked notifications don't use the agent in their rendering anyway.

Also remove the code that refused to route events to a page creator if
they didn't have an agent. It's perfectly legitimate for events not to
have an agent, that shouldn't preclude them from using non-agent-related
locators.

Bug: T200119
Change-Id: Ia31131b1d1b2640d962ab7f3e573599c43ae50d4
2018-08-27 10:46:39 -07:00
jenkins-bot 6072511b47 Merge "Fix common typos in code" 2018-08-27 11:33:30 +00:00
jenkins-bot 8a759ce1b7 Merge "Split long lines over 140 chars" 2018-08-26 18:35:58 +00:00
jenkins-bot b7815f435b Merge "Remove count() of null value" 2018-08-26 07:42:35 +00:00
Zoranzoki21 00dfbd1af7 Fix common typos in code
Bug: T201491
Change-Id: Ibd287f220720c33b82847475fbe88b586557de69
2018-08-25 17:35:13 +00:00
Umherirrender 5daca5ee1a Escape messages used in HTMLSelectField 'options'
Change-Id: I10aaa57d376f611997f47fa1fe3bff859370820b
2018-08-25 13:20:01 +02:00
Umherirrender 2cd8d9d0eb Split long lines over 140 chars
This makes the code easier to read even on big screens

Change-Id: I14bfb97b2986f389ad11a6ddc97ba61468774782
2018-08-25 12:51:14 +02:00
jenkins-bot b6bfaa2e2c Merge "Explicit convert Message objects when used as string" 2018-08-25 06:17:21 +00:00
Stephane Bisson a5ececbb7e Initialize $success
Followup I85452d0f0afe974d26a575e000f6ae2ceeddf06c

* initialize "$success = true" before using it in
  a loop to keep track of the overall success of
  all batches.

* Add check for readOnly db in markUnRead() and
  markAllRead(), like it was done in markRead()

Bug: T202672
Change-Id: Ifdfa93059268d5b02ba3e0e885661ce593845791
2018-08-24 06:15:12 -04:00
jenkins-bot c419bcf45e Merge "Drop $wgNotificationSender, written to but never configurable" 2018-08-23 20:58:49 +00:00
jenkins-bot b0d83815b9 Merge "Don't send email notifs to blocked users if $wgBlockDisablesLogin is true" 2018-08-23 19:02:48 +00:00
Roan Kattouw 2b0929a4b1 Don't send email notifs to blocked users if $wgBlockDisablesLogin is true
Bug: T199993
Change-Id: I47ed3599d61ca8177cdd0820dea4089fdb087d82
2018-08-23 11:39:25 -07:00
Umherirrender 516eeda19e Remove count() of null value
php7 gives:
count(): Parameter must be an array or an object that implements
Countable
null or [] are both evaluate to false, so just remove the count

Change-Id: Id92dbd48f308d1e9dffa086699e0e944744aeeaa
2018-08-23 18:07:22 +02:00
Umherirrender a0ad95b63f Split long lines over 200 chars
This makes the code easier to read even on big screens

Change-Id: Iebc2ca785690abc6e7998c6f6078daf0bd01ccf8
2018-08-23 10:33:25 +02:00
Umherirrender e89206ce4a Explicit convert Message objects when used as string
This makes clear which escaping should be used.
In all cases it needs Message::text, because there are used inside
Html::element. There is no visual different.

Change-Id: I17474a7d5f057321e8c759d4bf94c8234c7a89c7
2018-08-21 14:16:22 +02:00
James D. Forrester eefeb6d031 Drop $wgNotificationSender, written to but never configurable
Instead just use $wgPasswordSender explicitly. This also allows us to drop the
extension registration callback function, which is a performance improvement.

Bug: T200390
Change-Id: I08d2f040c5ad8feb395a2e8e176f91636efe1d3d
2018-08-20 13:41:05 -07:00
Timo Tijhof 2142be10b0 cache: Reduce responsibility of subclass and remove unused parts
* 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
2018-08-17 03:28:02 +00:00
jenkins-bot af2b92856f Merge "Fix missing/mismatching type hints PHPDoc tags" 2018-08-16 08:39:29 +00:00
Thiemo Kreuz 2d7096bcff Fix missing/mismatching type hints PHPDoc tags
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
2018-08-16 07:07:20 +00:00
jenkins-bot d53af8b8d3 Merge "Use "false" as type hint in PHPDoc tags" 2018-08-16 01:00:05 +00:00
jenkins-bot ef233becf5 Merge "Make "@… array" type hints more specific" 2018-08-16 00:57:12 +00:00
jenkins-bot cc1a3aaa6b Merge "Escape message used in html" 2018-08-16 00:16:09 +00:00
jenkins-bot b0e11b45f0 Merge "Make use of inline {@see …} tags" 2018-08-15 22:18:56 +00:00
jenkins-bot e23cf162fe Merge "Migrate EchoLocalCache to MapCacheLRU" 2018-08-15 21:45:02 +00:00
Umherirrender e499631a37 Escape message used in html
Change-Id: Iee1c2bebec8756c5672e36c837fe9c2065479673
2018-08-15 20:19:51 +00:00
Aaron Schulz 4939bff723 Migrate EchoLocalCache to MapCacheLRU
Change-Id: Ie007bc5ec1db4d9686ced724b87f9cbc328aa339
2018-08-15 12:30:51 -07:00
Thiemo Kreuz 63eee2b9a1 Remove two unused properties from AttributeManager
These two properties are protected. I used
https://codesearch.wmflabs.org/search/?q=EchoAttributeManager%5B%5ET%3A%5D
to make sure no subclass exists that might use them.

Change-Id: I37c71db55bc4832968a1812142588dddaa81724a
2018-08-15 09:29:54 +00:00
Thiemo Kreuz e5546e50b6 Add missing strict "array" type hints to DiscussionParser
This patch adds a few strict type hints on the language level, not
only on the PHPDoc level as my other patches do.

Change-Id: Ie66f9ebf80317dcaf13e2e96a93332a1a93cebbe
2018-08-15 09:03:33 +00:00
jenkins-bot 15b15adcb3 Merge "Remove $wgEchoNewMsgAlert and 'echo-show-alert' preference" 2018-08-15 01:19:38 +00:00
jenkins-bot 7d305a77d0 Merge "Use ContentLanguage service instead of global $wgContLang" 2018-08-13 23:39:27 +00:00
Fomafix f8341386a0 Replace deprecated Linker::link() with LinkRenderer
Bug: T149346
Change-Id: Icfb0a96735f8f69d73c8d597e6c7b033ca3bcf1f
2018-08-13 23:36:47 +02:00
Fomafix a1f72bbfa0 Use ContentLanguage service instead of global $wgContLang
This change requires MediaWiki 1.32 which is already required in
extension.json.

Change-Id: I61856796d864c9493c1a7a875cb2415f11f081a9
Depends-On: I193f5b9a95430b0a05573c361715e053e5411e32
2018-08-13 23:30:34 +02:00
Paladox bacee60d42 Fix "PHP Warning: count(): Parameter must be an array or an object that implements Countable"
Change-Id: I6169f4226acd41c77d0b4b7710064dce45761bbd
2018-08-13 16:37:44 +00:00
Thiemo Kreuz 8a7c3a78a9 Use "false" as type hint in PHPDoc tags
Most modern IDEs as well as documentation generators understand the
keywords "false" and "true", when a bool can only be one of the two.

Change-Id: I83dd1f0cc0802fa74ee35e7ca7425615230a767f
2018-08-13 15:31:13 +00:00
Thiemo Kreuz fc59da2cca Add missing newlines before "use" sections
Change-Id: I15b4aaac007379370f832bc24e3cebfe54dda754
2018-08-13 09:29:32 +02:00
Thiemo Kreuz c1c3c7b672 Make "@… array" type hints more specific
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
2018-08-13 09:27:37 +02:00
Thiemo Kreuz cf4ba1e6b8 Make use of inline {@see …} tags
Tested with the quick preview (Ctrl+Q) feature in PHPStorm.

I'm also updating a few type hints I could not split off into a separate
patch, because the lines are to close to each other.

Change-Id: I312ec601a5f443c2b12515e34c574b8889c4c128
2018-08-13 09:17:15 +02:00
Kunal Mehta b0687600a2 Remove $wgEchoNewMsgAlert and 'echo-show-alert' preference
Unconditionally enable it for all users.

Bug: T58845
Change-Id: Ie3ba685cef8979fe750c449fec01992b32df0fba
2018-08-12 20:25:15 -07:00
Umherirrender dbfcd23b3b Pass correct IContextSource to HTMLForm
The special page is only a MessageLocalizer, not a IContextSource.
Its implements all methods of IContextSource, but are delegated to the
underlayed IContextSource. So pass it directly make phan happy, while
the current code works as expected

Change-Id: Ia9d83f2f71a466a2ba74540f96f165c96fb7ca00
2018-08-11 05:44:52 +00:00
jenkins-bot 96db879275 Merge "NotifUser: Remove basically-unused talk notification cache" 2018-08-10 02:05:21 +00:00
jenkins-bot 66ae28ae4c Merge "UserNotificationGateway: Use batching in markRead() and markUnread()" 2018-08-10 02:02:59 +00:00
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 a9afcfb43a UserNotificationGateway: Use batching in markRead() and markUnread()
Change-Id: I85452d0f0afe974d26a575e000f6ae2ceeddf06c
2018-08-09 16:34:04 -07:00
jenkins-bot 8151b212ee Merge "Clean up EventLogging integration" 2018-08-09 21:54:37 +00:00
jenkins-bot 2e56ca2d4b Merge "NotificationMapper: Use batching in deleteByUserEventOffset()" 2018-08-09 18:52:07 +00:00
Kunal Mehta b574e252f8 Clean up EventLogging integration
* Move revision ids out of configuration and into MWEchoEventLogging
class. Because the EchoInteraction schema is used both server and
client, we have to duplicate the revision id.
* Use EventLoggingSchemas attribute to register client-side schema in
extension.json instead of a hook.
* Check if EventLogging is enabled in MWEchoEventLogging instead of
$wgExtensionFunctions.
* Pass only whether the EchoInteraction schema is enabled to the
client-side instead of all of $wgEchoEventLoggingSchemas.

Change-Id: I968294f96cedac19dc9d8f53df14fecfb666ceee
2018-08-09 14:19:45 +00: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
Kunal Mehta 832d9d4d16 Remove $wgEchoEventLoggingSchemas qunit hack
The only place that reads the config variable is in ext.echo.logger,
which uses OO.getProp() to do so. If that property doesn't exist,
`undefined` will be returned, which we can force to boolean false.

Bug: T118488
Change-Id: Iac352b133950f6f2e4b88950c1fcd0c893284fd9
2018-07-26 19:34:42 -07:00
Kunal Mehta 2f5581c30a Move ext.echo.logger module registration to extension.json
Change-Id: Iec48ff2f2362f5861ee52fde3394a820f9cb2d07
2018-07-26 19:34:42 -07:00
Kunal Mehta 9a828c7b56 Use mw.track() to submit EventLogging data client-side
This avoids needing any dependencies on EventLogging in the module
definition, as well as allowing the extra dependencies to be lazy-loaded
as necessary.

Change-Id: I49b5be4be4f55cd4e27064247463b2ddb8e81296
2018-07-26 19:34:37 -07:00
Kunal Mehta 9f2383a727 Use UserGetDefaultOptions hook instead of $wgExtensionFunctions
$wgExtensionFunctions are run on every MediaWiki request, and should be
avoided unless necessary. Default user options should be controlled by
the UserGetDefaultOptions hook instead.

Bug: T180192
Change-Id: I2a79e078753d289c3ea2f04b613ce72c59a9e59a
2018-07-25 17:19:17 -07: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
Thiemo Kreuz 75a55b80ee Remove some non-helpful lines of documentation
Explaining that a variable named "$username" contains a "username" is
not helpful. One have to read this comment first to understand that it
does not add anything to what's already obvious from the variable name
and the type.

Change-Id: I9a43866498d0c94422caf16233f502320a8e36c9
2018-07-06 15:14:44 +00:00
Stephane Bisson 10a99b016b Handle missing presentation model
When a presentation model is specified for an event type,
check if the class actually exist before trying to use it.
Logs to debug when the class is not specified or doesn't exist.

This is useful for extensions that get undeployed
(looking at you, OpenStackManager). Their notifications
cannot really render since the code to render them
is not available anymore. This make them simply go away and
the notification counts get updated shortly after because
unrenderable notifications are marked as deleted.

Bug: T195253
Change-Id: I6335204942002bba3e73887ab81e55a27b4e181a
2018-07-03 12:49:20 -04:00
jenkins-bot 65470a8d10 Merge "Add timestamps to generated notifications" 2018-06-28 13:09:29 +00:00
Moriel Schottlender 592bc476b2 Add timestamps to generated notifications
Add the ability to create notifications with specific timestamps
when generating notifications through the maintenance script.

Note, that not all notifications can be given specific timestamp;
only notifications that do not involve a direct editing action
will be given this timestamp and their events will be created
as if the actions were taken at the given timestamp, with
1 minute intervals.

Change-Id: I9e6b8660178ca0734979946c8e6ec8d43fc3de41
2018-06-27 11:16:22 -07: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
jenkins-bot 1c6d589b1b Merge "Remove masterPos from the job specification." 2018-06-25 10:48:16 +00:00
Moriel Schottlender 94f17f7910 Always place items outside menu if there's less than two of them
Bug: T174927
Change-Id: I5a30cf4d5cdc3e7ea9ea7b0536e015de8825f785
2018-06-22 15:31:05 +00:00
Petr Pchelko bf2cc7e687 Remove masterPos from the job specification.
The `DBMasterPos` class is not JSON-serializable, so
we can not transfer the job in the kafka-based queue.
Before, we were waiting for slaves before executing the
job till the point in time when the job was submitted,
now we will just wait for slaves till the point in time
the job was executed. That lets up not to include the
database master position in the event and make it serializable.

Bug: T192945
Change-Id: I7c754bd1e899bad030cc6434be19daf2542e015f
2018-06-18 19:56:15 +03:00
jenkins-bot 61cfa13beb Merge "Update some PHPDoc tags for improved type safety" 2018-06-18 01:14:37 +00:00
jenkins-bot afec5a19ec Merge "Directly use Language::factory instead of wfGetLangObj" 2018-06-18 01:14:35 +00:00
Thiemo Kreuz 6aa6824f96 Update some PHPDoc tags for improved type safety
Change-Id: I7573ab01e88c86c25180bc56b3874505aa00a047
2018-06-17 19:04:54 +02:00
C. Scott Ananian 190377dbbc Replace uses of deprecated Language::truncate()
See I2291c69d9df17c1a9e4ab1b7d4cbc73bc51d3ebb for the anticipated
hard-deprecation of this method in core.

Bug: T197492
Change-Id: I4687db09c27480147cfa7a648a886b1670812deb
2018-06-16 09:30:06 -04:00
Max Semenik 0a09984f55 Get rid of call_user_func_array()
Yay PHP7!

Change-Id: I3bad8d1a5a65137d9617ccd39c65b8a97edbf01a
2018-06-08 01:03:46 -07:00
Fomafix 99173922c1 Directly use Language::factory instead of wfGetLangObj
Other places like Message::inLanguage also use
Language::factory( $user->getOption( 'language' ) ).

Change-Id: I911dc2319e1922276daa3eb3614a350c80b8b57f
2018-06-05 11:00:14 +02:00
Roan Kattouw d0714b2928 NotifUser: Simplify function signatures for getNotificationCount() and friends
The $cached and $dbSource parameters are now unused, so remove them.
This affects get{Notification,Alert,Message}Count and
getLastUnread{Notification,Alert,Message}Time.

There are some callers in other extensions and in skins, but none of
them pass any parameters (except one, which I fixed in Ice42930280da).

Change-Id: If6f10c4f163ecb1def5a150656a60d1ab5f44d52
2018-06-05 01:07:23 +00:00
jenkins-bot aa984f1b9b Merge "NotifUser: Add a doc comment for getForeignCount()" 2018-06-02 17:20:28 +00:00
jenkins-bot 205c937164 Merge "NotifUser: Simplify timestamp comparisons in getForeignTimestamp() too" 2018-06-02 17:14:01 +00:00
jenkins-bot ffa6922558 Merge "NotifUser: Remove $dbSource parameter from resetNotificationCount()" 2018-06-02 17:11:34 +00:00
jenkins-bot 533a58dfcc Merge "NotifUser: Un-merge getMemcKey() and getGlobalMemcKey()" 2018-06-02 17:11:33 +00:00
jenkins-bot bb453d23e3 Merge "NotifUser: Redo caching strategy for multi-DC compatibility" 2018-06-02 17:10:20 +00:00
Roan Kattouw fa21b7b0cd NotifUser: Un-merge getMemcKey() and getGlobalMemcKey()
We used to have code that called getMemcKey() with a boolean parameter
deciding whether to get a local or global key, but we don't do that
anymore: every code path now knows whether it needs a local or global
key. Consequently, move the code for global cache key generation back to
getGlobalMemcKey(), rather than having both be in getMemcKey() and
getGlobalMemcKey() being a wrapper.

Change-Id: If35bafc53e1e0086c31fd9675a9dc057e36f5717
2018-05-31 16:01:57 -07:00
Roan Kattouw 1fec0793e1 NotifUser: Remove $dbSource parameter from resetNotificationCount()
As Krinkle points out, it always writes to DB_MASTER, so it doesn't make
much sense to offer an option to read from DB_REPLICA. This also
resolves the race condition that I believe arises from the one caller
that passes in DB_REPLICA.

Change-Id: I6976e5479debc3f4a8f28d53b1616c01475772be
2018-05-31 00:53:06 +00:00
Roan Kattouw 0edd96da17 NotifUser: Add a doc comment for getForeignCount()
Change-Id: I47fc2d879b6292d70ba53f8a52f450eed83cfcb6
2018-05-31 00:52:59 +00:00
Roan Kattouw 5935a63731 NotifUser: Simplify timestamp comparisons in getForeignTimestamp() too
Change-Id: I89e75eeded95f7417f8fccfa6274fa19ff5a26c7
2018-05-31 00:52:52 +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
jenkins-bot bb3cb12262 Merge "CachedList: Use getWithSetCallback()" 2018-05-30 21:55:07 +00:00
jenkins-bot 0aef7d8d94 Merge "NotifUser: Make resetNotificationCount() default to DB_MASTER" 2018-05-30 21:55:06 +00:00
jenkins-bot 8eba5bba4e Merge "build: Updating mediawiki/mediawiki-codesniffer to 20.0.0" 2018-05-30 15:24:34 +00:00
Roan Kattouw 5c33f929bf CachedList: Use getWithSetCallback()
Bug: T164860
Change-Id: I0d89865fadcbc7f014e2d88a9a984228d44bc1c6
2018-05-30 05:15:20 +00:00
Roan Kattouw 32b82fa1fe NotifUser: Make resetNotificationCount() default to DB_MASTER
We almost always call it with DB_MASTER, and I'm pretty sure that the
one call that uses DB_REPLICA introduces a race condition. I didn't want
to change that quite yet, though, so I left it in for now.

Change-Id: Ia5a59fdda357b799e327b8ed224f3ccb09509a8a
2018-05-30 05:14:38 +00:00
Roan Kattouw 544129492d UnreadWikis: Check the actual object we're about to call a method on
In principle, if $alertCount > 0, $alertTime should never be null,
but it feels much safer to check $alertTime itself instead.

Change-Id: Ifb107e257fbcd65e8181e2a214028f1b3733ac30
2018-05-30 05:03:51 +00:00
Roan Kattouw e29d1253b3 UserNotificationGateway: Add getDB() method
So that classes that get a UserNotificationGateway dependency-injected
into them can get something to call Database::getCacheSetOptions() on.

Change-Id: Ie1c98f09d1581ea17809a4dfc68adec1e2805580
2018-05-30 05:02:17 +00:00
Roan Kattouw 0483c5ff67 EchoHooks: Fix copypasta in link to documentation page
Change-Id: Ic39468363a7c44d69f01d76ed6500104610b5ee0
2018-05-30 04:17:57 +00:00
Fomafix e20d0aaf4d EventPresentationModel:🏭 Force type Language for $language
The call of wfGetLangObj() is not necessary anymore.

Depends-On: I36834dbd119f4299f84b3dfe5e085eb0f6b8499c
Change-Id: I4e047393eee337432dd5edd0b4e3d650b6c7d393
2018-05-28 08:00:06 +02:00
libraryupgrader d1ef3a9514 build: Updating mediawiki/mediawiki-codesniffer to 20.0.0
Change-Id: I69d6907eadd607cbeaef63d813ef79aea4e7983c
2018-05-26 02:15:41 +00:00
Stephane Bisson 4690c2fb47 Use static newFromID instead of loadFromID
Bug: T192945
Change-Id: Ifd7c40dfef5147581a59d39a6dbe7312a9b82cc6
2018-05-17 22:29:09 +02:00
Stephane Bisson be88fc58c1 Make NotificationJob json-serializable
NotificationJob used to include an instance
of EchoEvent, which is not serializable.

With this change, it only includes the
event Id (int) and retrieve the event
instance in its run() function.

Bug: T192945
Change-Id: I00950ddfa37717c7dfc19efdca9701693622da5d
2018-05-08 15:52:55 -04:00
Kunal Mehta e33b42882d Move EchoHooks into includes/
Change-Id: I6fe78ca2763f1d449198d9f4e9a0c4d9b8e081f7
2018-04-09 00:24:23 -07:00
Umherirrender b166664efc Fix parameter docs
Change @param to @var
Add |null to nullable arguments
Removed comment out code

Change-Id: I535ad4d544284c1e0fb6f39c254761f0810b4cc7
2018-04-06 08:17:17 +00:00
Umherirrender 7e40fcc6ca Add missing use for namespace Wikimedia\Rdbms
Changed to interface, because the result of IDatabase::select is
directly returned and now the same type

Change-Id: Ib77e1f5c26ebf0b474dc944b15d6ef671a88e836
2018-04-06 07:56:13 +00:00
Umherirrender 52e91a605a Fix return type of EmailBatch::newFromUserId
Use | as separator for multiple classes

Change-Id: I246443b058436bec6b17675d4be46e130a4c075b
2018-04-04 12:35:54 +00:00
Max Semenik 6229cadd2e Revert my fix for summary pings in reverts
To redo more properly.

This reverts commit 74eacad8d6.

Bug: T190374
Change-Id: If178ed1a497df5276894f86d7a3312811651ce6b
2018-03-26 15:37:10 -07:00
Ed Sanders 34e3d5feba Replace double-check with checkAll from OOUI
checkAll was specifically designed as a
replacement for double-check.

Change-Id: Ibdd6865213107650b9004ab40e12c6a7453b6251
2018-03-22 21:23:33 +00:00
Max Semenik 74eacad8d6 Properly handle undos/reverts and links in them
Bug: T189819
Change-Id: I6957157c02557f88e7a951667bd13dbb66c82193
Depends-On: Ib1dc0c323a9a5083b462421c68575fc22ad4af35
2018-03-16 16:20:39 -07:00
Brad Jorsch 48d737471e Update for the actor table change
Core change I8d825eb0 begins the process of changing core database
tables from using xx_user and xx_user_text fields to using xx_actor.
This updates the extension to continue to function during and after the
transition.

Bug: T167246
Change-Id: I5c0c4879c5ab252be9c0582aa9efa871304a8ad8
2018-03-12 14:34:45 -04:00
Umherirrender 748d9888d5 Fix typo in word compatibility
Change-Id: I499ebc795837a59f4c3f77dfc7e2e7ab60ae4fd6
2018-03-09 22:22:55 +01: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
Max Semenik 63b831f376 Disable pings from summary for bots
Bug: T189040
Change-Id: Ie99ad42fd1f5c6d1618669ae395e72e656b97135
2018-03-06 18:27:17 -08: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
jenkins-bot e0d634689d Merge "Add various read-only mode checks" 2018-02-22 20:33:05 +00:00
Aaron Schulz 06b6aee301 Add various read-only mode checks
* Make updateCount() check isReadOnly()
* Make EchoUserNotificationGateway::markRead() check isReadOnly()
* Make ApiEchoMarkRead check if the echo DB is read-only
* Remove access getExternalLB() argument

Bug: T187942
Change-Id: Ibafce8839b46e28251a6c1c08dd61fec4756bf33
2018-02-22 08:07:19 -08:00
libraryupgrader 83bdf90eb5 build: Updating mediawiki/mediawiki-codesniffer to 16.0.0
The following sniffs are failing and were disabled:
* MediaWiki.Commenting.MissingCovers.MissingCovers

Change-Id: I2a48e5c27a7307b3982d11875180fc11f2a125d9
2018-02-15 09:51:55 +00:00
Umherirrender dc7d27a795 Split assignment and return statement
Doing it in two lines makes it easier to read
This makes also clear that this is not a broken condition

Change-Id: I9771b6457789b7dc572f2d73d1fae8c361f9a1e6
2018-02-06 22:52:47 +00:00
Kunal Mehta 0209f4eb2f Don't use deprecated SpecialPage::getTitle()
Change-Id: I20c7d058bb25207705c08fe293800a6d1e0aab0e
2018-02-04 18:53:08 +00:00
Phantom42 254cf8360b Fix multiple PHP class declarations in one file
All files containing more than one PHP class were split into
multiple files.

extension.json was updated to match new class locations.

Bug: T177809
Change-Id: I4e7d8f02164c3048c41c4c9fbe4be18a99e7abaa
2018-01-21 21:17:53 +00:00
Stephane Bisson ca27299f51 Format user-rights reason as plain text
Format user-rights reason as plain text
in both web and email since links
in notification body are not supported.

Bug: T172636
Change-Id: Ief5ff0aff18aad070f4388e075b5aae072d8f101
2018-01-09 08:41:21 -05:00
jenkins-bot 290e5f6348 Merge "PresentationModelSectionTrait: Use section anchor generation from code" 2018-01-04 16:59:59 +00:00
Umherirrender 08cb7a470a Change doc type from DatabaseBase to IDatabase
Change-Id: I853b7cef85fdd77c28a947a8f3601f84ba17359a
2017-12-22 23:20:13 +01:00
Thiemo Mättig 2e9a27558c Minor cleanups to PHPDoc blocks
Change-Id: I5890144521b6b54c798b1590ab8d102d74ada26a
2017-12-15 15:42:38 +01:00
Brad Jorsch d049fc8802 Use ParserOutput stateless transforms
See MediaWiki core change Ied5fe1a61. There's no need for a dependency
here, though, since it'll just ignore the extra parameter.

Change-Id: Iff28b00638c15de7307a130196bbb91cda91c3d1
2017-11-24 12:20:40 -05:00
Roan Kattouw babd3f76d3 PresentationModelSectionTrait: Use section anchor generation from code
We used to have to DIY it because the core method stripped links, but
with guessSectionNameFromStrippedText() this is no longer an issue.

This allows us to pick up the nbsp handling that was added to core in
129067c907.

Bug: T180689
Depends-On: I56b9dda805a51517549c5ed709f4bd747ca04577
Change-Id: I192218dd14464de5041ceb1c16125bbcd8f44f18
2017-11-22 18:17:37 -05:00
jenkins-bot c02e732f06 Merge "Prevent loading or saving of zeros in the database." 2017-11-17 21:29:22 +00: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
Fomafix 37ef8819de Use getHtmlCode() instead of getCode() for HTML attribute lang
The HTML attribute lang uses a BCP 47 conform language code.

Change-Id: I16c7521bb08062337d5eb1502d9e7d96c1b0cc48
2017-11-09 11:45:22 +01:00
WMDE-Fisch 4cb11b84ef Fix some doc blocks
Change-Id: Ieb55488792a4609e497a81687c04f4beb3b92b86
2017-11-07 17:06:17 +01:00
jenkins-bot 0c5694802b Merge "Update for deprecation of selectFields() methods" 2017-10-30 23:20:37 +00:00
Matěj Suchánek b7f189ca5a Make edit-user-talk notifications expandable
Bug: T162299
Change-Id: I79a5e52dc8b861bd0ed4a55ce5d80c5a97cddb70
2017-10-20 11:27:47 +02:00
Max Semenik 7568dae7b0 Get rid of double-escaping
Title fragment isn't supposed to be escaped on input. It gets escaped later,
when getFullURL() gets called on the title. This previously didn't matter much
because Sanitizer::escapeId() doesn't break anything if called repeatedly. However,
now it's deprecated anyway and uses legacy encoding so I need to get rid of it.

Change-Id: I6392604ac0841ae92a21ecb569c9643d7bc6231c
2017-10-18 18:52:21 -07:00
Umherirrender 546e3bdd55 Improve some parameter docs
Change DB_SLAVE in comments

Change-Id: Idd5787928b87f5af63864dc626cb603f281515d7
2017-10-18 18:44:52 +02:00
jenkins-bot 6338d229c7 Merge "Minor PHPdoc fixes" 2017-10-17 20:06:32 +00: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
WMDE-Fisch 713c28e861 Minor PHPdoc fixes
Change-Id: I037df8d0bd13dd7a8201fd1408bb2f642f9786b6
2017-10-13 13:48:05 +02:00
Brad Jorsch 93136b71ac Update for deprecation of selectFields() methods
Various selectFields() methods were deprecated in MediaWiki core change
Idcfd1556, replaced with getQueryInfo() methods.

Change-Id: I5d62ad76fdb64a9c6efd228f27e9b5f512f17d5e
Depends-On: Idcfd15568489d9f03a7ba4460e96610d33bc4089
2017-10-12 16:04:15 -04: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
Chad Horohoe 382d163f95 Remove unstub logic
User objects haven't been stubbed in awhile, and language objects
aren't being stubbed anymore.

While we're here, swap a few MWException -> InvalidArgumentException
since they're more accurate :)

Change-Id: I7e2f2aa135b024fb653c3ec13181d7015383ff2f
2017-10-03 23:15:51 +00:00
David Barratt 3ba76f7faa Use User Ids instead of User Names for Echo Mute
The echo mute list uses user names which are not stable. User ids should be used instead.

Bug: T173475
Change-Id: I947bcf37a8f85aaa105776d368dbd0ab76823aeb
2017-10-02 19:39:40 -04:00
jenkins-bot 746b965fb2 Merge "Fix PHPDoc Documentation" 2017-10-02 22:53:47 +00:00
David Barratt d76ff6e32f Fix PHPDoc Documentation
Documentation is throwing linter errors and needs to be fixed.

Bug: T173475
Change-Id: Ic120b6a7a1f29ea90a939c4348202c09d47c38f5
2017-10-02 18:40:46 -04:00
libraryupgrader 7a23ddf4b0 build: Updating mediawiki/mediawiki-codesniffer to 13.0.0
Change-Id: I7b19fab3b1100c4973600ec95ee24160e141c5ac
2017-09-24 09:49:43 +00:00
Mark A. Hershberger 36ffa115c7
Provide base href in Echo's HTML emails
While working on my own Echo notifications for CategoryWatch, I came
across this bug.  I was happy to see that someone else identified this
a while back.

Wikitext-to-html production for the body of Echo messages does
not fully qualify urls.  This means that links are created pointing
to, for example, "/w/index.php..." instead of
"http://example.com/w/index.php...".  Supplying a base URL in the html
for the message fixes this problem.

Bug: T141521
Change-Id: Icfb9f3be58b83d2a441972adb58fef1169169d7c
2017-09-19 22:15:56 -04: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
libraryupgrader 638633216a build: Updating mediawiki/mediawiki-codesniffer to 0.12.0
The following sniffs are failing and were disabled:
* MediaWiki.Files.ClassMatchesFilename.NotMatch
* MediaWiki.Files.ClassMatchesFilename.WrongCase
* MediaWiki.Files.OneClassPerFile.MultipleFound

Change-Id: I7cbf305fae765dbf68df07f84992c2d5ed5486c6
2017-09-01 04:48:56 +00:00
jenkins-bot e74713a3ba Merge "Add 'Mark all as read' button" 2017-08-13 16:19:56 +00:00
mdew192837 e88185c54e Add 'Mark all as read' button
Currently, the 'Mark all as read' button exists only for JS users.
This patch adds the button for no-JS users as well.

Bug: T96061
Change-Id: I1a62c56306597209540ffd694c8fb7b2a92885c9
2017-08-13 10:55:46 -05:00
Kunal Mehta 27fa8c4f7d build: Updating mediawiki/mediawiki-codesniffer to 0.11.0
Change-Id: I48f0b64f19f9582b40540fa1b42a39d281979624
2017-08-10 23:22:40 -04:00
Umherirrender 5b4730c9bc Improve some parameter docs
Change-Id: Ie71fb080926781f2905e6264be060203c56185ea
2017-08-09 17:21:10 +02:00
jenkins-bot 41d160692b Merge "Check canHaveTalkPage() before calling getTalkPage()" 2017-08-02 17:07:12 +00:00
Roan Kattouw 5039841581 Check canHaveTalkPage() before calling getTalkPage()
Bug: T172146
Change-Id: I13e9d040e215b04de7843767706f6799a7787524
2017-08-02 00:47:18 +00:00
Umherirrender 79b6f470af build: Updating mediawiki/mediawiki-codesniffer to 0.10.1
Change-Id: I2326cf81e907f2a02615f96f922b66fd2806defd
2017-07-26 21:34:44 +02:00
Ela 07cac5c9f7 New Article Reminder API
This will be used to submit a new article reminder, for a specified date.
The delay is not implemented yet.

Bug: T166973
Bug: T167450
Change-Id: I773bbe98e781957912350c481c850b3263cb1821
2017-07-19 11:07:22 +00:00
Roan Kattouw abff3f780d Replace EchoDiscussionParser::htmlToText with Sanitizer::stripAllTags()
The latter doesn't trim(), so add trim() calls in some cases.
User input is trimmed, parsed i18n messages are not.

Change-Id: I933a6a929bf7d3e2d1623ea537227dc8c731cb6f
2017-07-07 16:55:51 -07:00
Ela a4974ef1e1 Adding the first step in order to enable the visualization of the Article Reminder feature.
Includes feature flag, presentation model.
Temporarly hooks to new user creation.

Bug: T165755
Bug: T165754
Change-Id: Ic0a2ca07b0cd1597e5534bb1f3b748beb215ddfc
2017-06-30 19:45:24 +03:00
Kunal Mehta 95f83de225 phpcs: Fix "MediaWiki.Commenting.FunctionComment.WrongStyle" issues
Change-Id: Ieb1d52e6fd4e1de54e6f1bbfde849acd54fbe0dc
2017-06-22 14:14:28 +00: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
Matthew Flaschen 24a055c946 Correct license to MIT
This extension overall is under MIT, per Echo.php, extension.json,
and COPYING.

Change-Id: I39d533b671bb9eff3ba2e9faf5fcf482374b8e61
2017-06-20 20:32:39 -04:00
Matthew Flaschen 813ab5b54e Fix user talk exception for blacklist
There was a null-dereference for events without titles.

Also, it should only whitelist their own user talk space, not e.g.
mentions on someone else's user talk space.

Bug: T150419
Bug: T166627
Change-Id: If7d9cad4eb33ce1f1e6b7d86244332ad5dece954
2017-05-30 19:42:20 -04: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
Matthew Flaschen 6a38987198 Trivial docfix in DiscussionParser
Change-Id: I105b297333017dbce71cc42528a0e76f8be5da4b
2017-05-20 13:09:06 +02: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
Max Semenik 5003262d77 Don't use deprecated class
Change-Id: I76ad6b8cafb4fcf2f1f2ce32537a5314a66b64a0
2017-05-05 11:51:04 -07:00
Roan Kattouw 2e4e14498a EventMapper: Don't retry failed lookup queries on the master on GET
Only retry lookups if there are multiple DB servers and
changes were made in this request. This same logic is used
in a couple of places in MW core, like WikiPage::loadPageData()
and Revision::newFromConds().

Bug: T164505
Change-Id: If1af363f9687019864b5eaef72ffe0bc824a2223
2017-05-04 17:49:33 -07:00
jenkins-bot f19d9156a2 Merge "Fix counting of bundled mention notifications" 2017-05-03 10:53:54 +00:00
WMDE-Fisch 620855d770 Fix counting of bundled mention notifications
This patch will fix the notification counts in bundled mention notification
messages. The former method did not work at all due to false assumptions
what the getBundleCount method can be used for.

Since this is in the presentation only wrong messages should be fixed when
deployed

Bug: T164115
Change-Id: If316549a090c2d281a8d612e4985fd556eabc807
2017-05-03 10:40:40 +02:00
jenkins-bot 71e10ff246 Merge "MentionStatus: prefer failure-type" 2017-04-20 20:26:23 +00:00
Stephane Bisson dd77a46c1b MentionStatus: prefer failure-type
In MentionStatusPresentationModel, prefer
extra['failure-type'] to event-type to determine
why the mention was not sent.

Bug: T144614
Change-Id: Id3b55e15a0c1a8f3fee19cbe07983c6e373b309e
2017-04-20 12:21:02 -04:00
Stephane Bisson c46d56b018 Special:Notifications show unread by default if there's unread notifications
Bug: T162927
Change-Id: Ibdfaca90803eb8b12b12eb1781b0692e7336b7d9
2017-04-19 15:20:12 -04:00
This, that and the other 3f99672d5e Add proper message when user group expiry is changed
There's a lot more that could be done to improve user "rights"
notifications (really user group notifications), but this will do for now.

Bug: T159301
Depends-On: I5d32445f8e5b41599889b8488a2431e7a908f858
Change-Id: I27d52bc5c39219c832bf63a491faa1e421b0c024
2017-04-10 11:38:49 -07:00
Chad Horohoe f4a5ad9300 LoggerFactory is now namespaced, reference it properly
Bug: T161837
Change-Id: Ide941dc019163ed09f208caa7a615d1e3483bc91
2017-03-30 12:35:47 -07:00
Paladox ecae781538 Fix Illegal string offset 'ltr' in ResourceLoaderEchoImageModule.php
Make $paths an array.

@Krinkle came up with this fix. I just uploaded the patch.

Bug: T161420
Change-Id: I709808bfb0e620f7808175dc272fd57e88b663f5
2017-03-27 23:46:45 +00:00
MtDu 185e68a803 Support loading of secondary icons in RLEIM module
Before, secondary icons, such as linked, changes, thanks, and
userSpeechBubble were loaded in mw.echo.ui.icons.less. Now, an
extra icons attribute is passed when the module is loaded, allowing
RLEIM to know which icons to load. If this attribute is left out,
an MWException will be thrown.

Bug: T159394
Change-Id: I9b36a74bcf1da0d1c698845bd067b226fb81ac96
2017-03-01 23:45:04 -06:00
Roan Kattouw e0ecaad90e Log more info for unserialize failures, and don't treat them as errors
Bug: T159372
Change-Id: I1110465759bd831a9a324bf3f11a3add4f5f446b
2017-03-01 13:02:59 -08: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
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
jenkins-bot d3fb6d38ea Merge "Use internal diff engine" 2017-02-10 11:24:28 +00:00
WMDE-Fisch 9b0a6f7a47 Replace deprecated wfGetLBFactory() and wfGetLB() call
Change-Id: I500196084db57e9d74dc25a513cbebea9ae3c9a6
2017-02-09 17:43:40 +01:00
WMDE-Fisch a1cb603bb3 Use internal diff engine
wfDiff() is deprecated and using the internal diff engine is
recommended as replacement.

Bug: T93625
Change-Id: I60af08888ef4e0bc9b80b75495f6e9e3fa631002
2017-02-03 19:07:21 +00:00
Leszek Manicki c205cd85d3 Document return value EchoEventPresentationModel:getTruncatedX methods
Change-Id: Ic3416bc07bb2f47ff6800ab0de86ee7b23a7cc2e
2017-01-30 11:54:55 +01:00
Stephane Bisson 8524471820 Remove 'text' as a valid notifications output format
The ability to format notifications as text
has been removed in Ic5712c4ce265b6faabce7a4028b4294fe3c73f18.

Bug: T155874
Change-Id: I72cadbaaa01414ce46315a618da0cb46241ad93e
2017-01-25 10:33:44 -05:00
Reedy 569006f614 Pass 2 parameters to addDeprecation
Change-Id: I891f94d32d64296fdb121d632e94dfba4b09070f
2017-01-05 22:14:38 +00:00
Yuriy Shnitkovskiy a3784bef1d Fixed variable interpolation in DataOutputFormatter.php
Bug: T154369
Change-Id: Ib51165081797d3aa5e036e3fde771ac92e89baa3
2017-01-03 09:55:29 +02:00
Justin Du 67f926707e Add GENDER support to a few Echo messages
* echo-email-plain-footer
* echo-email-html-footer-preference-link-text
* echo-email-html-footer-with-link

Bug: T145439
Change-Id: I2d55a617910efa11effef1a469e6d845eebc5591
2016-12-28 10:43:40 -06:00
Thiemo Mättig a37742b422 Fix typos and incomplete PHPDoc tags
Change-Id: I29382492a7afd14440019c0c478f5a81c2254f59
2016-12-28 12:57:26 +01: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
jenkins-bot 312bec325c Merge "Update for API error i18n" 2016-12-06 20:03:32 +00: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
Roan Kattouw 49974544ba Split up $wgEchoConfig
$wgEchoConfig is a deeply nested structure that ExtensionRegistry can't handle well.
It also combined different things, and the version number was used for two
separate purposes.

Split this out into $wgEchoCacheVersion, $wgEchoEventLoggingVersion
and $wgEchoEventLoggingSchemas.

Change-Id: I2f9d5d111f7925fb057d423a3e7064bff5040205
2016-12-05 15:44:12 -08:00
jenkins-bot 9733505d1c Merge "Align Email format with Wikimedia color palette" 2016-11-28 16:11:21 +00:00
Amir Sarabadani 047b92e4c6 Align Email format with Wikimedia color palette
For Wikimedia color palette see: https://phabricator.wikimedia.org/M82

Change-Id: I6782148e94f4896397f93295ab44760c02556e25
2016-11-28 00:50:46 +03:30
Roan Kattouw ed613f2e26 Fix missing doublecheck icon on Special:Notifications on mobile
Bug: T146706
Change-Id: I918beabb1bcbe4a66c4252a795d379e2ff6591a9
2016-11-23 16:31:23 -08:00
Brad Jorsch f608d73287 Update for API error i18n
See Iae0e2ce3. Since Echo master requires core master, this just depends
on the master patch instead of trying to maintain BC.

Depends-On: Iae0e2ce3bd42dd4776a9779664086119ac188412
Change-Id: Icc088b31bc99e03ac88dfb44329df55318bf99b5
2016-11-14 12:48:24 -05:00
WMDE-Fisch 5d0a03fcf1 Fix typo in doc
Change-Id: I8a4c3119391ef436cb021b8512ccd3a2dce185f4
2016-11-01 15:08:29 +01:00
Aaron Schulz cfa0aa099a Fix bogus variable usage
Change-Id: I9100648d5b6be63a697a8660def33e592d010688
2016-10-17 19:53:10 -07:00
Kavitha Muthu d3d61409d3 Show orange alert and provide hook
Show orange alert for all notification types in the edit-user-talk
category and provide a hook to enable other extensions to prevent
the orange alert from appearing.

Bug: T137954
Change-Id: I0b49c3a5eb0a027f8839ab86e77c527357907dd0
2016-10-14 17:54:29 +00:00
Reedy 161f21ab5a Database and LoadBalancer documentation updates
Replace deprecated function calls

Change-Id: Id7e4136d7258abb61117fff73d51766954605737
2016-10-09 21:21:33 +01:00
addshore 4010faaf89 Add some typehints & phpdoc
Change-Id: Ic5751f0745685ea4db009458b5976907dc22c518
2016-10-05 23:27:02 +01:00
Reedy 21faa050f6 Replace Revision::getText()
Bug: T147380
Change-Id: I3864fc64bd178471b1454033adbc9137485d1563
2016-10-05 00:42:45 +01:00
Roan Kattouw 9d8e09e71b Don't show pages and counts related to disabled notification types on Special:Notifications
Bug: T147138
Change-Id: I4350377720644015a1db9789979fb80cd4844745
2016-10-04 11:35:30 -07:00
enigmaeth 5b9ee79253 Dropped call to WikiPage::getText()
Bug: T146994
Change-Id: I47c5258154749b70f380c1462a4d310a04f1d85b
2016-09-29 18:47:29 +00:00
jenkins-bot e888d95f1e Merge "Used parsed section titles for anchors" 2016-09-28 14:46:47 +00:00
Roan Kattouw 6eea6d93a1 Used parsed section titles for anchors
This allows us to link to the right section when the section
title contains templates or magic words.

* Add getParsedSectionTitle()
* Use it in getTitleWithSection()
** Stop using Parser::guessSectionNameFromWikiText() because it
   wants preprocessed wikitext, not fully parsed and stripped text
* Move getTruncatedSectionTitle() from EventPresentationModel to
  PresentationModelSectionTrait and make it use getParsedSectionTitle()

Bug: T134216
Change-Id: I877ff6b0ce4e64400f6e5f6284ae47a11cd4335b
2016-09-27 16:17:59 -07:00
jenkins-bot faf3bee07c Merge "Fix links to sections with [[links]] in their title" 2016-09-27 19:53:33 +00:00
jenkins-bot 4f2ef135a7 Merge "Make user rights notifications link to added/removed group" 2016-09-27 04:00:07 +00:00
Kavitha Muthu a518044bb3 Make user rights notifications link to added/removed group
This change was made to direct users to the added/removed group.
Notification about the change in the user's right will route the user
to a page about the group.

Bug: T55860
Change-Id: Iff5f4d38ca2cc479c269ef736a7fd957959a03dc
2016-09-27 03:53:53 +00:00
Roan Kattouw 229db67347 Fix links to sections with [[links]] in their title
We would generate things like #Foo_.5B.5Bbar.5D.5D
instead of #Foo_bar . Unfortunately this doesn't
fix section titles with templates / magic words
in them, because those are parsed at notification render
time instead of at notification generation time.

Bug: T134216
Change-Id: Ia171324a4a616c956ab08fcff38293f18dc765fa
2016-09-26 17:16:24 -07:00
Roan Kattouw 44a210c720 Defer cache write in EchoSeenTime::setTime()
This can be called on GET requests, like when visiting Special:Notifications,
and also from getTime() on a cache miss. Defer the write to the real
cache, but update the in-memory cache immediately.

Bug: T146492
Change-Id: I24db223ded9508942dc0ef1abf55952e98f444d0
2016-09-23 12:11:37 -07:00
Roan Kattouw 8269970305 Remove unused $flags parameter for EchoSeenTime::getTime()
It was always set to 0, and we were using the old (pre-2015)
get() interface so it wouldn't have worked anyway.

Change-Id: Ie92b223a485a5d9d256d2dc69d4ff3807e838878
Bonus: remove documentation for nonexistent parameter for setTime().
2016-09-23 11:53:59 -07:00
jenkins-bot f40f1aa36c Merge "Convert 'seenTime' to a global property" 2016-09-20 23:22:26 +00:00
Matthew Flaschen ffd9d4bb4d Fix moderation controller
The change to use DeferredUpdates had a missing use.

Change-Id: Ied72608c9b3aa597627aa5ea069c257f506c3c1b
2016-09-20 01:44:25 -04:00
jenkins-bot 21cd011dda Merge "Make sure bundledNotifications is an array" 2016-09-20 00:13:56 +00:00
Moriel Schottlender f47c554e1c Make sure bundledNotifications is an array
- Make sure that even if internal values of the array are null,
  the end-result is a valid array (with sequential keys)
- Verify that the API sent the UI an actual array, and if not,
  output an error to the console.

Bug: T145825
Change-Id: Ibdf17c58fe88e3e2547dde62cd4d3d06e089cbc8
2016-09-19 23:08:14 +00:00
jenkins-bot 92c7c8d521 Merge "Remove primary link from the bundle of page linked notification" 2016-09-19 22:59:15 +00:00
Moriel Schottlender 1575e2bb7a Convert 'seenTime' to a global property
This transforms seenTime concept to a global property for all wikis
and sources, and updates the global seen time on opening the popup.

Bug: T134855
Change-Id: I67bcc4b346237317c7a9204dd43cd0e9ee02792f
2016-09-19 14:37:31 -07:00
Moriel Schottlender 58c53af1d1 Remove primary link from the bundle of page linked notification
Also, make sure that the bundle follows the same behavior as the
xwiki bundle, where if it does not have a primary link, the 'click'
event triggers the 'expand' action.

Bug: T145902
Change-Id: I456bf76a7bd531ffcad5462708f37cd54d8af99d
2016-09-19 14:16:43 -07:00
jenkins-bot bac8d67e99 Merge "Count the number of success & failure notifs sent" 2016-09-19 08:14:32 +00:00
Matthew Flaschen f2327a919b Fix GENDER without explicit parameter
Although we generally use getViewingUserForGender, these messages
are UI and in user language, so we should change the flag anyway.

getViewingUserForGender is essential for messages that are used
in batch jobs.  Some messages technically don't require it, though
it's probably best to be consistent anyway.

Bug: T144538
Change-Id: I7b57777ab93b5752165c7bdd85fa5ce66b294b22
2016-09-14 16:39:49 -04:00
addshore cb575928a9 Count the number of success & failure notifs sent
Change-Id: I3e11bc8878ddf48265c628d828ee700f3aee7bbb
2016-09-14 13:35:03 +02: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
jenkins-bot 1f3517e562 Merge "Fix seen time for new users" 2016-09-13 17:31:59 +00:00
Moriel Schottlender cc36178e4a Add {{GENDER}} support to dynamic action messages
Make sure we pass the current user to the message, since empty
{{GENDER:|}} doesn't seem to work in PHP.

- Add parameter to documentation
- Add {{GENDER}} syntax to en.json as example
- Add parameter to the message creation

Bug: T144538
Change-Id: Ifc5e3bbe8309cc9ce120b7d61cdc050d7055aacc
2016-09-12 15:30:29 -07:00
jenkins-bot 28248c0cc2 Merge "Actually insert target page entries when creating an Event" 2016-09-12 21:32:03 +00:00
Stephane Bisson d7845da3f6 resetNotificationCount() from replica with no lag
When notifications are being moderated, the unread count
for affected users has to be recalculated.

It was initially done using DB_SLAVE but it was leading
to inconsistent data since that database did not know
about recently deleted notifications.

It was changed to DB_MASTER but it potentially led
to too many queries on master.

This patch tries to wait for the replica to have
caught up with those changes and use it to update
the unread count for the affected users.

Bug: T93673
Change-Id: Ib4a845e82f686dd7ed807ab21a28490014b56604
2016-09-12 19:59:02 +00:00
Stephane Bisson bc03468473 Actually insert target page entries when creating an Event
This was broken in Ib57510e6b0e9202a7e035f8ea59955dca8a0b24a

Bug: T145232
Change-Id: Ieaad1febaf07bdcf8aee3761afbd039c082fc9ad
2016-09-12 15:05:18 -04:00
jenkins-bot 7f24836607 Merge "Make PresentationModel::getPrimaryLinkWithMarkAsRead() final" 2016-09-12 13:28:05 +00:00
Kunal Mehta 7051cfb2a5 Make PresentationModel::getPrimaryLinkWithMarkAsRead() final
Subclasses should not override this. Also fix the return type phpdoc of
getNotificationCountForOutput().

Change-Id: Ia6963794d3a68dca742fe52ac197edf1575bed76
2016-09-11 12:46:08 -07:00
Moriel Schottlender 615ffb1125 Always cap notification count based on MWEchoNotifUser::MAX_BADGE_COUNT
Also increase Echo version so we update the cache.

Bug: T144707
Change-Id: Ie939d313c8c6a8168fa3eb3036d9275270575559
2016-09-09 17:15:15 -07:00