wfGetServerUrl is deprecated since 1.39, let's remove the
only use and turn it into a hard deprecation.
Change-Id: I82be851fe411cd002c9c5847fe3924a6c0a4ba50
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
Why:
* The generateSitemap.php script currently generates a sitemap
using pages from the namespaces in the $wgSitemapNamespaces,
or if this is not defined then all namespaces that currently
have pages.
* However, being able to specify what namespaces should be used
instead of using the site config is useful in the case of
generating sitemaps ad-hoc and/or if that config is not set.
What:
* If the '--namespaces' argument is provided, then use it instead
of checking for the site config or looking for all namespaces
that are defined on the wikis.
* Use the namespaces provided in the namespace argument over the
site config. If no namespaces are provided in the command line
arguments, then check the site config.
Bug: T19748
Change-Id: If4a393605201be00200833c36b522bb34fcb651d
Commit 676fcf43 changes various substr() calls to str_starts_with,
except in some cases it adopted `$str[0]` or `$str[-1]` notation
instead. The cases in question:
* includes/Request/PathRouter.php
This one was safe since `$path` is already presumed to be non-empty
earlier in the same function via `$path[0]`.
* maintenance/generateSitemap.php
This one is not safe as the stting may be empty, leading to a
warning for undefined offsets in some cases.
Bug: T361379
Change-Id: I008f7b390fa08a813a0e44e8c29671e705db64f0
Updating name & email addresses for Brooke Vibber.
Re-ran updateCredits.php as well so there are some new entries in
there as well.
There are a couple of files in resources/libs that will have to
be changed upstream to keep tests happy, I will do patches
later. :D
Change-Id: I2f2e75d3fa42e8cf6de19a8fbb615bac28efcd54
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
Title::fixUrlQueryArgs() was removed in commit 3454a597, but this
use case didn't get fixed properly.
Bug: T347413
Change-Id: I6537446d244d0c4baf19e48f7fae7f391c07c27f
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
We'll have to come up with a replacement for getFullURL now that a
middle parameter is ignored, but that can be in a later patch.
Also, fix the generateSitemap script which has been making a call
that's been hard-deprecated for a while; whoops.
Change-Id: Ief5a48fe8357ab5c7cdba3ec69cf5d0322822940
Use str_starts_with, str_ends_with or string offset where appropriate.
This fixes a bug in MimeAnalyzer where the "UTF-16LE" header could not
be identified because of wrong constant. This is the exact type of bug
that the new functions can avoid.
Change-Id: I9f30881e7e895f011db29cf5dcbe43bc4f341062
No idea why this was not implemented earlier. Currently the switch
applies only to the outputted HTML and it would make sense to keep
it consistent with the sitemap.
Bug: T229754
Change-Id: I0e75675657fbf5a6f2e28a9e2528241cc99b4946
Google, at least, considers sitemap indexes that provide relative URLs
as being broken.
Bug: T202321
Change-Id: I5509be4b165eea9eca36e3f4975f87285ef87911
In cases where we're operating on text data (and not binary data),
use e.g. "\u{00A0}" to refer directly to the Unicode character
'NO-BREAK SPACE' instead of "\xc2\xa0" to specify the bytes C2h A0h
(which correspond to the UTF-8 encoding of that character). This
makes it easier to look up those mysterious sequences, as not all
are as recognizable as the no-break space.
This is not enforced by PHP, but I think we should write those in
uppercase and zero-padded to at least four characters, like the
Unicode standard does.
Note that not all "\xNN" escapes can be automatically replaced:
* We can't use Unicode escapes for binary data that is not UTF-8
(e.g. in code converting from legacy encodings or testing the
handling of invalid UTF-8 byte sequences).
* '\xNN' escapes in regular expressions in single-quoted strings
are actually handled by PCRE and have to be dealt with carefully
(those regexps should probably be changed to use the /u modifier).
* "\xNN" referring to ASCII characters ("\x7F" and lower) should
probably be left as-is.
The replacements in this commit were done semi-manually by piping
the existing "\xNN" escapes through the following terrible Ruby
script I devised:
chars = eval('"' + ARGV[0] + '"').force_encoding('utf-8')
puts chars.split('').map{|char|
'\\u{' + char.ord.to_s(16).upcase.rjust(4, '0') + '}'
}.join('')
Change-Id: Idc3dee3a7fb5ebfaef395754d8859b18f1f8769a
Find: /isset\(\s*([^()]+?)\s*\)\s*\?\s*\1\s*:\s*/
Replace with: '\1 ?? '
(Everywhere except includes/PHPVersionCheck.php)
(Then, manually fix some line length and indentation issues)
Then manually reviewed the replacements for cases where confusing
operator precedence would result in incorrect results
(fixing those in I478db046a1cc162c6767003ce45c9b56270f3372).
Change-Id: I33b421c8cb11cdd4ce896488c9ff5313f03a38cf
These comments do not add anything. I argue they are worse than having
no comments, because I have to read them first to understand they
actually don't explain anything. Removing them makes room for actual
improvements in the future (if needed).
Change-Id: Iee70aad681b3385e9af282d5581c10addbb91ac4
Clean up use of @codingStandardsIgnore
- @codingStandardsIgnoreFile -> phpcs:ignoreFile
- @codingStandardsIgnoreLine -> phpcs:ignore
- @codingStandardsIgnoreStart -> phpcs:disable
- @codingStandardsIgnoreEnd -> phpcs:enable
For phpcs:disable always the necessary sniffs are provided.
Some start/end pairs are changed to line ignore
Change-Id: I92ef235849bcc349c69e53504e664a155dd162c8
Deprecate the second argument to Maintenance::error() in favor of a new
Maintenance::fatalError() method. This is intended to make it easier to
review flow control in maintenance scripts.
Change-Id: I75699008638f7e99b11210c7bb9e2e131fca7c9e
Having such comments is worse than not having them. They add zero
information. But you must read the text to understand there is
nothing you don't already know from the class and the method name.
This is similar to I994d11e. Even more trivial, because this here is
about comments that don't say anything but "constructor".
Change-Id: I474dcdb5997bea3aafd11c0760ee072dfaff124c
We already do this in many places, but there were also still plenty
of getOption(, false) calls. Change these to hasOption() for consistency.
Change-Id: I74f91a5bf5a8036496ab1f493e5862a04d27ec0f
It's unreasonable to expect newbies to know that "bug 12345" means "Task T14345"
except where it doesn't, so let's just standardise on the real numbers.
This includes renaming fixBug20757.php to fixT22757.php for similar consistency.
Change-Id: If81a590d658fbd82c20c54ac47dfdc8856745ca3
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
Changed all remaining uses of 'and' (T_LOGICAL_AND) and 'or'
(T_LOGICAL_OR) except those in includes/libs/lessc.inc.php.
In maintenance/generateSitemap.php, also slightly cleaned up
touched code:
* Inlined GenerateSitemap::init_path().
* Removed the redundant `$fspath && !is_dir( $fspath )` check.
* Return a nonzero exit code if wfMkdirParents() fails.
There are still uses of 'xor' (T_LOGICAL_XOR) in the following
files, which I left as-is:
* includes/Export.php
* includes/htmlform/HTMLCheckField.php
* includes/Autopromote.php
* maintenance/importDump.php
* maintenance/backup.inc
Change-Id: I73cb20da989e90b52782e7499f633debd5ad265d