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
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 scripts in core have bolierplate code that is
added before and after the class to allow directly running
the maintenance script.
* Running the maintenance script directly has been deprecated
since 1.40, so this boilerplate code is only to support a now
deprecated method of running maintenance scripts.
* This code cannot also be marked as covered, due to PHPUnit
not recognising code coverage for files.
* Therefore, it is best to ignore this boilerplate code in code
coverage reports as it cannot be marked as covered and also
is for deprecated code.
What:
* Wrap the boilerplate code (requiring Maintenance.php and then
later defining the maintenance script class and running if the
maintenance script was called directly) with @codeCoverageIgnore
comments.
* Some files use a different boilerplate code, however, these
should also be marked as ignored for coverage for the same
reason that coverage is not properly reported for files.
Bug: T371167
Change-Id: I32f5c6362dfb354149a48ce9c28da9a7fc494f7c
This touches various production classes and maintenance scripts.
The code should do the exact same as before. The main benefit is that
the syntax avoids any repetition.
Change-Id: I5c552125469f4d7fb5b0fe494d198951b05eb35f
Avoid the call to internal constructor of AndExpressionGroup and
OrExpressionGroup by creating a factory function similiar as the
IReadableDatabase::expr function for Expression objects.
This is also a replacement for calls to ISQLPlatform::makeList with
LIST_AND or LIST_OR argument to reduce passing sql as string to the
query builders.
Created two functions to allow the return type to be set for both
expression group to allow further calls of ->and() or ->or() on the
returned object.
Depending on the length of the array argument to makeList() it is
sometimes hard to see if the list gets converted to AND or OR, having
the operator in the function name makes it easier to read, so two
functions are helpful in this case as well.
Bug: T358961
Change-Id: Ica29689cbd0b111b099bb09b20845f85ae4c3376
Changes to the use statements done automatically via script
Addition of missing use statement done manually
Change-Id: Ic4d4dd61de5ab896fb6173eb579c81f164a1e4a3
* Change `$services->getDBLoadBalancerFactory()->waitForReplication()`
to `$this->waitForReplication()`
* Change various complicated expressions to `$this->getReplicaDB()`
and `$this->getPrimaryDB()`
* Remove unused variables
Change-Id: Ia857be54938a32bb6288dcdf695a35cd38761c3c
And start using them instead of wfGetDB(), LB/LBF connection methods or
worse, $this->getDB().
$this->getDB() reuses the database object regardless of whether you're
calling a replica or primary, leading to returning a replica on a
primary and other way around.
Bug: T330641
Change-Id: I9e2cf85ca277022284fc26b9f37db57bd12aaa81
For readability. Allowed since PHP 7.4.
I searched for integer literals of 6 or more digits, and also changed
some nearby smaller numbers for consistency.
Bug: T353205
Change-Id: I8518e04889ba8fd52e0f9476a74f8e3e1454b678
Pass Authority to WikiImporter constructor, instead of looking at the
user from RequestContext::getMain(), and skipping this check if
$wgCommandLineMode is true.
Maintenance scripts now use UltimateAuthority, to match the original
intent of skipping permission checks, see 2ed55f42 / r96311.
The Authority parameter to WikiImporterFactory::getWikiImporter() is
optional for now for backwards-compatibility. It should become
required later after deprecation.
Change-Id: Iea1d03dcdcbda2f9a9adbff1b0d319efd22c4d86
Done semi-automatically via migrateselect[1]. The script only accepted
ascii chars until I found out and fixed it and now I can run it in more
places.
[1] https://gitlab.wikimedia.org/ladsgroup/migrateselect
Bug: T344971
Change-Id: I83b6c424c62a517a0ab3635b64488ea53fd88bab
Deprecating RevisionStore::getQueryInfo() and cleaning up a lot of code
Also removing a brittle test that wasn't really testing anything.
Bug: T344971
Change-Id: Ifd690dc8f030f86e3567a717eaeb830cb6dc703b
Maintenance class provides a method for getting a fresh reference
of the MW services container instance. Let's make use of these in
maintenance scripts now that we have it.
NOTE: There are still some static methods like in refreshLinks.php
that makes use of services that we can't use this method for now.
Change-Id: Idba744057577896fc97c9ecf4724db27542bf01c
Previous revisions can have bigger revision IDs than the last revision
in a few situations, including imported or history-merged revisions.
Change-Id: I4e23d10b0763de4b016460e789baec4f560f1674
Using a php parser written on top of ANTLR4, done semi-automatically.
I checked everything and made adjustments.
Bug: T311866
Change-Id: I6150c6909bce8f3dbd745a26380cc0af9d9c547f
To fix legacy encoding entries in external storage which means they
can't be fixed via calling moveToExternal.php.
The script originally was copy-paste and clean up of moveToExternal.php
but it made so much duplication that I went with subclassing.
Bug: T282734
Change-Id: Ic52e843f3dbe7d14cc8df5e8f3fe7aada7681bc9
While most rows in production use 'utf-8' to flag content being UTF-8,
we have lots of rows flagged with 'utf8':
mysql:research@s3-analytics-replica.eqiad.wmnet [dawiki]> select old_flags, count(*) from text group by old_flags limit 50;
+---------------------+----------+
| old_flags | count(*) |
+---------------------+----------+
| error | 2 |
| external,gzip | 49 |
| external,object | 36 |
| external,utf-8 | 1614469 |
| external,utf8 | 336780 |
| gzip,utf-8,external | 1094 |
| utf-8,gzip,external | 9458083 |
+---------------------+----------+
7 rows in set (26.038 sec)
This would confuse the script to try to reencode it again which possibly
could lead to all sorts of errors
Change-Id: I9b4a38538199c9954cfed51cdd2bba8b0f6cb953
HistoryBlobCurStub objects point to rows in the cur table from 1.4,
which would have used the legacy encoding. It is incorrect to add the
"utf-8" flag without also converting the encoding.
Bug: T337700
Change-Id: Ie884512c1489358cabdf52660a7cb9d0797b8e78
* Triple backslash in regex should really be quadruple backslash
* Using the returned value of a void method
* Immediately overwritten array keys
* Duplicate array keys
* Foreach variable reuse
* sprintf() with too many params
* Incorrect reference usage
Change-Id: I3c649b543c9561a1614058c50f3847f663ff04df
Convert these two old scripts to Maintenance subclasses.
* Uncomment the resolveStub() call in moveToExternal and fix one obvious
bug with it, i.e. the fact that stubs need to be resolved after CGZ
blobs are moved.
* Replace get_class() with instanceof.
* Make the "tiny text" threshold configurable. Normally this is not
wanted in WMF production since new revisions are written to ES
unconditionally.
* Add a dry run mode.
* Add an undo log.
* Add --skip-resolve option.
* Make resolveStub() be much more defensive about what it resolves.
* In moveToExternal, make compression optional and do it also for plain
text.
* Optionally convert the legacy encoding to UTF-8.
Bug: T299387
Change-Id: I52d54e3b6b785ac072796031be06499221340f51
The motivation is to make the code less confusing. I hope this is the
case.
?? is an older PHP 7.0 feature.
??= was added in PHP 7.4, which we can finally use.
Change-Id: Id807affa52bd1151a74c064623b41d950a389560
Various variables are left from ealier refactor are now unused
and can be removed to make the code easier to read
Change-Id: Id51770af1f08e85c7e7a02234a2cd2ab5b47ee7a