Commit graph

359 commits

Author SHA1 Message Date
jenkins-bot
f898b49c98 Merge "docs: Hook interface doc comment review" 2020-04-21 06:41:19 +00:00
jenkins-bot
cc89a81451 Merge "Automatically generated hook interfaces" 2020-04-21 00:07:41 +00:00
apaskulin
c44488f725 docs: Hook interface doc comment review
Edited doc comments for hook interfaces to improve
consistency and add type hints.

Bug: T246855
Change-Id: I38fa802463cd6f39bf5946dbbeb1b3ebaea604b2
2020-04-21 09:10:08 +10:00
jenkins-bot
1421ca6b65 Merge "Optimize email sending on password reset" 2020-04-20 17:03:09 +00:00
Aaron Schulz
1260bf71da Migrate CdnCacheUpdate to MultiHttpClient and deprecate SquidPurgeClient
Bug: T250417
Change-Id: I4ed471c0b50a94426cfea4ae326454b98419e218
2020-04-20 17:03:32 +01:00
Tim Starling
f5aaf75ad1 Automatically generated hook interfaces
Add hook interfaces which were generated by a script which parses
hooks.txt and identifies caller namespaces and directories.

Hook interfaces are mostly placed in a Hook/ subdirectory
relative to the caller location. When there are callers in multiple
directories, a "primary" caller was manually selected. The exceptions to
this are:

* The source root, maintenance and tests, which use includes/Hook. Test
  hooks need to be autoloadable in a non-test request so that
  implementing test interfaces in a generic handler will not fail.
* resources uses includes/resourceloader/Hook
* The following third-level subdirectories had their hooks placed in
  the parent ../Hook:
    * includes/filerepo/file
    * includes/search/searchwidgets
    * includes/specials/forms
    * includes/specials/helpers
    * includes/specials/pagers

Parameters marked as legacy references in hooks.txt are passed
by value in the interfaces.

Bug: T240307
Change-Id: I6efe2e7dd1f0c6a3d0f4d100a4c34e41f8428720
2020-04-20 13:31:05 +10:00
suecarmol
632fa50065 Optimize email sending on password reset
Improve performance of sending emails when a user resets a password.

Bug: T247017
Change-Id: I9edb0e4c8845f7a9082035de66f5965c3f9b762d
2020-04-16 13:59:08 -05:00
Aaron Schulz
3c7f29a6b9 Add small HtmlCacheUpdater service class to normalize purging code (2)
This is a re-submit of 35da1bbd7c, which was accidentally merged before
CR (and reverted with aa4da3c2e8).

The purge() method handles purging of both file cache and CDN, using
a PRESEND deferred update. This avoids code duplication and missing
file cache purge calls.

Also:
* Migrate HTMLCacheUpdate callers to just directly using HTMLCacheUpdateJob
* Add HtmlFileCacheUpdate class and defer such updates just like with CDN
* Simplify HTMLCacheUpdate constructor parameters
* Remove BacklinkCache::clear() calls which do nothing since the backlink
  query does not actually happen until the job runs

Bug: T230025
Change-Id: Ic1005e70e2c22d5bd1ca36dcdb618108ebe290f3
2020-04-14 03:19:07 +00:00
jenkins-bot
24b1aaeb98 Merge "RefreshSecondaryDataUpdate: Commit before running sub-updates" 2020-04-11 09:47:31 +00:00
DannyS712
318e20df37 Replace uses and hard deprecate LinksUpdate revision methods
Also removes all uses of Revision from RefreshSecondaryDataUpdate

Bug: T249397
Change-Id: Ic110a66f79db8c5834847b664f3a8449eceb9d83
2020-04-09 22:03:24 +00:00
Brad Jorsch
b8858d6d5b RefreshSecondaryDataUpdate: Commit before running sub-updates
The call to `$this->updater->getSecondaryDataUpdates()` probably started
an implicit transaction, and a sub-update may have tried to register a
callback to watch for a rollback which would make that implicit
transaction non-empty.

Bug: T248003
Change-Id: Ib9db8ec9c43c8b2871f283733ed6a05d2dec6dd1
2020-04-09 11:17:00 -04:00
jenkins-bot
516c859643 Merge "CdnCacheUpdate: Accept Titles in addition to strings" 2020-04-08 10:23:07 +00:00
DannyS712
c3dc69b243 Add LinksUpdate RevisionRecord methods
Old Revision methods are soft deprecated

Bug: T249397
Change-Id: I92c1dc4d44476ef47290969ef8b984f96e2be7c0
2020-04-07 15:53:18 +00:00
Brad Jorsch
d83e00cb92 CdnCacheUpdate: Accept Titles in addition to strings
The class was already documented as "given a list of URLs or Title
instances", this makes that work.

Title objects will have ->getCdnUrls() called when the update is
resolved, which avoids problems like those encountered in T240083 where
that was being called too early.

Bug: T240083
Change-Id: I30b29a7359a8f393fb19ffc199211a421d3ea4d9
2020-03-19 09:56:19 -04:00
Umherirrender
3161311c5a Use MediaWikiServices::getMessageCache
Change-Id: I07fcc9529991adc634c10e5ed8498ac138a1c2b7
2020-03-14 14:25:03 +01:00
jenkins-bot
43705de4f9 Merge "Add RefreshSecondaryDataUpdate and use it in DerivedPageDataUpdater" 2020-03-12 17:43:57 +00:00
Aaron Schulz
1f4efc6c34 Add RefreshSecondaryDataUpdate and use it in DerivedPageDataUpdater
This class implements EnqueueableDataUpdate and can be pushed as a
job if it fails to run via DeferredUpdates.

Unlike a1f7fd3ada, make RefreshSecondaryDataUpdate skip failing
updates in doUpdate(). Instead of throwing the first exception from
any update, log any exceptions that occur and try all the other
updates. The first error will be re-thrown afterwards.

Also, make sure that each DataUpdate still has outer transaction
scope. This property is documented at mediawiki.org and should not
be changed.

Add integration tests for RefreshSecondaryDataUpdateTest.

Bug: T218456
Bug: T206283
Change-Id: I7c6554a4d4cd76dfe7cd2967afe30b3aa1069fcb
2020-03-11 00:42:48 -07:00
Timo Tijhof
14a8713e93 exception,deferred: Standardise on 'exception' for uncaughts and fatals
Bug: T247113
Change-Id: Id72cae0672169e8d2622bbc67c3c0b59e7c8ad54
2020-03-06 20:16:22 +00:00
Aaron Schulz
6b12696452 Move UIDGenerator code to a service and put it under /libs
All MediaWiki dependencies have been removed or injected.

Change-Id: I01c9e96edd6b03496c1595670967ffa5a4069c9d
2020-02-18 00:20:40 +00:00
Aaron Schulz
e3a08b067f Make SiteStatsUpdate avoid setting negative values in the table
Change-Id: I0ade767a174e0fa1bc0d0982cb92c14d48991f33
2020-02-15 21:57:10 +00:00
Ricordisamoa
1b3bc281ac Clean up redundant Exception|Throwable union type
PHP 7.0 makes many error conditions throw instances of the new Error class
which does not extend the known Exception.
The Throwable interface provides a concise and type-safe way of handling
either, e.g. for logging purposes, but HHVM did not support it, requiring
tedious fallback checks.

This commit replaces occurrences of Exception in code paths equally
covered by Throwable, like Exception|Throwable parameter and return types
(also nullable), instanceof guards, duplicated `catch` blocks, as well as
related comments and documentation blocks, with the exception of $previous
parameter descriptions consistent with the manual at
https://www.php.net/manual/en/exception.construct.php

Proper type declarations have been added or reinstated where possible.

Change-Id: I5d3920d3cc66936a350314e2f19c4f6faeffd7c0
2020-02-12 20:28:40 +00:00
Peter Ovchyn
61e0908fa2 languages: Introduce LanguageConverterFactory
Done:
* Replace LanguageConverter::newConverter by LanguageConverterFactory::getLanguageConverter
* Remove LanguageConverter::newConverter from all subclasses
* Add LanguageConverterFactory integration tests which covers all languages by their code.
* Caching of LanguageConverters in factory
* Make all tests running (hope that's would be enough)
* Uncomment  the deprecated functions.
* Rename FakeConverter to TrivialLanguageConverter
* Create ILanguageConverter to have shared ancestor
* Make the LanguageConverter class abstract.
* Create table with mapping between lang code and converter instead of using name convention
* ILanguageConverter @internal
* Clean up code

Change-Id: I0e4d77de0f44e18c19956a1ffd69d30e63cf51bf
Bug: T226833, T243332
2020-02-03 11:38:03 +02:00
James D. Forrester
4f2d1efdda Coding style: Auto-fix MediaWiki.Classes.UnsortedUseStatements.UnsortedUse
Change-Id: I94a0ae83c65e8ee419bbd1ae1e86ab21ed4d8210
2020-01-10 09:32:25 -08:00
Thiemo Kreuz
b39a56d74e Make use of existing array value variables in foreach loops
In all these cases, the foreach() loop specifies a variable for the
current value. We don't need two ways to access the same value. This
makes the code harder to read.

Change-Id: I6ed7a518439963b7091057194de993a7e977be32
2019-12-29 12:04:29 +00:00
jenkins-bot
278cdf9607 Merge "deferred: Log trace as 'exception.trace' instead of 'trace'" 2019-12-19 17:38:33 +00:00
Umherirrender
8acea5491d Handle database error with LinksUpdate and numeric category names
Until I70473280, integer literals were always quoted as strings, because
the databases we support all have no problem with casting
string-literals for comparisons and such.

PHP associative arrays don't preserve
the types of keys, it converts integer-like strings into actual
integers, which can result in errors:

WikiPage::updateCategoryCounts	localhost	1292
Truncated incorrect DOUBLE value: 'A String Category' (localhost)
UPDATE
`category` SET cat_pages = cat_pages - 1 WHERE cat_title IN
(143434343434,'14343434string')
#0 includes\libs\rdbms\database\Database.php(1587):
Wikimedia\Rdbms\Database->getQueryExceptionAndLog(string, integer,
string, string)
#1 includes\libs\rdbms\database\Database.php(1166):
Wikimedia\Rdbms\Database->reportQueryError(string, integer, string,
string, boolean)
#2 includes\libs\rdbms\database\Database.php(2217):
Wikimedia\Rdbms\Database->query(string, string)
#3 includes\libs\rdbms\database\DBConnRef.php(68):
Wikimedia\Rdbms\Database->update(string, array, array, string)
#4 includes\libs\rdbms\database\DBConnRef.php(380):
Wikimedia\Rdbms\DBConnRef->__call(string, array)
#5 includes\page\WikiPage.php(3689):
Wikimedia\Rdbms\DBConnRef->update(string, array, array, string)
#6 includes\deferred\LinksUpdate.php(420):
WikiPage->updateCategoryCounts(array, array, integer)
#7 includes\deferred\LinksUpdate.php(315):
LinksUpdate->updateCategoryCounts(array, array)
#8 includes\deferred\LinksUpdate.php(193):
LinksUpdate->doIncrementalUpdate()
#9 includes\deferred\DeferredUpdates.php(416): LinksUpdate->doUpdate()

Also update some param docs

Change-Id: If77cf924af01a215977bfdc8f085c4e1f4c96cad
2019-12-06 19:17:56 +01:00
jenkins-bot
2b04ef6657 Merge "Set method visibility for various constructors" 2019-12-05 10:23:34 +00:00
Umherirrender
0688dd7c6d Set method visibility for various constructors
Change-Id: Id3c88257e866923b06e878ccdeddded7f08f2c98
2019-12-03 20:17:30 +01:00
Umherirrender
2cc97d844a Use array for 'ORDER BY'
It is converted to a valid sql string from the abstract database layer

Also use array for GROUP BY and column alias

Change-Id: I293a563607d115a42c8456c9b9ac66665d71d943
2019-11-29 23:01:07 +01:00
Umherirrender
c7ad21c25f Improve param docs
Change-Id: I746a69f6ed01c3ff000da125457df62b02d13b34
2019-11-28 19:08:59 +01:00
Timo Tijhof
c643e47248 deferred: Log trace as 'exception.trace' instead of 'trace'
This way most existing Logstash dashboards looking for traces
can pick this up without requiring the filter to be duplicated
or written as a custom Query DSL entry.

Also:

* Fix the broken logger from the jobify() method which did not
  define the "{type}" or "{exception_message}" keys at all.

* Fix the over-normalized logging of all fatal errors from deferred
  updates as "Error from {type}: {exception}" which isn't useful to
  aggregate (we can already get an overall count for
  channel:DeferredUpdates, level:error). The normalized aggregate
  is meant to uniquely identify specific errors that have a common
  cause. For other fatal exceptions we leave the keep the cause
  and exception message in the raw message and only add the request
  context and trace into placeholder fields (MWExceptionHandler.php).
  Apply the same principal here as well.

* Field 'exception.class' will now be available. This was previously
  missing (e.g. what exception is being thrown). It would log
  "The given Title does not belong" instead of
  "InvalidArgumentException: The given Title…".

Bug: T233342
Change-Id: I9b15658c97e3bfcc2ce8b234d1c0d47c9c294fb7
2019-11-26 20:40:08 +00:00
Aaron Schulz
d0b7a1b4f3 Clean up DeferredUpdates transactions and push failed updates as jobs
Bail out in attemptUpdate() if the transaction state is dirty rather
that failing at some later point. Also, flush implicit transaction
rounds before calling DeferrableUpdate::doUpdate() for fresher data.

Note that only instances of EnqueueableDataUpdate can become jobs.
Make handleUpdateQueue() defer throwing the exception until every task
was attempted for the special unit test logic.

Clean up some of the logging from 34427e7d7b.

Bug: T206283
Change-Id: I84ba1f2f8c4bf7c8ef21a907f73ad1065dd8f330
2019-11-14 13:24:53 +00:00
jenkins-bot
78a2b8f485 Merge "Fix new phan errors, part 5" 2019-10-20 01:39:44 +00:00
Daimona Eaytoy
d3252fc870 Fix new phan errors, part 5
Some of the errors are suppressed because they're phan false positives.
The idea behind this is that they'll be fixed in a future version of
phan, and we'll just have to remove the suppressions.

Note: I'm disabling UnusedPluginSuppression so that we can start suppressing
issues even if they're still disabled. The sniff should be re-enabled
as soon as we upgrade phan.

Bug: T231636
Change-Id: I0f7fa06a9e03fbb86c7a5eb6e50a850bb258a7f7
2019-10-18 20:45:53 +00:00
Max Semenik
8a98dd9d59 Convert some private static arrays to constants
Remove @since for some private ones as we don't guarantee anything
about private class members.

Change-Id: Ifb898353c02082e9ef69d67f69339345c6cd154d
2019-10-16 01:30:54 +00:00
Daimona Eaytoy
95dc119527 Fix new phan errors, part 2
Still mostly doc-only.

Bug: T231636
Change-Id: I65cec6c716ce6859e14da00a12ef71e03603e59a
2019-10-12 10:35:09 +00:00
jenkins-bot
643a2e527c Merge "Make CdnCacheUpdate::expand() private and update the sole caller" 2019-09-13 21:25:47 +00:00
jenkins-bot
a2c5e9eadf Merge "Expose LinksUpdate recursive flag with a getter" 2019-09-13 20:04:40 +00:00
Aaron Schulz
fef9ed715a Make CdnCacheUpdate::expand() private and update the sole caller
Change-Id: Id427a1667618b65055be772e9919052e95def1f9
2019-09-13 01:56:23 +00:00
Aaron Schulz
dd99fa6e7f Cleanup LinksUpdate::invalidateProperties() to use JobQueueGroup::lazyPush() in one batch
Change-Id: I7afaf6e6c0692aad83c017660bb8fdbb8a88597a
2019-09-11 15:07:41 -07:00
Aaron Schulz
2adff7579d Cleanup field visibility and comments in CdnCacheUpdate and HTMLCacheUpdate
Change-Id: Ifbdc3e845aee9c6785c7813f6c955da4bfbe2bc8
2019-09-11 15:04:58 -07:00
Derick Alangi
d441507260 deferred: Fix MW version number when hard deprecating to '1.34'
Should be string or bool and not a float. The reason 49bbfc7 was
not triggered is because the deprecated code path is no longer being
executed in production.

Change-Id: Ieeffb8a6cc7177c52b4c54d66152c90ded1dc248
2019-09-11 19:15:43 +01:00
David Causse
b2ac2a41dd Expose LinksUpdate recursive flag with a getter
knowing if recursion is enabled might help extensions implementing
LinksUpdate hooks to take some decisions.
E.g. CirrusSearch would like to know if a particular update needs to go to a
priorized queue or not (template transclusion).

Change-Id: I0a0de0d4621ed302b4fb550a1ddecd4ac8c5775a
2019-09-11 16:55:39 +02:00
Aaron Schulz
a5c7fd0db2 Move callers away from Title::GAID_FOR_UPDATE
These callers just need to load some data from DB_MASTER.
Subsequent code needing that latest title data should also use the
required flags, rather than relying on flakey global cache state.

Change-Id: I53248ea4b5bf1cd953f956c41b8244831ec5ef04
2019-09-09 13:19:08 -07:00
Daimona Eaytoy
e7ee0bc0f5 Better docs to make phan happy
Change-Id: I8a9a6330cf1f889cbb77dfc28c93774204767323
2019-09-07 16:47:18 +00:00
Daimona Eaytoy
c659bc6308 Unsuppress another phan issue (part 7)
Bug: T231636
Depends-On: I2cd24e73726394e3200a570c45d5e86b6849bfa9
Depends-On: I4fa3e6aad872434ca397325ed7a83f94973661d0
Change-Id: Ie6233561de78457cae5e4e44e220feec2d1272d8
2019-09-03 17:19:21 +00:00
jenkins-bot
0d6ef1c0b2 Merge "deferred: make DeferredUpdates::attemptUpdate() use callback owners for $fnameTrxOwner" 2019-08-21 19:38:13 +00:00
Daniel Kinzler
aa4da3c2e8 Revert "Add small HtmlCacheUpdater service class to normalize purging code"
This reverts commit 35da1bbd7c.

Reason for revert: wrong tab, wrong patch. Ooops.

Change-Id: I5828fff6308d43460a3b2b10f60996409181f8b3
2019-08-07 13:56:30 +00:00
Aaron Schulz
35da1bbd7c Add small HtmlCacheUpdater service class to normalize purging code
The purge() method handles purging of both file cache and CDN, using
a PRESEND deferred update. This avoids code duplication and missing
file cache purge calls.

Also:
* Migrate HTMLCacheUpdate callers to just directly using HTMLCacheUpdateJob
* Add HtmlFileCacheUpdate class and defer such updates just like with CDN
* Simplify HTMLCacheUpdate constructor parameters
* Remove BacklinkCache::clear() calls which do nothing since the backlink
  query does not actually happen until the job runs

Change-Id: Ic453b189a40109a73a9426538608eea87a76befa
2019-08-06 13:45:27 -07:00
jenkins-bot
c698fe313e Merge "Clean up spacing of doc comments" 2019-08-05 22:51:10 +00:00