Commit graph

149 commits

Author SHA1 Message Date
Amir Sarabadani
753a4ecdd3 Bump minimum required version for upgrade to 1.29
Since the branch cut has happened, we can bump and get rid of legacy
cruft. According to the policy we can go up to 1.31 but let's keep it
that way to avoid major distruptions.

Change-Id: I9d697445a3bb5047726c8b2a7f808edb8403cdda
2021-09-28 17:57:57 +02:00
Timo Tijhof
9a7c213682 Remove trailing dot/space from some exception messages and output strings
One exception message contained a trailing dot/space, which I removed
as well, following I935835316c0.

A very small number of exceptions and output() calls contained trailing
space, which I removed for consistency.

Change-Id: I16f48c1a051c452bbef699eb9b7476d83f8821d8
2021-08-04 02:38:48 +00:00
James D. Forrester
df5eb22f83 Replace uses of DB_MASTER with DB_PRIMARY
Just an auto-replace from codesniffer for now.

Change-Id: I5240dc9ac5929d291b0ef1c743ea2bfd3f428266
2021-04-29 09:24:31 -07:00
jenkins-bot
adeaf2d808 Merge "Fail update if bot_passwords doesn't exist" 2021-01-30 18:59:43 +00:00
Amir Sarabadani
8b810330c2 Fail update if bot_passwords doesn't exist
This is for when trying to upgrade from versions older than 1.27

Bug: T259771
Change-Id: If171fafb7c5ebfb6a68d1685bfeb6198abd6bab2
2021-01-30 16:35:37 +00:00
Ammarpad
b812ab8872 update.php: Purge database caches unconditionally after upgrade
This patch removes the '--nopurge' option which allows disallowing
the purge. The db caches will now be cleared unconditionally if the
update script is run.

The option description is already not quite accurate because of
more cache clearing logic that was incrementally added later without
updating the description.

Bug: T271062
Change-Id: I1d8cad057bc58dfb4042f146023f08417e491b78
2021-01-20 05:57:49 +01:00
Tim Starling
20d06b34bb Safer autoloading with respect to file-scope code
Many files were in the autoloader despite having potentially harmful
file-scope code.

* Exclude all CommandLineInc maintenance scripts from the autoloader.
* Introduce  "NO_AUTOLOAD" tag which excludes the file containing it
  from the autoloader. Use it on CommandLineInc.php and a few
  suspicious-looking files without classes in case they are refactored
  to add classes in the future.
* Add a test which parses all non-PSR4 class files and confirms that
  they do not contain dangerous file-scope code. It's slow (15s) but
  its results were enlightening.
* Several maintenance scripts define constants in the file scope,
  intending to modify the behaviour of MediaWiki. Either move the
  define() to a later setup function, or protect with NO_AUTOLOAD.
* Use require_once consistently with Maintenance.php and
  doMaintenance.php, per the original convention which is supposed to
  allow one maintenance script to use the class of another maintenance
  script. Using require breaks autoloading of these maintenance class
  files.
* When Maintenance.php is included, check if MediaWiki has already
  started, and if so, return early. Revert the fix for T250003 which
  is incompatible with this safety measure. Hopefully it was superseded
  by splitting out the class file.
* In runScript.php add a redundant PHP_SAPI check since it does some
  things in file-scope code before any other check will be run.
* Change the if(false) class_alias(...) to something more hackish and
  more compatible with the new test.
* Some site-related scripts found Maintenance.php in a non-standard way.
  Use the standard way.
* fileOpPerfTest.php called error_reporting(). Probably debugging code
  left in; removed.
* Moved mediawiki.compress.7z registration from the class file to the
  caller.

Change-Id: I1b1be90343a5ab678df6f1b1bdd03319dcf6537f
2021-01-11 11:59:36 +11:00
Kunal Mehta
0b43c49465 Revert "Add a new type of database to the installer from extension"
It caused a 20% latency regression by unconditionally parsing extension.json
files on every single load instead of using the existing caching
infrastructure. There are further problems with the use of parsing/loading
extension.json files in a method that is incompatible with the existing
architecture.

This primarily reverts commit 46eabe275c.

Also needed to revert 16381261ae and 7c72347ec1.

Bug: T258664
Change-Id: I34a783c3f0df0447876a26441bb2d12e02368871
2020-07-22 16:05:31 -07:00
ArtBaltai
46eabe275c Add a new type of database to the installer from extension
Decouple Installer services
Implement injection class Autoloader and i18n messages from extension.json
Implement extension selector by type
Add i18n message key `version-database`
Extensions for testing:
- https://github.com/MWStake/PerconaDB - real Percona extension
- https://github.com/killev/mediawiki-dbext2 - fake extension for test

Bug: T226857, T255151
Change-Id: I9ec8a18ad19283f6be67ac000110ac370afc0815
2020-06-26 13:37:32 +03:00
Tim Starling
68c433bd23 Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.

General principles:
* Use DI if it is already used. We're not changing the way state is
  managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
  is a service, it's a more generic interface, it is the only
  thing that provides isRegistered() which is needed in some cases,
  and a HookRunner can be efficiently constructed from it
  (confirmed by benchmark). Because HookContainer is needed
  for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
  SpecialPage and ApiBase have getHookContainer() and getHookRunner()
  methods in the base class, and classes that extend that base class
  are not expected to know or care where the base class gets its
  HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
  getHookRunner() methods, getting them from the global service
  container. The point of this is to ease migration to DI by ensuring
  that call sites ask their local friendly base class rather than
  getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
  methods did not seem warranted, there is a private HookRunner property
  which is accessed directly. Very rarely (two cases), there is a
  protected property, for consistency with code that conventionally
  assumes protected=private, but in cases where the class might actually
  be overridden, a protected accessor is preferred over a protected
  property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
  global code. In a few cases it was used for objects with broken
  construction schemes, out of horror or laziness.

Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore

Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router

setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine

Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-05-30 14:23:28 +00:00
Reedy
c7eb28aac9 Fix various MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment
Change-Id: I50c7c93f1534e966224f98a835ca01f93eb9416d
2020-05-21 01:06:05 +00:00
Reedy
8ba1c75559 Replace wfWaitForSlaves() with LBFactory::waitForReplication()
Change-Id: I337147d61e2ec686a8672d0340dff4b6783f78cd
2020-05-02 02:00:01 +00:00
Daimona Eaytoy
51b5af604f Remove check for vulnerable PHPUnit version
We're now requiring PHPUnit 8.5+, which is not vulnerable. In theory,
this should guarantee that the vulnerable file is absent.
However, I'm not opposed to holding for a MW version or two.

Referencing original bug for completeness:

Bug: T180231
Change-Id: Ibfe28e22abab0fe3bb655bdef1f237a4d42b0bb2
2020-03-08 17:40:13 +00:00
Timo Tijhof
f575721a06 Update all use of $wgVersion to MW_VERSION
Follows-up I04628de4152dd5.

Bug: T212738
Change-Id: I718474ec0d9fd29ac2c05477f0f2493615d8aff5
2020-02-25 02:16:12 +00:00
Umherirrender
b4fe9c4bcc Set method visibility on maintenance scripts
Change-Id: I44c82fbe65e1d002803ce065df6563f06dd39cd4
2019-11-16 22:54:17 +00:00
Max Semenik
93a27f83f9 Remove PhpXmlBugTester
This bug was fixed over 10 years ago and is impossible to encounter
on modern libxml versions. While libxml versions might vary slightly
for the same PHP version depending on how it's built, this gives a
general idea:

https://3v4l.org/Tk27c

Change-Id: I669abb3543180e6edd090297fcfcb811aa833b57
2019-10-31 00:44:40 +00:00
Aryeh Gregor
0de9c47b50 Remove Language::factory and getParentLanguage use
Change-Id: I11f8801ef47ec1a1f63d840116e69667e6f3ae3c
2019-10-27 12:34:28 +02:00
Daimona Eaytoy
754d163e29 Fix new phan errors, part 9
This should be the last part before we can upgrade.

Bug: T231636
Change-Id: I076986ac2d2c9cbbdd1a4bf8c66e16cc014c8ffb
2019-10-22 08:09:36 +00:00
Umherirrender
7363e38ddf Set public for override of Maintenance functions
The following function are set to public in the parent class and cannot
have another visibility in subclasses
Maintenance::__construct
Maintenance::execute
Maintenance::getDbType
Maintenance::validateParamsAndArgs
Maintenance::setDB

Change-Id: I0cd6514642d479aca20f1221bf673b0713c21631
2019-10-09 20:41:33 +02:00
Daimona Eaytoy
c659bc6308 Unsuppress another phan issue (part 7)
Bug: T231636
Depends-On: I2cd24e73726394e3200a570c45d5e86b6849bfa9
Depends-On: I4fa3e6aad872434ca397325ed7a83f94973661d0
Change-Id: Ie6233561de78457cae5e4e44e220feec2d1272d8
2019-09-03 17:19:21 +00:00
Reedy
2cc8aeb1d7 Revert "Output more MW version info in update.php"
Left changes to SpecialVersion.php

This reverts commit e73328601d.

Bug: T227489
Change-Id: I673b6a6abb73e93d2253fc554f94ef9c833dae0c
2019-08-27 20:57:33 +00:00
jenkins-bot
1cc50ab8f5 Merge "Migrate various callers away from wfWikiId() to WikiMap" 2019-07-12 17:33:51 +00:00
Aaron Schulz
7710afe569 Migrate various callers away from wfWikiId() to WikiMap
Change-Id: Idc2980c05873c428fb5ffa6ab89f723d33217a8e
2019-07-12 01:02:00 +00:00
Bill Pirkle
c92d559da3 Allow PHP version check to execute on older version of PHP
Gerrit change 522014 (merged as b8b2514) mostly corrected this
issue, but one line was missed. Fixing that now.

Bug: T213893
Change-Id: I0a57f5902f1af2619fe47f7ee53695d3fd03adaf
2019-07-11 08:54:47 -05:00
Bill Pirkle
b8b2514940 Allow PHP version check to execute on older versions of PHP
A change to update.php used the null coalesce (??) operator.
While this is normally fine, the code in question executes
before the PHP version check, and causes an unfriendly PHP
error rather than the intended helpful error. Use the older-style
isset() call instead, so that the PHP version check will get
a chance to execute.

Bug: T213893
Change-Id: I22e4a24bed9e0b29e08afc7b9468e7bfd81d7d57
2019-07-10 22:39:45 -05:00
Reedy
e73328601d Output more MW version info in update.php
Bug: T226636
Change-Id: I0d5b7c3ff7d95fe759f16435da37092df14fd042
2019-06-26 15:05:09 +00:00
Thiemo Kreuz
3a66680ec5 Simplify a few list() that only care about the first element
The nice thing about explode() is that the resulting array is
guaranteed to contain at least one element. The array can not be
empty.

In some of these cases it might be possible to use strstr() instead,
but that returns an empty string when the needle character is not
found. explode() returns the original string in this case.

Change-Id: I6ad1f3273defeaf36e2305fd871eaaf9d3c1e134
2019-05-17 16:54:47 +02:00
Bill Pirkle
4d5edb65f3 Allow extensions to add params to the update.php maintenance script
T110209 caused maintenance scripts to fail on unknown parameters,
which is normally desirable.  However, some extensions (notably
SemanticMediaWiki) need to support additional params and had no
way to add them to the list of expected parameters.  It will
now be possible them to update.php via a new hook:
MaintenanceUpdateAddParams.

Bug: T213893
Change-Id: Ia40949ccb2f32090f21e0f3f7e5b9c4aef322330
2019-03-26 21:12:49 -05:00
Reedy
a8408122fd Load installer i18n when running update.php
Bug: T206765
Change-Id: Ie1c1a5dbf7c905eaca55777448e5aba00267ed31
2018-10-11 19:20:30 +01:00
Umherirrender
ad776c7d5f Use ::class to resolve class names in maintenance scripts
This helps to find renamed or misspelled classes earlier.
Phan will check the class names

Change-Id: I1d4567f47f93eb1436cb98558388e48d35258666
2018-01-23 17:40:16 +00:00
Umherirrender
255d76f2a1 build: Updating mediawiki/mediawiki-codesniffer to 15.0.0
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
2018-01-01 14:10:16 +01:00
Bryan Davis
9e34eeff23 Maintenance: add fatalError() method
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
2017-11-21 21:34:16 -07:00
Reedy
417a83a1a3 Ignore long git hashes for eval-stdin.php
This reverts commit 5b20572584.

Change-Id: Ib47ffed1174628959b9ef537370ff88f8bcb22f1
2017-11-15 03:49:20 +00:00
Reedy
5b20572584 Shorten git hashes for eval-stdin.php
Ping I5b838686ede9764083c52853cc05c52ea72739df

Change-Id: Ie80a068507444721f8ffdbdc1867555338489283
2017-11-15 03:19:00 +00:00
Kunal Mehta
20fd11be7a SECURITY: update.php: Remove eval-stdin.php if necessary
If phpunit's eval-stdin.php file exists and is one of the vulnerable
versions, delete it when running update.php as most people should run
that when updating to a new release. If the unlink() call fails, we'll
warn the user but continue with update.php processing and hope they've
mitigated it in some other way.

Bug: T180231
Change-Id: I5b838686ede9764083c52853cc05c52ea72739df
2017-11-15 02:56:15 +00:00
jenkins-bot
f428f95ac4 Merge "Check minimum database server version when running update.php" 2017-10-20 23:57:51 +00:00
Max Semenik
0392d9bb57 Move wfCountDown() into Maintenance class
Doing this allows to restrict it to maintenance scripts and support
quiet mode.

Change-Id: Iad0858ce1fdd64f746d5f9d4a7d6ed96f21e94df
2017-10-12 17:24:46 -07:00
Kunal Mehta
574ae4929e Check minimum database server version when running update.php
If MediaWiki has increased the minimum database server version that is
required, check it when running update.php to ensure it is still
compatible. Previously this was only checked during the installer.

Bug: T162044
Change-Id: I47092c9557f4706a4dcb3a23150647e68af4317f
2017-10-02 22:23:32 -07:00
Aaron Schulz
21e71e0235 Use IDatabase type hints in /maintenance
Relatedly, move lockTables()/unlockTables() to IMaintainableDatabase

Change-Id: Ib53e9fa948deb2f9a70f0ce16c002613d0060bf9
2017-04-07 23:37:41 +00:00
James D. Forrester
242df680ce maintenance: Replace implicit Bugzilla bug numbers with Phab ones
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
2017-02-21 18:32:44 -08:00
Aaron Schulz
d1215eb7a5 Small DB classes IDEA warning fixes and cleanups
Change-Id: I65b5f452a364b329bb671540f4115dbc4f40eebd
2016-10-23 22:03:37 -07:00
Kevin Israel
751f1d0d45 update.php: Don't check for mbstring extension
This check is redundant to the one in PHPVersionCheck.php which
was added in 41d1fa1c3a.

Change-Id: I32ab259939ca7e93ad6d08f2c04406ad8a973b5d
2016-06-15 10:23:21 +00:00
Chad Horohoe
de764f68dc Remove unused and undocumented $wgUseMasterForMaintenance
Change-Id: I32b58a869c796f5170fc61d6cedca9b07b7f5762
2016-06-13 19:24:48 -07:00
Kevin Israel
5ce39553e2 Fix mbstring check in update.php
Maintenance::error() will not cause the script to exit unless the
$die argument, when cast as an integer, is greater than 0. Since
the default value is 0, specify a different one, as in the other
calls from within the same function.

Follows-up 943563062f.

Change-Id: I3af72b1cd87c63d7f57436866633e86c272e904f
2016-04-08 00:44:33 -04:00
Max Semenik
943563062f Kill mbstring fallbacks
In the age when we require PHP 5.5, pretending that mbstring emulation
is not slow and silly is silly.

Bug: T129435
Change-Id: Ic8235c9da9a926df63ec7388900c44eab454eebe
2016-04-06 22:14:48 +00:00
Reedy
b5656b6953 Many more function case mismatches
Change-Id: I5d3a5eb8adea1ecbf136415bb9fd7a162633ccca
2016-03-19 00:20:58 +00:00
Timo Tijhof
9a2e9ff1cd maintenance: Remove odd use of $wgLang
* testCompression.php: Called $wgLang, but didn't set it.
  It just assumed it was English. Use a local variable instead.

* update.php: Set $wgLang to English. Set main RequestContext as well.

* transstat.php: Rename $wgLanguages to $languages for less confusion.
  It's just a local instance of language.inc's Languages class.

Change-Id: I67865f4d8710946001f7586ab0a17e125366b184
2016-03-03 01:37:45 +00:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Max Semenik
59db24e90b Use addDescription() instead of accessing mDescription directly
Change-Id: I0e2aa83024b8abf5298cfea4b21bf45722ad3103
2016-01-30 01:28:32 -08:00
Reedy
44cebea941 Update wfGetDB calls in Maintenance scripts to use getDB()
Change-Id: I9ad6745d84506b736dae94747256caac89715899
2016-01-02 16:58:23 +00:00