Commit graph

133 commits

Author SHA1 Message Date
Daimona Eaytoy
947ff7c0f5 build: Update mediawiki/mediawiki-phan-config to 0.12.0
This patch only adds and removes suppressions, which must be done in the
same patch as the version bump.

Bug: T298571
Change-Id: I4044d4d9ce82b3dae7ba0af85bf04f22cb1dd347
2022-10-08 15:45:42 +02:00
Kunal Mehta
499a1fe497 rdbms: Move Database::factory() to DatabaseFactory service
We also bring along Database::attributesFromType(), which relied on the
private ::getClass(). This requires us to inject DatabaseFactory through
the LBFactory/LoadBalancer hierarchy.

Database::factory() is now soft deprecated. All callers outside of
includes/installer/ still need migration.

Bug: T299691
Bug: T315270
Change-Id: I7d057a9438f1b097554679975e4e9b2fc99e7c2b
2022-08-31 10:53:50 +10:00
James D. Forrester
aba3b27e2e Raise minimum supported postgres version from 9.5 to 10
Bug: T314163
Change-Id: Ic9c6ff7a66af0fa13676a32ed3d26b61acde55d3
2022-08-03 08:39:39 -04:00
Umherirrender
07b499fbcf build: Update mediawiki/mediawiki-phan-config to 0.11.0
Addition and remove of suppression needs to be done with the version
update.

Change-Id: I3288b3cefa744b507eadebb67b8ab08c86517c1c
2021-09-07 17:19:05 +02:00
Thiemo Kreuz
46f26dff03 Same code style and formatting for exists-style SQL queries
Queries that query a value "1" are expected to return either
that "1" (possibly as a string), or false. It's safe to simply
cast this to bool and use it as it is.

Queries for COUNT(*) are expected to return that number,
possibly as a string. It's not possible for such a query to
return false. And even if, casting to 0 is fine.

I found an existing code style where the table name and the
"1" are on the same line as the selectField() method name, and
applied it to all similar queries.

Change-Id: I9453196281871c03ef03f653f43762eb9284342f
2021-08-12 11:37:58 +02:00
DannyS712
a84ad7bd40 Add some missing __METHOD__ parameters to database calls
Plus fix a typo

Change-Id: I8ca326990559ea80254ce0cef2ed204590716679
2021-06-07 19:28:51 +00:00
Ammarpad
88bfadf5ed Migrate user table to abstract schema
Postgres:
 - Rename the table from `mwuser` to `user`
 - Transition user_id from int to serial
 - Make user_token not nullable and add default
 - Make user_real_name not nullable and add default
 - Make user_email not nullable
 - Make user_newpassword not nullable
 - Make user_password not nullable
 - Drop UNIQUE contraint on user_name and add default

MySQL/SQLite:
 * No changes

Bug: T164898
Bug: T230428
Change-Id: I746714f7b3ae16f9625f97bcca84280fcd8b61a0
2021-04-24 21:44:26 +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
Amir Sarabadani
c33876f834 Migrate text table to abstract schema
For MySQL/Sqlite, drop the table options, they are for MySQL < 5.0 which
was released in 2003 and not any use today.

For Postgres, rename pagecontent table to text, approved as part of the
RFC. Swap order of creating auto-generated tables and manual tables.

Bug: T230428
Bug: T164898
Change-Id: Id7510b80beed7a7297353094a57d5e2d4f12fc64
2021-01-09 16:07:54 +01:00
Reedy
5b8466ded4 Update minimum version of PostgreSQL to 9.4
9.4 was released December 2014, and became EOL in February 2020
https://www.postgresql.org/support/versioning/

Debian oldstable (Stretch) has PostgreSQL 9.6

Keeps things inline with doctrine/dbal 3.0.0, which only supports
PostgreSQL >= 9.4.

Bug: T270749
Change-Id: I9dc6af65f91849638a49f14e013b9a27fd6b8789
2020-12-23 02:48:50 +00:00
saper
b6c7fd6b4e installer: PostgreSQL installer should respect a custom port
Submitted by: joernc_unibi (Joern C.)

Bug: T30162
Bug: T245387
Change-Id: I99f0ae363096da49b3f840af999821a81767584e
2020-08-11 22:24:34 -07:00
Umherirrender
88fe512c22 Pass function name to database functions (rdbms/installer)
Change-Id: Ia37d37f2471960c1d9d04fd9bd86224058e88413
2020-06-07 21:06:47 +02:00
Reedy
60fdd5d8cd Fix some more Squiz.Scope.MethodScope.Missing
Change-Id: I5560d3d65a31f0922c9518b647be690fdb06e6be
2020-05-17 01:30:25 +00: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
Umherirrender
92a0db8165 Pass 1 always as string to IDatabase::select and friends
Column names or other sql fragments are strings, not integer

Change-Id: I7950b6e7ce4fa3b97c8b8ed55c8d7d0119eaac7e
2020-01-11 00:36:13 +00:00
James D. Forrester
4f2d1efdda Coding style: Auto-fix MediaWiki.Classes.UnsortedUseStatements.UnsortedUse
Change-Id: I94a0ae83c65e8ee419bbd1ae1e86ab21ed4d8210
2020-01-10 09:32:25 -08: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
Umherirrender
f74400487f phan: Disable enable_class_alias_support
It is enabled for b/c in extensions, but not needed in core

Change-Id: I51dca12be9c77049f77563d9bf0edd07928c2300
2019-09-15 08:26:52 +00: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
DannyS712
834064f645 Correct typo `notMinimumVerisonMessage'
Bug: T224449
Change-Id: I4d76f900770f74ce668abf71ea5e7a9f167f5950
2019-07-08 04:42:34 +00:00
Aaron Schulz
7911da9c6f rdbms: remove $opened field from Database for simplicity
This avoids having two similar fields that have to stay
in sync. Clean up the related error handling for connections.
If a connection handle is unusable, like when essential SET
queries fail, then destroy it.

Also:
* Avoid use of transactions in DatabasePostgres::determineCoreSchema.
* Make sure all subclasses log on connection failure.
* Add schema sanity checks to mysql/sqlite classes.
* Add IDatabase::QUERY_NO_RETRY flag to simplify reasoning about
  queries that already run on open() to begin with.
* Remove unused return value of Database::open.
* Remove deprecated Database::reportConnectionError method.

Change-Id: I97beba7ead1523085bda8784234d00c69ef1accc
2019-06-27 18:29:12 +01:00
Reedy
a469e81971 Fix typo of Minimum in variable name
Change-Id: I0d0ef26f59721039b2c24ab322fa3bf6ab16fea1
2019-05-26 20:11:05 +01:00
Fomafix
14d9e80ba4 Fix order of @var parameter in PHP
Replace

 @var $foo type

by

 @var type $foo

Change-Id: Iec8b90ffea4028a1005daef422b7c4ec38c2715f
2019-04-08 18:37:56 +02:00
Reedy
c13fee87d4 Collapse some nested if statements
Change-Id: I9a97325d738d09370d29d35d5254bc0dadc57ff4
2019-04-04 19:02:22 +00:00
Max Semenik
e6818e6c64 Fix unused vars/pointless assignments
Change-Id: If475c738b4af7208024c866594d4c0048af053dd
2019-03-29 16:52:48 -07:00
Max Semenik
eab02463f5 Bump required Postgres version to 9.2
This was approved by TechCom in the "PostgreSQL schema change for
consistency with MySQL" RfC (T164898).

Bug: T164898
Bug: T190539
Change-Id: I1b17c18c513e4edcd9219e36e873c55dd7f33034
2018-03-26 20:12:36 +00:00
Thiemo Mättig
ef470ebf7f Remove @param comments that literally repeat what the code says
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
2018-01-10 14:14:26 +01:00
jenkins-bot
f428f95ac4 Merge "Check minimum database server version when running update.php" 2017-10-20 23:57:51 +00:00
Umherirrender
14dfc3dbc5 Fix typo in 'language'
Change-Id: I3c4d090640892ae07d3da33dcfe3ace397a40808
2017-10-07 18:53:04 +02: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
Kunal Mehta
0cb2a09b6d Always put type information before variable name for @var tags
Like other tags, @var should have the type information before the
variable name.

<https://docs.phpdoc.org/references/phpdoc/tags/var.html>

Change-Id: I9eca6957b1990fa8cc687103dc02ee38af5f9086
2017-09-04 11:06:51 -07: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
Timo Tijhof
9b0cfff5aa installer: Fix "relation 'user' does not exist" error for Postgres
On Travis CI, the Postgres build has been failing very early on
in the installer (before phpunit) due to a database error:

> Creating administrator user account.. DBQueryError at Database.php:1059
> Query: SELECT user_id FROM "user" WHERE user_name = 'Admin' LIMIT 1
> Function: User::idForName
> Error: 42P01 ERROR:  relation "user" does not exist
> LINE 1: SELECT /* User::idForName  */ user_id FROM "user" ...

This is because the installer makes its own Database object without
involving ServiceWiring or MWLBFactory, which means wgDBport and
(more importantly) 'keywordTableMap' don't get applied.

While keywordTableMap doesn't matter during the database installation,
after the installer is done updating GlobalVarConfig and resetting
MediaWikiServices, DatabaseInstaller::enableLB takes that homemade
connection and injects it into MediaWikiServices by redefining
the 'DBLoadBalancerFactory' service. Which then affects all use
of wfGetDB(), such as from User::idForName().

Bug: T30162
Bug: T75174
Bug: T75176
Change-Id: I7af58c4beffc4908a93c0c1d8ab1aec9d4ec57c6
2017-02-23 19:39:03 -08:00
Aaron Schulz
66b0ad56df Postgres installation fixes
* Make isTransactableQuery() exclude CREATE/ALTER.
  Starting transactions for schema changes like this can cause
  errors as it is not supported for MySQL and some Postgres
  operations. Note that temporary tables are session-level,
  so they are not effected by this change.
* Clean up the transaction logic in determineCoreSchema()
  so a transaction is not left dangling.
* Fix broken getSchemaPath() call in PostgresInstaller.
* Avoid warnings in DatabasePostgres::closeConnection() if
  mConn is already unset.
* Commit master changes in doMaintenance.php before running
  deferred updates, just as MediaWiki.php does.
* Change E_WARNING to E_USER_WARNING to avoid notices in the
  default /rdbms error handlers.
* Also avoid trying to rollback in MWExceptionHandler if the
  LBFactory service is disabled, which just results in an error.

Bug: T147599
Change-Id: I64ccab7f9b74f60309ba0c9a8ce68337c42ffb0f
2016-10-17 15:06:38 -07:00
Aaron Schulz
30f4b3c103 Replace DatabaseBase => Database in more places
Change-Id: If37a7909056bf2c31a8228cbc84f0fbbf5f1c517
2016-09-28 15:53:02 -07:00
Aaron Schulz
5bbac35ed1 Replace DatabaseBase:: with Database:: and update type hints
Change-Id: I3919b04eb2de4fa0bf8a02239fb5bbf17d347511
2016-09-27 04:20:03 +00:00
Reedy
b5656b6953 Many more function case mismatches
Change-Id: I5d3a5eb8adea1ecbf136415bb9fd7a162633ccca
2016-03-19 00:20:58 +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
Siebrand Mazeland
2bdfbe629f Fix PHPCS warnings in includes/installer
8 uses of $IP remain, which trigger the global naming convention
check.

Change-Id: I1040782323ec7512fb7badd6052742ecd13d9dff
2015-09-28 13:40:27 +02:00
Brion Vibber
183bd8309a Don't break installation when the local db root user has no password
Reverts broken patch 0cf4e92d; it seems to have been intended to
validate the *to be created* db username/pass, but instead it
validates the *installation username/pass*. This made it impossible
to install if your db user had no password, as on many default dev
installations.

Bug: T85281
Change-Id: I0caaf8b9a244d6f4dad0cba32c566ea557f77fcc
2015-07-17 08:42:37 -05:00
Jeff Janes
1fd9f18d13 PostreSQL: DatabaseBase constructor cleanups
Change I29b79a3c1bb2b5e51c1c8f5e04cd08c71e0662a3 rendered
it uninstallable on PostgreSQL.

Make the corresponding API changes to PostgreSQL installer.

Bug: T90288
Change-Id: I2019893ad705d99f3dbbce13690cd808cfb71d4a
2015-02-25 18:27:59 +00: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
saper
229e56d2ca Schema is not PostgreSQL connection parameter
Temporary fix for bug 70030.

openConnectionWithParams() got a new schema
parameter in 30a82aae9c and therefore must
not be used to probe some available databases
when checking username/password, because
schema is not at all a PostgreSQL connection
parameter - it something similar to
"current directory" in the database. PostgreSQL
can additionally search additional schemas
for objects in necessary.

This whole openPgConnection logic needs some
deeper repair; for now however, let's quickly
fix bug 70030 which is caused by that fact
that openConnectionWithParams returns magic
"Status" object and no longer a DatabasePostgres
instance we can directly talk to.

As a result, openPgConnection( "create-db" )
was returning a Status object that had
another Status object embedded in the value
field.

This reverts partially commit 30a82aae9c.

Conflicts:
	includes/installer/Installer.php
	includes/installer/PostgresInstaller.php
	maintenance/install.php

Bug: 70030
Change-Id: I61d5f262e60722bc08201b40b61a298d8af42223
2014-08-26 21:11:25 +02:00
withoutaname
b803906e08 Fix calls to DatabaseBase static functions
Previously they were calling Database:: which is a nonexistent class.

Change-Id: I73b2ed4722c9108b6a00c8c0cabbda9564378b4b
2014-08-17 03:23:18 +00:00
umherirrender
2b021dc48a Fixed spacing
- Added/removed spaces around parenthesis
- Added space after switch/if/foreach
- changed else if to elseif

Change-Id: I99cda543e0e077320091addd75c188cb6e3a42c2
2014-07-19 23:12:10 +02:00
Skizzerz
30a82aae9c Set the default database schema to "mediawiki" so as not to break the CLI installer.
Due to changes made to support Microsoft SQL Server, $wgDBmwschema changed its default from
"mediawiki" to null in DefaultSettings.php, as anything else horribly broke every DBMS that did
not use schemas (such as MySQL and SQLite). This change makes it so that the default value can
be properly overridden again by PostgreSQL and Microsoft SQL Server, and also enables the
--dbschema flag to the CLI installer.

Bug: 64043
Change-Id: Id364306d883e0d494b948854e05f3f79ba7dd6d2
2014-07-09 00:20:36 +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
pubudu538
0cf4e92dec Error Msg for missing db username & password when installing
Added configurations for Mysql and Postgresql installers
to display an error message if user doesnt input a username to the
database username

Bug: 43528
Bug: 59663
Change-Id: Ib6b05d2d7e8ebb4438d3b0051c33d367f41a9957
2014-04-07 22:17:18 +05:30
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