- upgrade script: do DB update even if stop_web is present,

rather than spewing an HTML error message.
    Fixes #875


svn path=/trunk/boinc/; revision=17839
This commit is contained in:
David Anderson 2009-04-17 02:08:05 +00:00
parent 217b1a6086
commit 0b11a548dc
5 changed files with 51 additions and 22 deletions

View File

@ -3952,7 +3952,7 @@ David 15 Apr 2009
samples/example_app/
uc2.cpp
Davaid 16 Apr 2009
David 16 Apr 2009
- client: another try at fixing the above crash
- web: don't show plan class in separate column in apps list; fixes #874
@ -3960,3 +3960,18 @@ Davaid 16 Apr 2009
app_control.cpp
html/user/
apps.php
David 16 Apr 2009
- upgrade script: do DB update even if stop_web is present,
rather than spewing an HTML error message.
Fixes #875
html/
inc/
boinc_db.inc
util.inc
ops/
db_update.php
user/
apps.php

View File

@ -22,33 +22,47 @@ require_once("../inc/util_basic.inc");
class BoincDb extends DbConn {
static $instance;
// connect to the database (possibly to a read-only replica)
//
static function get_aux($readonly) {
$config = get_config();
$user = parse_config($config, '<db_user>');
$passwd = parse_config($config, '<db_passwd>');
$host = parse_config($config, '<db_host>');
$replica_host = parse_config($config, '<replica_db_host>');
$name = parse_config($config, '<db_name>');
if ($host == null) {
$host = "localhost";
}
$instance = new DbConn();
if ($readonly && $replica_host) {
$retval = $instance->init_conn($user, $passwd, $replica_host, $name);
if ($retval) return $instance;
}
$retval = $instance->init_conn($user, $passwd, $host, $name);
if (!$retval) {
$instance = null;
}
self::$instance = $instance;
}
// same, but
// 1) check for a cached connection
// 2) check whether the "stop_web" trigger file is present
//
static function get($readonly = false) {
if (!isset($instance)) {
if (!isset(self::$instance)) {
if (web_stopped()) {
show_page("Project down for maintenence",
"Please check back in a few hours."
);
exit;
}
$config = get_config();
$user = parse_config($config, '<db_user>');
$passwd = parse_config($config, '<db_passwd>');
$host = parse_config($config, '<db_host>');
$replica_host = parse_config($config, '<replica_db_host>');
$name = parse_config($config, '<db_name>');
if ($host == null) {
$host = "localhost";
}
$instance = new DbConn();
if ($readonly && $replica_host) {
$retval = $instance->init_conn($user, $passwd, $replica_host, $name);
if ($retval) return $instance;
}
$retval = $instance->init_conn($user, $passwd, $host, $name);
if (!$retval) return null;
self::get_aux($readonly);
}
return $instance;
return self::$instance;
}
static function escape_string($string) {
$db = self::get();
return parent::base_escape_string(trim($string));

View File

@ -739,7 +739,7 @@ function check_web_stopped() {
// Connects to database server and selects database as noted in config.xml
// If only read-only access is necessary,
// tries instead to connect to <replica_db_host> if tag exists.
// DEPRECATED - use boinc_db.h
// DEPRECATED - use boinc_db.inc
//
function db_init($try_replica=false) {
check_web_stopped();

View File

@ -25,7 +25,7 @@ require_once("../inc/util.inc");
require_once("../inc/ops.inc");
cli_only();
db_init();
BoincDb::get_aux(false);
set_time_limit(0);

View File

@ -22,7 +22,7 @@ require_once("../inc/translation.inc");
$platforms = BoincPlatform::enum("deprecated=0");
$xml = $_GET['xml'];
$xml = get_str('xml', true);
if ($xml) {
require_once('../inc/xml.inc');
xml_header();