Why:
* Maintenance scripts in core have low test coverage
* This can cause issues such as the findDeprecated.php maintenance
script not working, as described in T374832
* Testing the broken script after fixing it will avoid the script
breaking again.
What:
* Fix the findDeprecated.php maintenance script to actually
show when code is hard-deprecated.
* Modify the script to allow mocking of the MediaWiki install
path in PHPUnit tests
* Create FindDeprecatedTest which tests that the script produces
an expected output, without being specific about how the
code finds the methods (to allow the method to be changed
as discussed in T243403)
** To do this, create a folder in the data folder for the PHPUnit
tests that has a mock file structure allowing the test to
use a fixed list of soft and hard deprecated methods.
Bug: T374832
Bug: T371167
Change-Id: Ic4933cef95ef1af7fa3939625ac1747106c71230
A constant is not a variable. The type is hard-coded via the value
and can never change. While the extra @var probably doesn't hurt much,
it's redundant and error-prone and can't provide any additional
information.
Change-Id: Iee1f36a1905d9b9c6b26d0684b7848571f0c1733
Why:
* Maintenance scripts in core are mostly untested
* Increasing this test coverage, especially for more critical
scripts, will help avoid bugs and regressions.
What:
* Add tests for renameUsersMatchingPattern.php
* Expand tests for renameUser.php
* Add TestSelectQueryBuilder::assertFieldValues, which is used
to assert against the result of ::fetchFieldValues.
Bug: T371167
Change-Id: I0470c53df7f31ae4891c33aeb5ba6e308bdcdac6
For a private function the $fname does not need to be optional,
it should be easy to pass it always.
Change-Id: Ifcddcd2479ae6f8bbf68210441c61ee7a45e1489
Remove unused $db parameter and make the $cluster required. Update
the checkStorage.php callers to provide the cluster.
Use the getTable() method in trackBlobs.php to avoid duplication.
Mark this method as @internal to the class and /storage scripts.
Change-Id: I888040a536a60e22e780900a59e4c34b6c468cdf
The variables on the converter are not usable outside of the class,
so making the public ones also private.
Change-Id: I6087dcdac761916359009548beb5210671a32ee5
Why:
* Maintenance scripts in core have low test coverage.
* Testing scripts which are not overly complex should create
less complex tests that easily raise test coverage.
What:
* Create a test for both exportSites.php and importSites.php which
checks that the XML file produced by exportSites.php can be
parsed and produces the same sites table config as was exported.
Bug: T371167
Change-Id: I3eb1b86803ee2413e624f9ffe699a60161103758
In order to replace the /api/rest_v1/page/title/{title} endpoints, we
need to have something in MediaWiki that generates a compatible
responser. The v1/page/{title}/bare and v1/revision/{id}/bare endpoints
are functionally equivalent, so the easiest approach seemed to be to
add a compatibility mode to them. The compatibility mode is triggered
using the x-restbase-compat header, which can be set via the gateway
when routing the request from /api/rest_v1/page/title/.
Bug: T374136
Change-Id: I4af7ff5325660ae30faebb24753b9dc1c3acb2b3
Add doc-typehints to class properties found by the PropertyDocumentation
sniff to improve the documentation.
Once the sniff is enabled it avoids that new code is missing type
declarations. This is focused on documentation and does not change code.
Change-Id: I7dec01892a987a87b1b79374a1c28f97d055e8fa
Why:
* Maintenance::runChild was renamed to ::createChild in
af4117bbdd
* The ::runChild method was left as a deprecated alias and the
stable to override annotation was removed.
* Following I96628f5e2bd847a1cf621b3f52015659cc1c170b, no WMF
deployed code overrides the ::runChild method and
therefore overriding the method can be marked as
hard-deprecated.
What:
* Use MWDebug::detectDeprecatedOverride to mark overriding
Maintenance::runChild as hard deprecated.
Depends-On: I96628f5e2bd847a1cf621b3f52015659cc1c170b
Bug: T374730
Change-Id: I2a3163c0853c3312cef5bee74771bed9eda74146
Why:
* The logging table on en.wikipedia.org contains an entry from
2005 which is an unblock of an autoblock. However, the log_title
contains the namespace, which makes the code that looks for
logs which target an autoblock fail (because it checks for the
first character being '#').
* Fixing the log_title to remove the 'User:' prefix from rows which
are autoblocks (i.e. searching for log_titles which start with
'User:#') should address the exceptions seen on Special:Log for
these rows.
** The search can be limited to rows which have the 'unblock'
log_action, as this has only been seen for this type of log.
What:
* Create fixAutoblockLogTitles.php which searches for the entries
and then updates the log_title value to no longer include the
'User:' prefix
** The queries to search are split, such that the expensive LIKE
query is performed on batches of row IDs. If the LIKE query is
applied directly to all rows in the table, the query takes 30s
to run on WMF production.
* Add this maintenance script to update.php. It will be run once
as the class extends LoggedUpdateMaintenance.
* Test the newly added maintenance script to ensure it works.
Bug: T373929
Change-Id: Ia62db56eda456bb764303b5f4b5a29be8f2d8fff
Improve maintainability of update-keys.sql by moving the list from an
SQL file to a PHP array in the same file as the updates it is disabling.
It was apparently an SQL file for the convenience of third parties
wishing to install MediaWiki by manually sourcing tables.sql. Support
this use case by adding an option to update.php which inserts the update
keys. Users should source tables-generated.sql and then run
update.php --initial
The array is the same for each DB type, but it's correct for it to have
the same scope as getCoreUpdateList(). Factoring out common parts of
getCoreUpdateList() and this new array is a separate project.
Bug: T167924
Change-Id: I404ee29aadcc2f3f24f78d1111090395129cd021
Why:
* The deleteSelfExternals.php maintenance script is broken on
my local wiki as the SQL generated by the script errors out
when run on MariaDB.
* This script should be fixed, updated to use the query builders,
and tested to ensure that any future breakages do not go
unnoticed.
What:
* Fix the deleteSelfExternals.php script to use a DELETE query
that works, by generating it using the query builder.
* Create DeleteSelfExternalsTest to test that the script now
works.
Bug: T371167
Change-Id: Id423fa5c1bfe666f57a38e733334342ac1ad2cea
This is the fourth patch of a series of patches to remove
ParserOutput::getText() calls from core. This series of patches should
be functionally equivalent to I2b4bcddb234f10fd8592570cb0496adf3271328e.
Here we replace calls to getText where a ContentRenderer is available
close by by temporary ParserOutput::runOutputPipeline that will
eventually be replaced by a call to (probably) ContentRenderer
(T371004). Doing this work in stages allows us to separate the work of
"bring ParserOptions to the call site" from the work of "bringing
ContentRenderer(ish) to the call site", since both need to be done for
to make ParserOutput a value object (T293512).
Change-Id: Ib4f9357293dc230df6e0ca2379a1e2a4cc1b91b7
Bug: T293512