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
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
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
* Remove inline `false` fallback in fetch().
load() does this already and can't return other falsey values
like null.
* Remove use of Database::getCacheSetOptions as this data is
generally not mutable.
* Remove foreach-wiki logic from clearInterwikiCache.php.
Usually to make scripts apply cross-wiki they are iterated
externally via something like foreachwiki (as WMF does) and
by using the `--wiki` parameter that core supports. Iterating
in-process is somewhat fragile and depended on various hardcoding
and assumptions, including e.g. BagOStuff::makeKey() and how
ClassicInterwikiLookup calls this.
Also fix clearInterwikiCache.php to actually work on simple wikis.
Previously it did nothing locally as $wgLocalDatabases is empty.
* Remove non-confident code from loadFromArray() for tolerating
absence of iw_url. Move the isset() check to the one place that
needs it, namely the hook handler in load(), and document what it
is for.
* Simplify load() usage by inlining and moving fetchPregenerated()
responsibility there.
* Simplify load() by merging the aborted and non-aborted hook cases,
and document the reasons explicitly.
* Move use of WikiMap::getCurrentWikiId() to the constructor
with TODO for proper injection.
* Rename a bunch of variables and apply more consistent terminology
within interwiki-related source code. In particular, it was
confusing that the variable 'objectCache' in fact did not cache
the objects, which are cached in 'localCache' instead. Use the
common naming found in other MW components instead ("wanCache" and
"instances").
Bug: T315315
Change-Id: If3429b0604974efd4ff5914660979d3e49266848
Usages in Installer.php were not removed as the installer is
resetting $wgMemc to an EmptyBagOStuff instance. Removing it
would risk breaking the installer for extensions still using
$wgMemc.
Bug: T160813
Change-Id: I46b837c92cf86474989ee6dd97f1251cf795309f
Per documentation on IDatabase, $conds must be a string or an array.
Passing false for conds is confusing, since it's unclear whether this
should match everything or nothing.
Bug: T188314
Change-Id: I8be1ac4cbdaafc41aadc2a658be8a99b754b0268
This is more consistent with LoadBalancer, modern, and inclusive
of master/master mysql, NDB cluster, and MariaDB galera cluster.
The old constant is an alias now.
Change-Id: I0b37299ecb439cc446ffbe8c341365d1eef45849
Follows-up I1343872de7, Ia533aedf63 and I2df2f80b81.
Also updated usage in text in documentation and the
installer LocalSettingsGenerator.
Most of them were handled by this regex:
- find: (require|include|require_once|include_once)\s*\(\s*(.+?)\s*\)\s*;$
- replace: $1 $2;
Change-Id: I6b38aad9a5149c9c43ce18bd8edbab14b8ce43fa
Squiz.WhiteSpace.LanguageConstructSpacing:
Language constructs must be followed by a single space;
expected "require_once expression" but found
"require_once(expression)"
It is a keyword (e.g. like `new`, `return` and `print`). As
such the parentheses don't make sense.
Per our code conventions, we use a space after keywords like
these. We appeared to have an unwritten exception for `require`
that doesn't make sense. About 60% of require/include usage
was missing the space and/or had superfluous parentheses.
It is as silly as print("foo") or return("foo"), it works
because keywords have no significance for whitespace between
it and the expression that follows, and since experessions can
be wrapped in parentheses for clarity (e.g. when doing string
concatenation or mathematical operations) the parenthesis
before and after basiclaly just ignored.
Change-Id: I2df2f80b8123714bea7e0771bf94b51ad5bb4b87
Use lowerCamelCase.php format for all files (per [[mw:CC#File_naming]]),
and make filenames more specific:
- clear_stats.php -> clearCacheStats.php
- clear_interwiki_cache.php -> clearInterwikiCache.php
- initStats.php -> initSiteStats.php
- proxy_check.php -> proxyCheck.php
- stats.php -> showCacheStats.php
- showStats.php -> showSiteStats.php
Also changed the class names accordingly (per [[mw:CC/PHP#Naming]]),
and make class names more specific:
- clear_stats -> ClearCacheStats
- InitStats -> InitSiteStats
- CacheStats -> ShowCacheStats
- ShowStats -> ShowSiteStats
Updated files that made references to the changed files/classes:
- DefaultSettings.php and SpecialBlockme.php (proxy_check.php -> proxyCheck.php)
- maintenance/showSiteStats.php (initStats.php -> initSiteStats.php)
- maintenance/README and docs/memcached.txt (stats.php -> showCacheStats.php)
- docs/maintenance.txt and docs/memcached.txt (clear_stats.php -> clearCacheStats.php)
Thanks Hashar for the initial help and encouragement :)
Change-Id: I60f76fc971e06e1b710dcda35f9c2d931b93bdd7
2013-03-06 03:57:54 +00:00
Renamed from maintenance/clear_interwiki_cache.php (Browse further)