Hi, This is my first contribution to WikiMedia, so please forgive me(and tell me what to do in the future) if this is the wrong list for patches, or I have not correctly followed your coding style conventions.
The patch makes config/index.php work out of the box(before it failed with a database error). To get this to work, I had to make LoadBalancer.php honour $wgUseDatabaseMessages = false(the code is only run if the database connection has already failed, so there is no slowdown except in error situations). I also had to modify User.php so that a wgDebugDieBacktrace is not called when $wgUseDatabaseMessages = false. Again, this does not affect the "usual" path of execution. I added a $dbr == null check in Group.php, this does affect the usual path of execution, but is probably a check we should have anyway.
I also fixed some old and/or unnecessary code in config/index.php
Patch follows(-rbud options): cvs diff: Diffing config Index: config/index.php =================================================================== RCS file: /cvsroot/wikipedia/phase3/config/index.php,v retrieving revision 1.89 diff -b -u -d -r1.89 index.php --- config/index.php 28 Dec 2004 14:49:41 -0000 1.89 +++ config/index.php 15 Jan 2005 00:17:12 -0000 @@ -405,7 +405,6 @@ $wgDBadminuser = "root"; $wgDBadminpassword = $conf->RootPW; $wgDBprefix = $conf->DBprefix; - $wgCommandLineMode = true; $wgUseDatabaseMessages = false; /* FIXME: For database failure */ require_once( "includes/Setup.php" ); chdir( "config" ); @@ -414,7 +413,7 @@
$wgTitle = Title::newFromText( "Installation script" ); $wgDatabase = Database::newFromParams( $wgDBserver, "root", $conf->RootPW, "", 1 ); - $wgDatabase->mIgnoreErrors = true; + $wgDatabase->ignoreErrors(true);
@$myver = mysql_get_server_info( $wgDatabase->mConn ); if( $myver ) { @@ -436,7 +435,7 @@ $wgDBadminpassword = $wgDBpassword; $wgDatabase = Database::newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, "", 1 ); $wgDatabase->isOpen(); - $wgDatabase->mIgnoreErrors = true; + $wgDatabase->ignoreErrors(true); @$myver = mysql_get_server_info( $wgDatabase->mConn ); if( !$myver ) { $errs["DBuser"] = "Check name/pass"; @@ -1104,6 +1103,9 @@
$wgProxyKey = "$proxyKey";
+# The whitelist +$wgWhitelistRead = array("Special:Userlogin"); + ## Default skin: you can change the default skin. Use the internal symbolic ## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook': # $wgDefaultSkin = 'monobook'; cvs diff: Diffing docs cvs diff: Diffing docs/html cvs diff: Diffing docs/php-memcached cvs diff: Diffing extensions cvs diff: Diffing images cvs diff: Diffing includes Index: includes/Group.php =================================================================== RCS file: /cvsroot/wikipedia/phase3/includes/Group.php,v retrieving revision 1.2 diff -b -u -d -r1.2 Group.php --- includes/Group.php 24 Oct 2004 22:02:02 -0000 1.2 +++ includes/Group.php 15 Jan 2005 00:17:24 -0000 @@ -131,6 +131,8 @@ function nameFromId($id) { $fname = 'Group::nameFromId'; $dbr =& wfGetDB( DB_SLAVE ); + if ($dbr == null) + return; $r = $dbr->selectRow( 'group', array( 'group_name' ), array( 'group_id' => $id ), $fname );
if($r === false) { Index: includes/LoadBalancer.php =================================================================== RCS file: /cvsroot/wikipedia/phase3/includes/LoadBalancer.php,v retrieving revision 1.17 diff -b -u -d -r1.17 LoadBalancer.php --- includes/LoadBalancer.php 6 Dec 2004 01:14:53 -0000 1.17 +++ includes/LoadBalancer.php 15 Jan 2005 00:17:31 -0000 @@ -320,8 +320,11 @@
function reportConnectionError( &$conn ) { + global $wgUseDatabaseMessages; $fname = 'LoadBalancer::reportConnectionError'; wfProfileIn( $fname ); + if (!$wgUseDatabaseMessages) + return; # Prevent infinite recursion
static $reporting = false; Index: includes/User.php =================================================================== RCS file: /cvsroot/wikipedia/phase3/includes/User.php,v retrieving revision 1.114 diff -b -u -d -r1.114 User.php --- includes/User.php 8 Jan 2005 09:17:33 -0000 1.114 +++ includes/User.php 15 Jan 2005 00:17:36 -0000 @@ -379,7 +379,7 @@ * Load a user from the database */ function loadFromDatabase() { - global $wgCommandLineMode, $wgAnonGroupId, $wgLoggedInGroupId; + global $wgCommandLineMode, $wgAnonGroupId, $wgLoggedInGroupId, $wgUseDatabaseMessages; $fname = "User::loadFromDatabase";
# Counter-intuitive, breaks various things, use User::setLoaded() if you want to suppress @@ -397,9 +397,15 @@ /** Get rights */ $anong = Group::newFromId($wgAnonGroupId); if (!$anong) - wfDebugDieBacktrace("Please update your database schema " - ."and populate initial group data from " - ."maintenance/archives patches"); + { + if ($wgUseDatabaseMessages) + wfDebugDieBacktrace( + "Please update your database ". + "schema and populate initial ". + "group data from maintenance/". + "archives patches"); + return; + } $anong->loadFromDatabase(); $this->mRights = explode(',', $anong->getRights()); $this->mDataLoaded = true;
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Andrew Miller wrote:
Hi, This is my first contribution to WikiMedia, so please forgive me(and tell me what to do in the future) if this is the wrong list for patches, or I have not correctly followed your coding style conventions.
Hello Andrew,
You should probably send patch for mediawiki in mediawiki-l :o)
I commited in HEAD and REL1_4 your hunks for: * config/index.php : accessing group private propriety directly and the wgWhitelistRead thing. * Group.php : additional check for $dbr status
The patch makes config/index.php work out of the box(before it failed with a database error). To get this to work, I had to make LoadBalancer.php honour $wgUseDatabaseMessages = false(the code is only run if the database connection has already failed, so there is no slowdown except in error situations). I also had to modify User.php so that a wgDebugDieBacktrace is not called when $wgUseDatabaseMessages = false. Again, this does not affect the "usual" path of execution. I added a $dbr == null check in Group.php, this does affect the usual path of execution, but is probably a check we should have anyway.
I also fixed some old and/or unnecessary code in config/index.php
Patch follows(-rbud options):
I did not apply the $wgCommandLineMode = true in index.php cause it's not true :o) Need to find another way to use that :o)
Index: config/index.php
RCS file: /cvsroot/wikipedia/phase3/config/index.php,v retrieving revision 1.89 diff -b -u -d -r1.89 index.php --- config/index.php 28 Dec 2004 14:49:41 -0000 1.89 +++ config/index.php 15 Jan 2005 00:17:12 -0000 @@ -405,7 +405,6 @@ $wgDBadminuser = "root"; $wgDBadminpassword = $conf->RootPW; $wgDBprefix = $conf->DBprefix;
$wgCommandLineMode = true; $wgUseDatabaseMessages = false; /* FIXME: For database
failure */ require_once( "includes/Setup.php" ); chdir( "config" );
<snip hunks applied>
I did not apply the other parts concerning $wgUseDatabaseMessages cause I am too tired right now to check them and don't really understand them :o) Will have a look at them later if nobody did it. <snip $wgUseDatabaseMessages>
cheers,
- -- Ashar Voultoiz - WP++++ http://en.wikipedia.org/wiki/User:Hashar http://www.livejournal.com/community/wikitech/ Servers in trouble ? noc (at) wikimedia (dot) org
Ashar Voultoiz wrote: ...
I did not apply the $wgCommandLineMode = true in index.php cause it's
not true :o) Need to find another way to use that :o)
My patch removes that line(i.e. the - in unified diff means that it was in the code before but after the patch is applied it will be removed).
Index: config/index.php
RCS file: /cvsroot/wikipedia/phase3/config/index.php,v retrieving revision 1.89 diff -b -u -d -r1.89 index.php --- config/index.php 28 Dec 2004 14:49:41 -0000 1.89 +++ config/index.php 15 Jan 2005 00:17:12 -0000 @@ -405,7 +405,6 @@ $wgDBadminuser = "root"; $wgDBadminpassword = $conf->RootPW; $wgDBprefix = $conf->DBprefix;
$wgCommandLineMode = true; $wgUseDatabaseMessages = false; /* FIXME: For database
failure */ require_once( "includes/Setup.php" ); chdir( "config" );
...
On Jan 14, 2005, at 4:36 PM, Andrew Miller wrote:
+# The whitelist +$wgWhitelistRead = array("Special:Userlogin");
Since this causes any installed wiki to fail to be accessible, I've taken it out.
if ($dbr == null)
return;
As a general rule, you should use is_null() rather than == null, as the == operator is relatively 'weak' and will allow equality between for instance null and 0, "", and false.
function reportConnectionError( &$conn ) {
global $wgUseDatabaseMessages; $fname = 'LoadBalancer::reportConnectionError'; wfProfileIn( $fname );
if (!$wgUseDatabaseMessages)
return;
I don't understand the purpose of this. $wgUseDatabaseMessages controls whether user interface messages (generally retrieved via wfMsg() or wfMsgForContent() functions) are to be pulled from the MediaWiki: page entries in the database, or directly from the arrays defined in the language files.
Pulling messages from the default arrays should not prevent the reporting of database errors.
Additionally, as a general rule if you return from a profiled function you should remember to do a wfProfileOut( $fname ) to avoid unbalancing the call tree.
/** Get rights */ $anong = Group::newFromId($wgAnonGroupId); if (!$anong)
wfDebugDieBacktrace("Please update your database
schema "
."and populate initial group data from "
."maintenance/archives patches");
{
if ($wgUseDatabaseMessages)
wfDebugDieBacktrace(
"Please update your database ".
"schema and populate initial ".
"group data from maintenance/".
"archives patches");
return;
This is another really weird bit. Loading UI messages from the hardcoded arrays should definitely not cause a database error to be ignored.
Note also that wfDebugDieBacktrace() causes script execution to end, so a return statement after it can never be reached.
-- brion vibber (brion @ pobox.com)
wikitech-l@lists.wikimedia.org