Commit graph

108 commits

Author SHA1 Message Date
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
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
6c278b6d7e fix some spacing
* Removed spaces around array index
* Removed double spaces or added spaces to begin or end of function
  calls, method signature, conditions or foreachs
* Added braces to one-line ifs
* Changed multi line conditions to one line conditions
* Realigned some arrays

Change-Id: Ia04d2a99d663b07101013c2d53b3b2e872fd9cc3
2013-03-25 22:22:46 +00:00
Tyler Anthony Romeo
4dcc7961df Fixed @param tags to conform with Doxygen format.
Doxygen expects parameter types to come before the
parameter name in @param tags. Used a quick regex
to switch everything around where possible. This
only fixes cases where a primitve variable (or a
primitive followed by other types) is the variable
type. Other cases will need to be fixed manually.

Change-Id: Ic59fd20856eb0489d70f3469a56ebce0efb3db13
2013-03-11 13:15:01 -04: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
Siebrand Mazeland
d4b046a893 Update docs for return and exception info
* Removed some inline tabs in the process.
* IDE fixed some incorrect leading spaces, too.

Change-Id: Ic9303eff6db4424ac3f1fa2816839692b43e6190
2012-10-09 09:41:58 +00:00
Alex Monk
2fabea7eea Use wfMessage instead of deprecated wfMsg*
Or $this->msg in special pages.

Change-Id: I774a89d646615053c8424050e42ad95601f92543
2012-08-18 14:11:05 +02:00
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
saper
f752cf8042 Fix PostgreSQL updater to produce 1.19 schema
* PostgresField now reports column default value
* DatabasePostgres::indexAttributes reports index
  details
* Perform schema update in one transaction

With this change we can sucessfully update
MediaWiki 1.7.3 schema to trunk^Wmaster

Patch set 2: Rebased against master. PLEASE check carefully
to make sure I got those conflicted files right.

Conflicts:

	includes/db/DatabasePostgres.php
	includes/installer/PostgresUpdater.php

Change-Id: Iebb6855e8f6f44470bbb1dc5ab9ac1abb513adfe
2012-04-10 12:59:21 -04:00
Marcin Cieślak
cfb8e9a251 Handle PostgreSQL transaction errors and improve schema detection
* Introduce $wgDebugDBTransactions facility to help
  figure out what's going on with transactions.
  Currently PostgreSQL only.

  PostgresTransactionState can be easily be made more general 
  to trace all sorts of state machinery.

* Improve r113408: we don't need to full reconnect on error,
  rollback is enough. 
  
  Rolling back breaks search_path, as PostgreSQL
  can manage sessions settings under transaction therefore
  we need to improve schema sniffing introduced in r82674

* Introduce few schema handling functions. This could
  probably be generalized for other databases like DB2 and Oracle.

* Fix bug 15816 - Add a switch for SETting the search_path

  We try to avoid touching search_path at all unless
  really necessary. Even in this case we append MediaWiki
  core schema to the front of the list.

* No longer add $wgDBmwschema to PostgreSQL role search_path
  in the installer. This is no longer necessary as 
  setting schema on connect should ReallyWorkNow(tm).

* Get rid as much as possible of $wgDBmwschema and
  bring us one step closer to fix bug 16794 (wgSharedDB
  support). 
  
  All references to core MediaWiki schema in PostgreSQL
  specific code should now use Database::getCoreSchema() 
  unless we know what we are doing. 

Followup-To: r113408 r82674
2012-03-09 17:24:57 +00:00
Sam Reed
c47f83a4d4 More __METHOD__ in our madness 2012-02-24 18:45:24 +00:00
Sam Reed
2ec09c5165 More return documentation 2012-02-09 21:35:05 +00:00
Sam Reed
85bbb0b080 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 18:01:10 +00:00
OverlordQ
9191b2f8e6 Bug 28172 - wfGetDB called when it shouldn't be 2011-11-03 21:00:14 +00:00
Sam Reed
9d41b95053 Kill various unused variables
Comment some out also

Add some bits of documentation
2011-10-29 01:17:26 +00:00
Sam Reed
856faea6d6 Add documentation
Fix some unused variables, commented some others out
2011-10-18 17:26:09 +00:00
Mark A. Hershberger
a67094c6c1 Remove hardcoded commit statements for pg installer. 2011-10-11 21:54:10 +00:00
Mark A. Hershberger
d8db86a4a6 Fix cli install so that db user is created if needed. 2011-10-11 21:24:00 +00:00
Sam Reed
6bc9679307 Update calls to deprecated User::isValidEmailAddr
Fix trailing whitespace

Some minor documentation fixes
2011-06-26 19:16:04 +00:00
Tim Starling
88e8af820c Fix for r72150: rename getSchema() to getSchemaPath(). This terminology creates an unfortunate and potentially confusing conflict with the PostgreSQL usage of the term. At some point in the future I'd like to have a getSchema() that gives you the PostgreSQL schema name ($wgDBmwschema). Strictly speaking, tables.sql is not a schema, it's an SQL file that creates a schema. 2011-06-20 07:16:09 +00:00
Tim Starling
7a6c42e9bc Fix for r89821, r89839: we can skip certain tests if the web user is the same as the install user. 2011-06-10 22:33:16 +00:00
Mark A. Hershberger
1866fa1381 Make Pg installer work in the “common” case: follow up r89821 so that $exists can be set true if same user is the same for install and web. 2011-06-10 18:48:16 +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
Mark A. Hershberger
9be60e5725 forward port r88929 2011-06-03 03:41:11 +00:00
Mark A. Hershberger
44f9460caf w/s cleanup 2011-05-20 18:20:16 +00:00