Commit graph

52 commits

Author SHA1 Message Date
DannyS712
73c7d7fea9 EmailNotification: fix misplaced tab
Change-Id: I2479e596f7c93d4527bb8db800e570d15bccce03
2021-09-20 22:25:20 +00:00
Fomafix
c7ebc1ec44 Fix various typos in documentation
Bug: T201491
Change-Id: I144c120cc88bda723c8608ed7fb0ccb709f295f1
2021-08-23 09:03:44 +00:00
Petr Pchelko
c621548cf8 Convert mail namespace to Authority/UserIdentity
Change-Id: I1e1ea72f94735ddaf66eab29aad1296e1abffb9b
2021-04-01 15:46:09 -06:00
DannyS712
c932f620d7 EmailNotification: clean up with modern coding conventions
Declare one variable at a time
Add some documentation
Add some whitespace for readability
Replace some globals with retrieval from MainConfig
Should be a no-op

Change-Id: Ie58e56d61808d00fea99c35cd1c83a30d6aa28af
2021-03-31 02:58:27 +00:00
Reedy
50fe6326ef Remove some space indenting
Change-Id: I82436948fdb1f9abc5c13d32c732e1bf122a0516
2020-09-14 22:58:25 +01:00
Ed Sanders
7683f7d839 Use strict (in)equality with namespaces constants when LHS is definitely an integer
Change-Id: I8fede00dfe1270d93c5d78d3c36e788cddfc8a99
2020-07-31 18:03:28 +01:00
MusikAnimal
1ff6ca3fca Filter out expired watched items when sending email notifications
Bug: T253035
Change-Id: I9ebfee4042b6ac40726162fa8c887f757d7528b8
2020-06-24 12:07:08 -04:00
Tim Starling
47a1619027 Remove terminating line breaks from debug messages
A terminating line break has not been required in wfDebug() since 2014,
however no migration was done. Some of these line breaks found their way
into LoggerInterface::debug() calls, where they mess up the formatting
of the debug log.

So, remove terminating line breaks from wfDebug() and
LoggerInterface::debug() calls.

Also:
* Fix the stripping of leading line breaks from the log header emitted
  by Setup.php. This feature, accidentally broken in 2014, allows
  requests to be distinguished in the log file.
* Avoid using the global variable $self.
* Move the logging of the client IP back to Setup.php. It was moved to
  WebRequest in the hopes that it would not always be needed, however
  $wgRequest->getIP() is now called unconditionally a few lines up in
  Setup.php. This means that it is put in its proper place after the
  "start request" message.
* Wrap the log header code in a closure so that variables like $name do
  not leak into global scope.
* In Linker.php, remove a few instances of an unnecessary second
  parameter to wfDebug().

Change-Id: I96651d3044a95b9d210b51cb8368edc76bebbb9e
2020-06-03 12:01:16 +10:00
Tim Starling
68c433bd23 Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.

General principles:
* Use DI if it is already used. We're not changing the way state is
  managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
  is a service, it's a more generic interface, it is the only
  thing that provides isRegistered() which is needed in some cases,
  and a HookRunner can be efficiently constructed from it
  (confirmed by benchmark). Because HookContainer is needed
  for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
  SpecialPage and ApiBase have getHookContainer() and getHookRunner()
  methods in the base class, and classes that extend that base class
  are not expected to know or care where the base class gets its
  HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
  getHookRunner() methods, getting them from the global service
  container. The point of this is to ease migration to DI by ensuring
  that call sites ask their local friendly base class rather than
  getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
  methods did not seem warranted, there is a private HookRunner property
  which is accessed directly. Very rarely (two cases), there is a
  protected property, for consistency with code that conventionally
  assumes protected=private, but in cases where the class might actually
  be overridden, a protected accessor is preferred over a protected
  property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
  global code. In a few cases it was used for objects with broken
  construction schemes, out of horror or laziness.

Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore

Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router

setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine

Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-05-30 14:23:28 +00:00
Reedy
4cd8d9cff5 Fix numerous PSR12.Properties.ConstantVisibility.NotFound
Change-Id: I2ec09c02c2e4ed399d993cb1871e67df02167ca8
2020-05-11 01:36:36 +01:00
Petr Pchelko
7b4eafda0d Replace usages of deprecated User::isAllowed. Step 2.
Bug: T220191
Depends-On: I509cd88355cfd0cc074f4135ec86399b4075f89f
Change-Id: I2341e6f1d108c92924620fba3c64ec090cb09918
2019-09-11 16:00:03 -07:00
Derick Alangi
3cc65c87e3 mail: Avoid use of global state and use MediaWiki services DI
Change-Id: If335cb6a220ebc5eb7487e51ee097f9d2afa0d2d
2019-08-27 14:19:49 +01:00
Derick Alangi
02bbbdfa53 Mail: Add visibility for some methods without method visibility
Carefully, I checked usage of these methods in our code bases and
added the best possible visibilities to them. Not sure if I missed
something but let me know if I did.

Used private & public where suitable for the various methods. As for
__toString(), this is a magic method, so should be public per PHP docs.

Change-Id: Ie0987f4a984cac2f5eb1d9e21a305ad9467a8eb2
2019-06-30 15:32:20 +00:00
David Barratt
e86a060284
Deprecate User::isBlocked()
The method User::isBlocked() attempts to answer two questions:
(1) Does the user have a block?
(2) Is the user prevented from performing this action?
The method can answer #1, but it cannot answer #2. Since User::getBlock() can
also answer #1, this method is redundant. The method cannot answer #2 because
there is not enough context in order to answer that question.

If access is being checked against a Title object, all access checks can be
performed with PermissionManager:userCan() which will also check the user's
blocks.

If performing all access checks is not desirable, using
PermissionManager::isBlockedFrom() is also acceptable for only checking if the
user is blocked. This method does *not* determine if the action is allowed,
only that the user's block applies to that Title.

If access is being checked without an existing Title, User::getBlock() can be
used to get the user's block. Then Block::appliesToRight() can be used to
determine if the block applies explicitly to a right (or returns null if
it is unknown or false if explicitly allowed). If the user is creating a new
Title, but the text of the title is not yet known (as in the case of Wikibase),
access should be checked with Block::appliesToNamespace().

Bug: T209004
Change-Id: Ic0ad1b92e957797fee8dcd00bd1092fe69fa58f1
2019-04-25 11:47:44 -04:00
Reedy
c13fee87d4 Collapse some nested if statements
Change-Id: I9a97325d738d09370d29d35d5254bc0dadc57ff4
2019-04-04 19:02:22 +00:00
Derick Alangi
4ff82a335a i18n: Add line-break in email notificaton for minor edits
Added missing line-break in email notification specifically after
page summary or immediately before $PAGEMINOREDIT (for minor edits).
In addition, if the edit is not marked as a "minor edit", avoid the
line break.

Bug: T176595
Change-Id: I68cc249c3546eb7fed0834063f15304e3c245e55
2019-03-18 12:40:18 +00:00
James D. Forrester
4577b5f6dc Drop EmailNotification::updateWatchlistTimestamp(), deprecated in 1.27 and unused
Change-Id: Idad6f5aa579e41e941d1074465dd2f0e0f4577dc
2019-02-09 12:47:14 -08:00
Thiemo Kreuz
734a969d55 Safe replacement of a lot of !count() with === []
This was originally a global search and replace. I manually checked all
replacements and reverted them if (due to the lack of type hints) either
null (that would be 0 when counted) or a Countable object can end in the
variable or property in question.

Now this patch only touches places where I'm sure nothing can break.

For the sanity of the honorable reviewers this patch is exclusively touching
negated counts. You should not find a single `!== []` in this patch, that
would be a mistake.

Change-Id: I5eafd4d8fccdb53a668be8e6f25a566f9c3a0a95
2019-01-15 17:28:49 +01:00
Mark A. Hershberger
9d9e3117c7 EmailNotification should provide a getter for pageStatus
Extensions that have hooks for
UpdateUserMailerFormattedPageStatus (to provide additional
pageStatus indicators) need a way to make sure that, when their
hook is called in SendWatchlistemailNotification, they only
notifications handling their pageStatus indicator.  This allows them
to fetch the protected property.

Bug: T175104
Change-Id: I2beb5b3576f2cd739dab16b9adf613c96636edd3
2018-12-21 01:36:33 +00:00
Alangi Derick
b5ace113e7 mail: Correct return value of sendPersonalised() method
If email is not successfully sent, return Status (with appropriate
status error) and also, if successfully sent, return Status::newGood().

Change-Id: I602e30641b88614087d9aff83cf8c93e32af7b81
2018-12-03 16:23:25 +00:00
Alangi Derick
eb251abc62 Fix code style in EmailNotification.php
Code style fix for namespace "use" statement.

Change-Id: I0755481f640aae535c8328824812e25db467e528
2018-10-25 18:57:22 +00:00
Alex Monk
02b2086d95 EmailNotification: Add newline before minor edit text
Otherwise you get something like this:
"Editor's summary: interwiki fix This is a minor edit"
It's not entirely clear that the editor's summary has ended and the minor edit
text has been added by the software.

Change-Id: Iab79b5f8a1f6f319e9fd284835b7a4e86c3f0394
2018-09-29 19:08:13 +02:00
Aryeh Gregor
90d4f56fe4 Mass conversion of $wgContLang to service
Brought to you by vim macros.

Bug: T200246
Change-Id: I79e919f4553e3bd3eb714073fed7a43051b4fb2a
2018-08-11 22:44:29 -06:00
James D. Forrester
73aeb82fab EmailNotification: Hard deprecate updateWatchlistTimestamp()
Soft-deprecated in 1.27.

Depends-On: Ie7073f2048ba2b79a8b36ad913453008ec3555ce
Change-Id: If1dd2f8211c808ab0e284d7a3fb0b24610a0b32d
2018-02-03 03:48:33 +00:00
Matthew Flaschen
6e5e278494 Split minoredit into minoredit and enotif_minoredit
This allows minoredit to have links, while enotif_minoredit can
not.

Change-Id: I7aff9e5a5e6d460f6fce7da36a32e4717b247e4c
2017-07-27 20:13:58 -04:00
Mark A. Hershberger
6c7d4481d7 Update documentation URL
Change-Id: I6a32689c5d224674fe96ad631b073f9efba47e3f
2017-05-30 22:16:22 -04:00
James D. Forrester
9635dda73a includes: Replace implicit Bugzilla bug numbers with Phab ones
It's unreasonable to expect newbies to know that "bug 12345" means "Task T14345"
except where it doesn't, so let's just standardise on the real numbers.

Change-Id: I6f59febaf8fc96e80f8cfc11f4356283f461142a
2017-02-21 18:13:24 +00:00
addshore
818984e5cb Remove WatchedItemStore::getDefaultInstance
Change-Id: I0c7d706fabee8d1f6fcfbc4c568f375953de8058
2016-05-06 08:47:37 +00:00
Kunal Mehta
c9d885f3b4 Namespace LinkTarget under MediaWiki\Linker
And add a GPL file header while we're at it.

Change-Id: I15a6f240124c879b21fb655ade1baaebf4f34ffd
2016-04-21 17:19:10 -07:00
Reedy
b5656b6953 Many more function case mismatches
Change-Id: I5d3a5eb8adea1ecbf136415bb9fd7a162633ccca
2016-03-19 00:20:58 +00:00
addshore
a683b11b23 Move EmailNotification::updateWatchlistTimestamp to WatchedItemStore
Flow is the only thing remaining that uses this deprecated method.

Change-Id: Iaa4e1e34cb3f2a91c163565fb0107c500e3852d7
2016-03-08 18:44:05 +00:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
addshore
627a47801b Use LinkTarget in EmailNotification::updateWatchlistTimestamp
Change-Id: I3a59839b3ec4db42966afa1db5ad0252fafa8cb9
2016-02-03 16:59:45 +01:00
Aaron Schulz
5e1d0584b7 Code style cleanups to notifyOnPageChange()
Change-Id: I08593be2eba6417cdfae31b1aa1021da7db00c74
2016-01-29 16:03:29 -08:00
Aaron Schulz
334e8f8f9d Remove $wgEnotifUseJobQ
Always treat this as on and simplify the code.
This will also make it easier to move updateWatchlistTimestamp() into
the EnotifNotifyJob class to avoid query timeouts.

Change-Id: I8ceaa42cdcfe3ad00a26368be6a73052be329045
2016-01-29 12:24:16 -08:00
saper
f415a29a15 $wgUsersNotifiedOnAllChanges should not send mail twice
Also make sure that normal watchlist functionality
works for the $wgUsersNotifiedOnAllChanges, for
example changes should marked 'bold' since last visit.

Bug: T69041
Change-Id: I7d53f07ed3dceb5b1c541091fd69beca3fb3e94f
2015-12-14 01:11:05 +00:00
addshore
06b3acc333 Of course EmailNotification::updateWatchlistTimestamp returns users ids
Change-Id: I04b2a8f97527c2bcd3f993b60e4100915b7f4c18
2015-10-13 17:30:04 +01:00
Siebrand Mazeland
6f1db0e3c9 Fix PHPCS warnings in /includes/mail/
Change-Id: Iea420ddecac86ef9a6f34b420b0cd151ba604e91
2015-09-28 13:47:16 +02:00
Kunal Mehta
4e09a3e903 Set 'List-Help' header for watchlist emails
Added an option to UserMailer::sendMail() to allow adding arbitrary
headers to emails.

Bug: T58315
Change-Id: I01a60430bf39f6bd104269b7246767f016eb9cd5
2015-08-19 09:37:45 +00:00
jenkins-bot
02f609e068 Merge "Don't send email notifs to blocked users if $wgBlockDisablesLogin is true" 2015-08-13 16:44:05 +00:00
Kunal Mehta
c8ac9622ea Clean up UserMailer::send() parameters
$replyto and $contentType should now be passed as an array of $options.
This will make it easier to add more options in the future without
having a long list of optional parameters.

Change-Id: I2c38bb438bd01e0ed2552024a40311f3e8e2dc08
2015-07-20 21:34:44 -07:00
Matthew Flaschen
40761e9ee7 Fix inaccurate documentation re $wgEnotifMinorEdits
In actuallyNotifyOnPageChange, the $wgEnotifUserTalk is inside
a check involving $wgEnotifMinorEdits, so it won't fire if
it's a minor edit and $wgEnotifMinorEdits is false.

Change-Id: I6576cb1735db5d9288257e6877b8755450d0dacd
2015-07-08 20:30:17 -04:00
Glaisher
32359cca9a Don't send email notifs to blocked users if $wgBlockDisablesLogin is true
Previously, private data could be leaked on private wikis where
this configuration is common. To prevent this, do not send email
notifications on page changes for blocked watchers and blocked
talk page owners if $wgBlockDisablesLogin is true.

Bug: T54453
Change-Id: I17408e1038ae10ee01eab747591ef2d9c86b106e
2015-06-16 09:52:49 +00:00
jenkins-bot
34ebdaff86 Merge "wl_notificationtimestamp code comments typo, false statement" 2015-06-03 13:37:33 +00:00
Federico Leva
17b05db14c wl_notificationtimestamp code comments typo, false statement
The timestamp is updated earlier.

Change-Id: I5c40affc346b85fa5350c381ee3f93c86b26d454
2015-06-02 10:23:24 -06:00
Aaron Schulz
a17cdcbf5b Use lazyPush() instead of push() in a few places for jobs
Change-Id: I56661ea29988e4ee217a63f4c3ffcb78333cc454
2015-05-18 10:31:24 -07:00
Ricordisamoa
2ae155da52 Fix phpcs errors in includes/
Mostly Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines

Change-Id: I678b2f0902f11cd1dfa1611b9da24e7237df9122
2015-01-08 20:15:07 +01:00
Chad Horohoe
aa21e125a3 Remove obvious function-level profiling
Xhprof generates this data now. Custom profiling of various
sub-function units are kept.

Calls to profiler represented about 3% of page execution
time on Special:BlankPage (1.5% in/out); after this change
it's down to about 0.98% of page execution time.

Change-Id: Id9a1dc9d8f80bbd52e42226b724a1e1213d07af7
2015-01-07 11:14:24 -08:00
Aaron Schulz
e369f66d00 Replace wfRunHooks calls with direct Hooks::run calls
* This avoids the overhead of an extra function call

Change-Id: I8ee996f237fd111873ab51965bded3d91e61e4dd
2014-12-10 12:26:59 -08:00
Erik Bernhardson
3069453eb3 Move EmailNotification watchlist handling into helper method
Pulls one pure method with no state from EmailNotification into a 
public static method.  This is done so that extensions (Flow, maybe
others) can replace the Email notifications with alternative ones (Echo)
while still updating the watchlist.

A better solution might be to extricate watchlist update from email
notifications, but this seems like a reasonable first step.

Bug: 66876
Change-Id: Iae213b87706c447b880244711e7747954423bb69
2014-09-18 13:55:31 +00:00