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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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