Commit graph

144 commits

Author SHA1 Message Date
Reedy
86934b2fa8 Replace some more usages of Wikimedia\(suppress|restore)Warnings()
Change-Id: I2eb133a9e32116cd155f59086245bc4d15ecbfcc
2022-02-24 20:27:46 +00:00
Daimona Eaytoy
32c86a2621 installer: Various tweaks for taint-check
Taint-check really doesn't like assigning things from $GLOBALS this way,
because it knows that stuff inside $GLOBALS can be tainted (e.g.
$GLOBALS['_GET'], $GLOBALS['_POST']), and since it cannot determine
which key is used in the assignment, it assumes that it's tainted.
As such, the new code patch generates the default values in a separate
method, whose return value is annotated as safe, so taintedness from
$GLOBALS doesn't get into $this->settings.

Also annotate getAcceptLanguage() as untainted, since the raw values
from the HTTP header are matched against a list of known codes.

Change-Id: Ifc44d3703d505962e3b07db7613b5bbf5e448320
2022-02-10 11:25:53 +01:00
jenkins-bot
3ac949969c Merge "DatabaseInstaller.php: Only run core schema file if specified table doesn't already exist" 2021-06-14 16:16:48 +00:00
Reedy
11f144ae53 DatabaseInstaller: Fix unneded typo
Change-Id: I376385b5b379549332c7d42aa72ba800f664da7f
2021-05-29 00:35:43 +00:00
Reedy
27283dd86c DatabaseInstaller.php: Only run core schema file if specified table doesn't already exist
Bug: T283942
Change-Id: Ifd38e3b283c3f4218aace099c414a4c7e83a0d05
2021-05-28 21:35:36 +00:00
Amir Sarabadani
a4379d6fc9 Drop doInterwikiUpdate
This update is not being called in basically any wiki because it skips
when interwiki exists and that table was introduced in 1.2 (we don't
support direct upgrade from 1.26 or earlier).

The .sql file is not useful but installers use interwiki.list and that
is useful.

Bug: T272199
Bug: T273080
Change-Id: I0de40b8dc60eb07b9c7ebeb620142f3cdfe5b67b
2021-03-26 21:41:59 +01:00
Amir Sarabadani
2cc79854e8 Migrate archive table to abstract schema
One of the last ones left.

For MySQL/Sqlite:
 - Dropping default of ar_timestamp, empty string is not a valid
   timestamp.
 - Changing ar_title from "varchar() binary" to varbinary

for Postgres:
 - Set default for ar_namespace and ar_title
 - Change datatype of ar_comment_id, ar_actor, ar_namespace
The indexes were fixed separately.

Bug: T230428
Bug: T164898
Bug: T42626
Depends-On: I83cf1cd51ac9cf933c9175cefd6e38a6914f3494
Change-Id: Ic1d13a82b27f7fa39a0f0ea9c5b7b193b007e4ab
2021-03-13 21:51:16 +01:00
Umherirrender
8de3b7d324 Use static closures where safe to use
This is micro-optimization of closure code to avoid binding the closure
to $this where it is not needed.

Created by I25a17fb22b6b669e817317a0f45051ae9c608208

Change-Id: I0ffc6200f6c6693d78a3151cb8cea7dce7c21653
2021-02-11 00:13:52 +00:00
Umherirrender
a30fe542ae build: Enable SecurityCheck-DoubleEscaped and suppress issues
This issue type was globally suppressed in
I849ac4f120fd15b483e8939d4db45c98dc351259 to make reviewer easier.

This adds inline suppressions or @suppress directives on function
docs for false positives, mostly restoring those removed in
I849ac4f120fd15b483e8939d4db45c98dc351259

Bug: T231311
Change-Id: I1b1d814bd907e9d49fcc39f777982936574fc7c6
2020-12-30 23:34:20 +00:00
Umherirrender
e9e784a09e build: Enable phan-taint-check-plugin and suppress issues
Taint check checks for possible security issues by tracking html
escaping and more by using phan.
This slows done the phan-job a bit and requires more ram

Keep the DoubleEscaped issues out to make reviewer easier

Adds suppression for false positives
Adds taint-annotation to help taint-check
Removes suppression for code phan now understand better by the tracking
of keys in taint-check
Fix some small issues by adding int cast or htmlspecialchars calls

Bug: T216348
Bug: T268920
Change-Id: I849ac4f120fd15b483e8939d4db45c98dc351259
2020-12-30 19:02:22 +01:00
Tim Starling
2621d96ace Support new style hook registration on install and update
LoadExtensionSchemaUpdates hook handlers registered in the new
HookContainer style were not executed during install or update, due to
broken special case code which reads from ExtensionRegistry and
$wgHooks. So:

* In Installer, instead of hacking up $wgHooks, construct a special
  HookContainer to be used for running LoadExtensionSchemaUpdates. Make
  sure it contains new-style hooks.
* Pass the HookContainer from Installer to DatabaseInstaller via a
  setter, and then have DatabaseUpdater fetch it using $this->parent.
* Refactor Installer::includeExtensions(), splitting the legacy
  parts from the extension.json parts. A lot of weird things are done in
  service of loading old-style registration files, which are almost
  extinct at this point, so split out that code and only run it if there
  is at least one legacy extension. The order in which updates are done
  will change.
* The MW_EXTENSIONS_LOADED constant was previously used for global-level
  communication between Installer and DatabaseUpdater. Leave it in for
  now as a sanity check, but make it clear that it is redundant with the
  new HookContainer injection.
* Similarly in DatabaseUpdater::loadExtensions(), construct a custom
  HookContainer based on the existing LocalSettings.php.
* Use array_merge() instead of array_merge_recursive() when merging
  legacy hooks.

Bug: T266681
Change-Id: I2c41ece04aed11a176559d4364cea2f3320b9574
2020-11-05 14:09:21 +11:00
daniel
607cc15526 Installer: consistently reset Language objects
Language objects contain references to service objects, so they need to
be be discarded when the global service container is reset by calling
MediaWikiServices::resetGlobalInstace(). The Installer class was doing
this correctly in the constructor, however, there where other calls to
resetGlobalInstace() during the installation process that did not
properly reset all language objects, which resulted in incorrect instances
of LocalisationCache being accessed.

This patch introduces the resetMediaWikiServices() method into the
Installer class which can be used to safely reset the service container
during installation.

Bug: T261081
Change-Id: I0ccab2b7fcac6942016430b1df5a1dbeb192f2f6
2020-09-18 12:42:58 +02:00
jenkins-bot
39705eb311 Merge "Replace "@stable for subclassing" with "@stable to extend"" 2020-07-13 09:31:38 +00:00
jenkins-bot
0270990f0b Merge "Replace "@stable for calling" by "@stable to call"" 2020-07-13 09:27:04 +00:00
daniel
3c50afa46b Replace "@stable for subclassing" with "@stable to extend"
For compliance with the new version of the table interface policy
(T255803).

This patch was created by an automated search & replace operation
on the includes/ directory.

Bug: T257789
Change-Id: Ie32c1b11b3d16ddfc0c83a757327d449ff80b2e4
2020-07-13 11:00:30 +02:00
daniel
f7116bb3a2 Replace "@stable for overriding" with "@stable to override"
For compliance with the new version of the table interface policy
(T255803).

This patch was created by an automated search & replace operation
on the includes/ directory.

Bug: T257789
Change-Id: I5ffbb91882ecce2019ab644839eab5e8fb8a1c5f
2020-07-13 10:57:12 +02:00
daniel
272db6afde Replace "@stable for calling" by "@stable to call"
For compliance with the new version of the table interface policy
(T255803).

This patch was created by an automated search & replace operation
on the includes/ directory.

Bug: T257789
Change-Id: If560596f5e1e0a3da91afc36e656e7c27f040968
2020-07-13 08:55:28 +00:00
daniel
aedc93fdb0 Mark remaining eligible classes as stable for subclassing
This classes were found by surveying concrete classes derved from base
classes in core.

Bug: T247862
Change-Id: I231752aaad26e2ab3f097301e449b31e723590f0
2020-07-10 15:02:27 +02:00
Amir Sarabadani
11f241589b Wire empty abstract schema into installer
For more information on schema changes see:
https://www.mediawiki.org/wiki/Manual:Schema_changes

Bug: T191231
Bug: T230428
Change-Id: I779b9c61e388e998738a2ed41b0b8e2afdecd232
2020-05-09 20:42:11 +02:00
James D. Forrester
4f2d1efdda Coding style: Auto-fix MediaWiki.Classes.UnsortedUseStatements.UnsortedUse
Change-Id: I94a0ae83c65e8ee419bbd1ae1e86ab21ed4d8210
2020-01-10 09:32:25 -08:00
Daimona Eaytoy
ce0856b12f Fix more scalar types in docblocks
Change-Id: I574d4e261ab986e028c3ce26c4f0ec648b88a2ac
2019-12-08 17:59:08 +00:00
Timo Tijhof
b118bddc15 installer: Rename Doxygen group from "Deployment" to "Installer"
Also improve the description a bit and explain at a high level
how this code is used, and which classes back those entry points.

Change-Id: Ia69531858e714d0b43a29a7d5b6dcc5c7edd8240
2019-11-25 23:26:20 +00:00
Volker E
a9252abb1c Replace infobox usages and extend successbox, warningbox and errorbox
Adding optional $className parameter to provide additional
styling options.
Optional parameter $heading was introduced for MobileFrontend. Therefore
leaving inconsistent parameter order is necessary for the time being.

Bug: T232903
Change-Id: I5857b2c58a47a83156c32f086a73fe2bd48ab0c8
2019-09-24 16:29:32 -07: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
Amir Sarabadani
807d793ab9 More clean up of oracle/mssql
Bug: T230418
Change-Id: I1ff01548e55f01f9419668e31d5aa7dd03d23258
2019-08-14 17:04:50 +02:00
Aaron Schulz
b12b7e4ddb installer: Stop offering MyISAM option for new installs and fix bogus method calls
The methods were renamed in 2010 (r68908, c4100fb83b).

Change-Id: I076ec8d9c11f5bd33cb0ad19e5be8e239401b9c6
2019-07-20 18:19:17 -07:00
DannyS712
834064f645 Correct typo `notMinimumVerisonMessage'
Bug: T224449
Change-Id: I4d76f900770f74ce668abf71ea5e7a9f167f5950
2019-07-08 04:42:34 +00:00
Reedy
a3942e029b Partial revert I0d0ef26f59721039b2c24ab322fa3bf6ab16fea1
The parameter swap in meetsMinimumRequirement wasn't supposed to happen

Change-Id: Icf5b237f336084e7a8d11698cd5ea665305e7f3c
2019-05-28 02:15:14 +01:00
Reedy
a469e81971 Fix typo of Minimum in variable name
Change-Id: I0d0ef26f59721039b2c24ab322fa3bf6ab16fea1
2019-05-26 20:11:05 +01:00
Derick Alangi
3e27b50786 installer: Remove TODO per discussion in Ia9f0cd7d0117f67d2017e
So other developers think that the class property name makes more
sense than the proposed name in the TODO section. In an attempt to
rename it in this patc: Ia9f0cd7d0117f67d2017e, it was rather adviced
to remove the todo and leave the class property name as-is.

Change-Id: I3336b5a6112f098e290f102caac6b04c0b50b076
2019-04-13 19:01:35 +01:00
Brian Wolff
286d49011f Various fixes for phan-taint-check
Bug: T216348
Change-Id: I0adafdc680dae0e930f38f08fe926645c57be06c
2019-02-17 11:41:11 +00:00
RazeSoldier
56d2fc8081 Use "try-catch" block instead of "if" block to prevent interruption of new installation
New installation blocked when checking if the DB exists,
because when select DB, if it fails, it will throw an exception.

So I modify the checking logic to determine if there is an exception
thrown instead of detecting the return value.

Bug: T215566
Change-Id: I6817997434df7adc79fbc1b224b77c0daa8cc11d
2019-02-12 13:38:32 +08:00
LukBukkit
76663a22f7
Improve display of an SQL error during the installation
This commit moves the call of the DatabaseUpdater::purgeCache
function into a try catch block which ensures
that the error will be displayed nicely.

Bug: T209341
Change-Id: I614444140e29948c41baa30dd557483b63f21a9a
2018-11-16 23:56:31 +01:00
Reedy
39f0f919c5 Update suppressWarning()/restoreWarning() calls
Bug: T182273
Change-Id: I9e1b628fe5949ca54258424c2e45b2fb6d491d0f
2018-02-10 08:50:12 +00:00
jenkins-bot
f428f95ac4 Merge "Check minimum database server version when running update.php" 2017-10-20 23:57:51 +00:00
Brad Jorsch
fa4a909def Replace more uses of "SELECT *"
With the introduction of CommentStore, selects from various table
require certain joins or column aliases for proper operation. The
upcoming actor table change, and the suggested title table change, will
add more such requirements.

Change-Id: Ic8213bff74b8350b15cd271d0ef252e63e7e79bd
2017-10-13 19:02:56 +00: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
Umherirrender
be42e09aa8 build: Prepare for mediawiki/mediawiki-codesniffer to 0.9.0
The used phpcs has a bug, so the version 0.9.0 could not be enforced at the moment.
Will be fixed in next version, see T167168

Changed:
- Remove duplicate newline at end of file
- Add space between function and ( for closures
- and -> &&, or -> ||

Change-Id: I4172fb08861729bccd55aecbd07e029e2638d311
2017-06-26 17:14:31 +00:00
Aaron Schulz
d735dc562d Move Database and subclasses to Rdbms namespace
Change-Id: I52bef87512f9ddd155d1f4cc0052f6b7a0db5b42
2017-04-12 10:43:57 -07:00
Aaron Schulz
488a647831 Move IDatabase/IMaintainableDatabase to Rdbms namespace
Change-Id: If7e8a8ff574661fd827de8bcec11d2c39a687300
2017-03-28 15:32:38 -07:00
Aaron Schulz
4a177b34ef Move LBFactory to Rdbms namespace
Change-Id: I5ae10783228d0252284807c9562bc8e328d4becb
2017-02-03 17:24:03 -08:00
umherirrender
34fe90ac52 Remove empty lines at end of functions
It looks like there is something missing after the last statement
Also remove some other empty lines at begin of functions, ifs or loops
while at these files

Change-Id: Ib00b5cfd31ca4dcd0c32ce33754d3c80bae70641
2016-11-05 11:55:10 +01:00
Aaron Schulz
30f4b3c103 Replace DatabaseBase => Database in more places
Change-Id: If37a7909056bf2c31a8228cbc84f0fbbf5f1c517
2016-09-28 15:53:02 -07:00
Aaron Schulz
9e8f157ed2 Minor installer/upgrader cleanups
Change-Id: I6352d16dce242c94203bdf7d020f1c0279fec6e5
2016-09-24 02:06:20 +00:00
Aaron Schulz
896a4c74de Move LBFactorySingle to /libs/rdbms
Also add newFromConnection() methods for cleaner looking construction
since the IDatabase is fundamental and required.

Change-Id: Ife478d045cee92a30c91e9004833a557488bd512
2016-09-17 19:13:21 -07:00
Aaron Schulz
acdfb5806a Move updater/installer specific methods out of DatabaseBase
Change-Id: I995799fc15d2797ce7ab9ce2aca8beeef409447c
2016-09-15 02:52:58 -07:00
daniel
d7410db0fd Allow reset of global services (redux).
(This is part of I6ec374ac9 wich was a re-submit of Ie98bf5af5
which got reverted by Ide7ab563)

This change provides a mechanism to reset global service instances
in an orderly manner. There are three use cases for this:

* the installation process
* integration tests (which most of the existing phpunit tests are)

In contrast to I6ec374ac9, this change does not cause singeltons
of legacy services to be reset. It is assumed that legacy services
use global state to access services and configuration, so any
change in confuguration would affect them immediately.

NOTE: the original I6ec374ac9 would cause session information to
get lost if the user session was creatsed before initialization
was complete. This was apparently triggered by the MobileFrontend
extension under some circumstances. Check with Addshore and Catrope.

Change-Id: Ie06782ffb96e675c0aa55dc26fb8f22037e8517d
2016-05-04 19:18:29 +02:00
Catrope
1162ed5f88 Revert "Allow reset of global services."
Completely breaks login.

This reverts commit 8e7a0a0912.

Change-Id: Ide7ab5632e987e81374c21173df6ab3998649df7
2016-04-11 13:40:28 -07:00
daniel
8e7a0a0912 Allow reset of global services.
This change provides a mechanism to reset global service instances
in an orderly manner. There are three use cases for this:

* the installation process
* forking processes
* integration tests (which must of the existing phpunit tests are)

Depends-On: I5d638ad415fc3840186a0beaa09ac02ea688539b
Change-Id: Ie98bf5af59208f186dba59a9e971c72ea0b63e69
2016-04-11 16:22:40 +02:00
Reedy
b5656b6953 Many more function case mismatches
Change-Id: I5d3a5eb8adea1ecbf136415bb9fd7a162633ccca
2016-03-19 00:20:58 +00:00