Commit graph

84 commits

Author SHA1 Message Date
Umherirrender
88fe512c22 Pass function name to database functions (rdbms/installer)
Change-Id: Ia37d37f2471960c1d9d04fd9bd86224058e88413
2020-06-07 21:06:47 +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
Thiemo Kreuz
7a4df9b019 Remove auto-generated and empty lines in comments
… and add the missing newline after the initial <?php.

Change-Id: I83bbbb1504e4b2bd97eec63c7626d34c655c3197
2020-03-17 09:55:24 +01: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
jenkins-bot
02dc5d8685 Merge "Fix installation failure due to unexpected dbpath under CLI installation" 2019-09-06 17:38:36 +00:00
Aaron Schulz
3298a9db90 objectcache: SqlBagOStuff cleanups for sqlite and postgres
Make createTables() work for Postgres. Also add and use new
initSqliteDatabase() method for SQLite.

Also use ConvertibleTimestamp instead of wfTimestamp

Change-Id: I8e4505775e57fc6cd7380afa015fc0901a1bfc1b
2019-08-26 16:26:26 +00:00
Aaron Schulz
2eb5bdbac6 rdbms: remove DatabaseSqlite::checkForEnabledSearch() in favor of explicit queries
Change-Id: I0f13b9f054d7732f0e9694ec75c415f91a36ede9
2019-08-07 18:47:36 -07:00
RazeSoldier
f2c220adfc Fix installation failure due to unexpected dbpath under CLI installation
1. Make sure `wgSQLiteDataDir` is not empty.
2. Fix a logic bug
  In the current logic, in web environment, SqliteInstaller::dataDirOKmaybeCreate()
  will be executed twice, first in the DBConnect page [1] (with $create=true),
  and the second time in Installer::performInstallation() [2] (with $create=false),
  this is a sanity check.
  But in cli environment, SqliteInstaller::dataDirOKmaybeCreate() will
  be only executed once, called by Installer::performInstallation() (with $create=false).
  So the Cli installer will abort because the data directory is checked
  without the behavior of creating the directory.
  In this case, I split dataDirOKmaybeCreate() into checkDataDir() and
  createDataDir() according to its responsibility. And for web installation,
  we just check the directory on DBConnect page instead of creating it and
  then actually creating it in setupDatabase().
3. Add a unit test for SqliteInstaller::dataDirOKmaybeCreate

[1] DBConnect page call SqliteInstaller::submitConnectForm(),
  ::submitConnectForm() call ::dataDirOKmaybeCreate()
[2] Installer::performInstallation() call SqliteInstaller::setupDatabase(),
  ::setupDatabase() call ::dataDirOKmaybeCreate()

Bug: T217855
Change-Id: I139036b265716e9898fb76ba907c194f005ea318
2019-07-23 00:39:18 +08:00
Aaron Schulz
8a4f27fe00 installer: make SqliteInstaller set "synchronous" for the job queue DB like the other DBs
Change-Id: Ifc51ea735020fd7557c99b02bb7426d78b5f8b47
2019-07-11 13:04:43 -07:00
DannyS712
834064f645 Correct typo `notMinimumVerisonMessage'
Bug: T224449
Change-Id: I4d76f900770f74ce668abf71ea5e7a9f167f5950
2019-07-08 04:42:34 +00:00
Reedy
a469e81971 Fix typo of Minimum in variable name
Change-Id: I0d0ef26f59721039b2c24ab322fa3bf6ab16fea1
2019-05-26 20:11:05 +01:00
jenkins-bot
75f937543b Merge "Collapse some nested if statements" 2019-04-04 19:29:31 +00:00
Reedy
c13fee87d4 Collapse some nested if statements
Change-Id: I9a97325d738d09370d29d35d5254bc0dadc57ff4
2019-04-04 19:02:22 +00:00
Aaron Schulz
db784ada9f Set synchronous = NORMAL for cache tables in Sqlite installer
In local testing, this makes SqlBagOStuff::set 17x faster.

Change-Id: I54d0d4f009ca1289485b89a1dcab46ffb31d8f11
2019-04-03 18:23:34 +00:00
Aaron Schulz
fe6e812629 installer: make sqlite installer move the job queue to another DB
Also update some of the other separate DBs/files to use IMMEDIATE

Bug: T93097
Change-Id: Ib250b74cb7ff743f155512d7410cb229441cc70a
2019-03-29 22:41:38 +00:00
Max Semenik
59f4c32323 Bump minimum SQLite version to 3.8.0
3.3.7 is 12 years old, no chance in hell you will find it somewhere
that supports modern MediaWiki. Since Ubuntu 14.04 LTS has 3.8.2, this
seems like a reasonable conservative version.

Change-Id: I5fbb35bd2d4c0993889b79f463a3c35ce6765d3b
2019-03-10 17:30:09 -07:00
Aaron Schulz
1081356412 Move l10n_cache table to a separate DB for sqlite via the installer
This does not set 'db' as the cache type so that admins can still
easily set the cache directory to use the file-based cdb system.
If they do not, then at least the second DB file will be used to
avoid heavy contention.

Bug: T93097
Change-Id: Ib3912f00cf12de99801ebda4f06135b2987ce71a
2018-08-14 17:29:01 +00:00
Reedy
39f0f919c5 Update suppressWarning()/restoreWarning() calls
Bug: T182273
Change-Id: I9e1b628fe5949ca54258424c2e45b2fb6d491d0f
2018-02-10 08:50:12 +00:00
Umherirrender
3124a990a2 Use ::class to resolve class names in includes files
This helps to find renamed or misspelled classes earlier.
Phan will check the class names

Change-Id: I07a925c2a9404b0865e8a8703864ded9d14aa769
2018-01-27 20:34:29 +01: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
5544cef16b Add missing type to @param documentation
Change-Id: I6b2c9c7af9a281fe457099cc3a336a60a25e74aa
2017-08-11 20:37:35 +02:00
Umherirrender
a9007e8baf Add missing & to @param documentation to match functon call
Change-Id: I81e68310abcbc59964b22e0e74842d509f6b1fb9
2017-08-11 18:47:46 +02:00
Reedy
4b0567a86b Swap SqliteInstaller::MINIMUM_VERSION for SqliteInstaller::$minimumVersion
Makes it like the rest of the Installer classes

Change-Id: I940e71878f4e9454371c0e1da0ef5d6bfa51ebdd
2017-07-13 22:40:09 +00:00
Aaron Schulz
dd359741cc Move DB errors to Rdbms namespace
Change-Id: I463bd86123501abc68fdb78b4cda6110f7af2549
2017-04-15 10:47:41 -07:00
Aaron Schulz
d735dc562d Move Database and subclasses to Rdbms namespace
Change-Id: I52bef87512f9ddd155d1f4cc0052f6b7a0db5b42
2017-04-12 10:43:57 -07:00
Bartosz Dziewoński
ecdef925bb Miscellaneous indentation tweaks
I was bored. What? Don't look at me that way.

I mostly targetted mixed tabs and spaces, but others were not spared.
Note that some of the whitespace changes are inside HTML output,
extended regexps or SQL snippets.

Change-Id: Ie206cc946459f6befcfc2d520e35ad3ea3c0f1e0
2017-02-27 19:23:54 +01:00
Aaron Schulz
5bbac35ed1 Replace DatabaseBase:: with Database:: and update type hints
Change-Id: I3919b04eb2de4fa0bf8a02239fb5bbf17d347511
2016-09-27 04:20:03 +00:00
jenkins-bot
f197ed2395 Merge "Fix minor SqliteInstaller IDEA warning" 2016-09-20 19:27:55 +00:00
Marius Hoch
2d16cb6069 Fix SQLite $wgObjectCaches definition + b/c handling
Follow-up to 47e816c69c

Change-Id: Id94857a7c8726871cf826a34b5cf10cb465b7125
2016-09-19 19:41:23 +00:00
Marius Hoch
0cd59925f5 Fix SqliteInstaller DatabaseSqlite creation
Follow-up to 47e816c69c

Change-Id: I1612b0a187ea1df272bdd304ffb2bafbc006b2e4
2016-09-19 20:21:14 +02:00
Aaron Schulz
e962645d18 Fix minor SqliteInstaller IDEA warning
Change-Id: I13f6adebf436c40c3c8555fd2fe95db161ab1a8b
2016-09-19 11:19:04 -07:00
umherirrender
f800abc858 Use short array for generator output
The AutoloadGenerator and LocalSettingsGenerator should generate short
array syntax

Change-Id: I5772640556fd6274db0d522341a98c0acfe5794d
2016-02-17 22:08:07 +01: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
Kunal Mehta
f6e5079a69 Use mediawiki/at-ease library for suppressing warnings
wfSuppressWarnings() and wfRestoreWarnings() were split out into a
separate library. All usages in core were replaced with the new
functions, and the wf* global functions are marked as deprecated.

Additionally, some uses of @ were replaced due to composer's autoloader
being loaded even earlier.

Ie1234f8c12693408de9b94bf6f84480a90bd4f8e adds the library to
mediawiki/vendor.

Bug: T100923
Change-Id: I5c35079a0a656180852be0ae6b1262d40f6534c4
2015-06-11 18:49:29 +00:00
Aaron Schulz
46cf4f1e30 Clean up $wgSQLiteDataDir handling and removed standalone sqlite class
* The data directory can now be set via the construction params
* A standalone factory method now replaces the subclass
* Also made mDatabaseFile protected

Change-Id: I1791fd4f630e5c121fa7f68f473411a7c12d0c97
2015-03-09 18:35:24 +00:00
Aaron Schulz
a9780637fe Made the SQLite installer make a separate objectcache DB
* This avoids severe lock contention if CACHE_DB is used and also makes
  cache sharing between wikis simple (keys are always prefixed as needed).

Bug: T89180
Change-Id: I864272af099a9ebe2b3648e2714d2ccdee20305d
2015-02-25 23:05:10 +00:00
jenkins-bot
19d6957824 Merge "DatabaseBase constructor cleanups" 2015-02-23 21:18:23 +00:00
Aaron Schulz
2cfcb390c6 DatabaseBase constructor cleanups
* The array based format is now required
* Pass any additional parameters through factory() to __construct() even
  if the base clase does not recognize them. This makes DB specific
  options simpler.
* Also added missing bits to Sqlite constructors

Bug: T90288
Change-Id: I29b79a3c1bb2b5e51c1c8f5e04cd08c71e0662a3
2015-02-23 13:02:28 -08:00
umherirrender
583764482a DatabaseInstaller::getGlobalDefaults: Return all needed globals
Since Id364306d883e0d494b948854e05f3f79ba7dd6d2 the text boxes on the
gui installer were not preloaded with the default values from
DefaultSettings.php.

Changed this by return all needed globals (defined by getGlobalNames)
from DatabaseInstaller::getGlobalDefaults(). This injects the as default
value in function getVar and than gets used, when no value is set.

Bug: T71281
Change-Id: I8217b25e903e40ec82be3d700381ff7aea3b481f
2015-02-22 00:17:14 +00:00
umherirrender
f5f1e38b9a Fixed some @params documentation (includes/[db|installer])
Swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.
Also added some missing @param.

Change-Id: I3595e9aac69ac42fbb74b0783fae0ad9bcc831aa
2014-04-19 13:55:27 +02:00
Siebrand Mazeland
bb0044f638 Address PHP CodeSniffer errors and warnings
One class of errors left unaddressed: Class name "WebInstaller_Language"
is not in camel caps format. I think this can be changed, too, but I
wasn't able to quickly find out where class names are being created.

Change-Id: I920b0231db1b70b68c6c8907257c288a0e112668
2013-10-23 12:42:07 +00:00
Siebrand Mazeland
626addab9e Update formatting
With some manual corrections.

Change-Id: Icd947288c32fdb90a0f35388963ef5a17ffa58e7
2013-10-09 09:35:18 +00:00
umherirrender
ee31d37821 Fixed spacing in context/installer/media/templates/upload folder
Added spaces before if, foreach
Added some braces for one line statements

Change-Id: I9761be9fa47adc3554852a97b19792b4648466ad
2013-04-21 06:22:06 +00:00
umherirrender
d63121016d fix some spacing
Added/removed spaces around logical/arithmetic operator
Reduced multiple empty lines to one empty line
Removed wrong tabs before comments at end of line
Removed too many spaces in assigments

Change-Id: I2bba4e72f9b5f88c53324d7b70e6042f1aad8f6b
2013-03-07 17:53:21 +01:00
Max Semenik
18e80879f2 Make sure that SQLite uses no prefix
Otherwise, when user selects MySQL, sets the prefix,
then switches  to SQLite, the tables will created with  prefix
however the prefix will be absent from LocalSettings, making the
wiki dead on arrival.

Change-Id: I6360af819f87b03c2e9967207c43bca95f931a00
2012-11-10 15:24:10 +05:30
Alexandre Emsenhuber
09bb6975c5 Added missing GPLv2 headers in some places.
Also made file/class documentation more consistent.

Change-Id: I1615bf268515ed7169e33173cea6ec30402451dc
2012-05-06 07:50:15 +02:00
Sam Reed
7b25f8231f Fixing some of the "@return true" or "@return false", need to be "@return bool" and then the metadata can say true if foo, false if bar
Other documentation improvements
2012-02-09 19:30:01 +00:00
Max Semenik
16b811c803 Made installer not install on SQLite less than 3.3.7, would prevent stuff like bug 25746. Also, threw MSSQL out of release notes - it can't be installed through the usual means. 2012-01-04 10:41:39 +00:00
Sam Reed
66e01d1bb7 Adding __METHOD__ to parameters passed to wfMkdirParents() 2011-07-25 22:01:19 +00:00
Tim Starling
b37cde66c1 PostgreSQL install fixes:
* Made PG throw a DBQueryError when it gets a query error, instead of DBUnexpectedError. Apparently this mistake goes back to r14625, when exceptions were first introduced. Did it by removing reportQueryError(), the DatabaseBase version works fine.
* Fixed several places where there was an attempt to check for a query error by checking if the result of query() was false. This never worked. Used try/catch instead.
* Made the DBConnectionError messages go on one line so that they don't mess up the formatting in the installer.
* In DatabasePostgres::selectDB(), only disconnect and reconnect if the DB name is actually changing.
* Made DatabasePostgres::schemaExists() less weird and scary.
* Added DatabasePostgres::roleExists() for use by the installer.
* Removed the PostgreSQL-specific hack to make _InstallUser have a default other than "root". Made _InstallUser into a proper DBMS-specific internal variable instead, since every DBMS we support so far needs a different default.
* Removed the $dbName parameters from openConnection/getConnection, and got rid of $this->useAdmin. Implemented a more sophisticated caching scheme instead. Partial revert of r89389 and r81440.
* When connecting as the install user before DB creation, and when testing the web user's credentials, try a few different database names and use whichever one works. 
* Instead of connecting as the web user to create tables, I used SET ROLE. It seems cleaner and more like what the other DBMSes do during installation. "SET ROLE wikiuser" requires the same privileges as "CREATE SCHEMA ... AUTHORIZATION wikiuser", so it's unlikely to break anything.
* In the area of web account creation, fixed various minor logic errors and introduced more informative error messages at the submit stage, pre-install. Show a helpful error message if the web user exists already and the install user can't do the relevant SET ROLE.
* Split schema creation out to a separate install step.
* When creating an account as a non-superuser, add the administrative account to the new account's group. This is necessary to avoid a fatal error during installation (bug 28845).
* Removed code which alters an existing web user to have appropriate search paths and permissions. This may break other apps and is not necessary. As in other DBMSes, If the web user exists, it is the responsibility of the sysadmin to ensure that it has appropriate permissions.
* Rewrote setupPLpgSQL() to use the query builder functions.
2011-06-10 11:32:57 +00:00