r69909 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69908‎ | r69909 | r69910 >
Date:21:02, 25 July 2010
Author:platonides
Status:ok
Tags:
Comment:
Kill $wgDBsuperuser
Modified paths:
  • /trunk/phase3/config/Installer.php (modified) (history)
  • /trunk/phase3/includes/db/DatabasePostgres.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/db/DatabasePostgres.php
@@ -227,9 +227,9 @@
228228 }
229229
230230
231 - function initial_setup($password, $dbName) {
 231+ function initial_setup($superuser, $password, $dbName) {
232232 // If this is the initial connection, setup the schema stuff and possibly create the user
233 - global $wgDBname, $wgDBuser, $wgDBpassword, $wgDBsuperuser, $wgDBmwschema, $wgDBts2schema;
 233+ global $wgDBname, $wgDBuser, $wgDBpassword, $superuser, $wgDBmwschema, $wgDBts2schema;
234234
235235 print "<li>Checking the version of Postgres...";
236236 $version = $this->getServerVersion();
@@ -242,17 +242,17 @@
243243
244244 $safeuser = $this->quote_ident($wgDBuser);
245245 // Are we connecting as a superuser for the first time?
246 - if ($wgDBsuperuser) {
 246+ if ($superuser) {
247247 // Are we really a superuser? Check out our rights
248248 $SQL = "SELECT
249249 CASE WHEN usesuper IS TRUE THEN
250250 CASE WHEN usecreatedb IS TRUE THEN 3 ELSE 1 END
251251 ELSE CASE WHEN usecreatedb IS TRUE THEN 2 ELSE 0 END
252252 END AS rights
253 - FROM pg_catalog.pg_user WHERE usename = " . $this->addQuotes($wgDBsuperuser);
 253+ FROM pg_catalog.pg_user WHERE usename = " . $this->addQuotes($superuser);
254254 $rows = $this->numRows($res = $this->doQuery($SQL));
255255 if (!$rows) {
256 - print "<li>ERROR: Could not read permissions for user \"" . htmlspecialchars( $wgDBsuperuser ) . "\"</li>\n";
 256+ print "<li>ERROR: Could not read permissions for user \"" . htmlspecialchars( $superuser ) . "\"</li>\n";
257257 dieout('</ul>');
258258 }
259259 $perms = pg_fetch_result($res, 0, 0);
@@ -264,7 +264,7 @@
265265 }
266266 else {
267267 if ($perms != 1 and $perms != 3) {
268 - print "<li>ERROR: the user \"" . htmlspecialchars( $wgDBsuperuser ) . "\" cannot create other users. ";
 268+ print "<li>ERROR: the user \"" . htmlspecialchars( $superuser ) . "\" cannot create other users. ";
269269 print 'Please use a different Postgres user.</li>';
270270 dieout('</ul>');
271271 }
@@ -283,7 +283,7 @@
284284 }
285285 else {
286286 if ($perms < 1) {
287 - print "<li>ERROR: the user \"" . htmlspecialchars( $wgDBsuperuser ) . "\" cannot create databases. ";
 287+ print "<li>ERROR: the user \"" . htmlspecialchars( $superuser ) . "\" cannot create databases. ";
288288 print 'Please use a different Postgres user.</li>';
289289 dieout('</ul>');
290290 }
@@ -297,7 +297,7 @@
298298
299299 // Reconnect to check out tsearch2 rights for this user
300300 print "<li>Connecting to \"" . htmlspecialchars( $wgDBname ) . "\" as superuser \"" .
301 - htmlspecialchars( $wgDBsuperuser ) . "\" to check rights...";
 301+ htmlspecialchars( $superuser ) . "\" to check rights...";
302302
303303 $connectVars = array();
304304 if ($this->mServer!=false && $this->mServer!="") {
@@ -307,7 +307,7 @@
308308 $connectVars['port'] = $this->mPort;
309309 }
310310 $connectVars['dbname'] = $wgDBname;
311 - $connectVars['user'] = $wgDBsuperuser;
 311+ $connectVars['user'] = $superuser;
312312 $connectVars['password'] = $password;
313313
314314 @$this->mConn = pg_connect( $this->makeConnectionString( $connectVars ) );
@@ -380,7 +380,7 @@
381381 // Install plpgsql if needed
382382 $this->setup_plpgsql();
383383
384 - $wgDBsuperuser = '';
 384+ $superuser = '';
385385 return true; // Reconnect as regular user
386386
387387 } // end superuser
Index: trunk/phase3/config/Installer.php
@@ -1033,10 +1033,9 @@
10341034 ## Possible connect as a superuser
10351035 // Changed !mysql to postgres check since it seems to only apply to postgres
10361036 if( $useRoot && $conf->DBtype == 'postgres' ) {
1037 - $wgDBsuperuser = $conf->RootUser;
10381037 echo( "<li>Attempting to connect to database \"postgres\" as superuser \"" .
1039 - htmlspecialchars( $wgDBsuperuser ) . "\"..." );
1040 - $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBsuperuser, $conf->RootPW, "postgres", 1);
 1038+ htmlspecialchars( $conf->RootUser ) . "\"..." );
 1039+ $wgDatabase = $dbc->newFromParams($wgDBserver, $conf->RootUser, $conf->RootPW, "postgres", 1);
10411040 if (!$wgDatabase->isOpen()) {
10421041 print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
10431042 $errs["DBserver"] = "Could not connect to database as superuser";
@@ -1044,7 +1043,7 @@
10451044 $errs["RootPW"] = "and password";
10461045 continue;
10471046 }
1048 - $wgDatabase->initial_setup($conf->RootPW, 'postgres');
 1047+ $wgDatabase->initial_setup($conf->RootUser, $conf->RootPW, 'postgres');
10491048 }
10501049 echo( "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) .
10511050 "\" as \"" . htmlspecialchars( $wgDBuser ) . "\"..." );

Follow-up revisions

RevisionCommit summaryAuthorDate
r69970Followup r69909. This.. is.. no.. longer... a global!platonides20:55, 26 July 2010

Status & tagging log