From 46addb00fd4c7147be820dce3b111948048e9f0e Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Wed, 30 May 2012 23:04:10 +1200 Subject: [PATCH] Fix some final niggles with setup.php and spurious logged errors. --- htdocs/always.php | 3 +++ htdocs/setup.php | 36 ++++++++++++++++++++++++++++-------- inc/always.php.in | 3 +++ 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/htdocs/always.php b/htdocs/always.php index cda45b8d..1bdd81ac 100644 --- a/htdocs/always.php +++ b/htdocs/always.php @@ -92,7 +92,9 @@ $c->dbg = array(); // Utilities +if ( isset($skip_errors) ) $skip_errors = true; if ( ! @include_once('AWLUtilities.php') ) { + if ( isset($skip_errors) ) $skip_errors = false; $try_paths = array( '../../awl/inc' , '/usr/share/awl/inc' // Where it ends up on Debian @@ -110,6 +112,7 @@ if ( ! @include_once('AWLUtilities.php') ) { @ob_flush(); exit(0); } } +if ( isset($skip_errors) ) $skip_errors = false; // Ensure that ../inc is in our included paths as early as possible set_include_path( '../inc'. PATH_SEPARATOR. get_include_path()); diff --git a/htdocs/setup.php b/htdocs/setup.php index 1d6ef178..c4fda678 100644 --- a/htdocs/setup.php +++ b/htdocs/setup.php @@ -6,7 +6,10 @@ function i18n($value) { return $value; /* Just pass the value through */ } +$skip_errors = false; // We need to hide a couple of unsightly errors even here... function log_setup_error($errno , $errstr , $errfile , $errline) { + global $skip_errors; + if ( $skip_errors ) return; error_log('DAViCal setup.php: Informational: '.$errfile.'('.$errline.'): ['.$errno.'] '.$errstr); } @@ -97,7 +100,7 @@ function check_database_connection() { global $c; if ( !check_pdo_pgsql() ) return new CheckResult(false); - return new CheckResult( $c->schema_major != 0 || $c->schema_minor != 0 ); + return new CheckResult( !( empty($c->schema_major) || $c->schema_major == 0 || empty($c->schema_minor) || $c->schema_minor == 0) ); } function check_gettext() { @@ -187,15 +190,19 @@ $phpinfo = get_phpinfo(); try { include("./always.php"); + set_error_handler('log_setup_error', E_ALL); include("DAViCalSession.php"); if ( check_pgsql()->GetOK() ) { $session->LoginRequired( (isset($c->restrict_setup_to_admin) && $c->restrict_setup_to_admin ? 'Admin' : null ) ); } } catch( Exception $e ) { - set_error_handler('catch_setup_errors', E_ALL); - include("DAViCalSession.php"); -// $session = new FakeSession(1); + class FakeSession { + function AllowedTo() { + return true; + } + } + $session = new FakeSession(1); } @@ -244,8 +251,13 @@ function check_davical_version() { fclose($version_file); $result = new CheckResult($c->version_string == $current_version); if ( ! $result->getOK() ) { - $result->setDescription( sprintf(i18n('Want: %s, Currently: %s'), $current_version, $c->version_string) ); - if ( $c->version_string > $current_version ) $result->setClass('dep_warning'); + if ( $c->version_string > $current_version ) { + $result->setClass('dep_ok'); + $result->setDescription( sprintf(i18n('Stable: %s, We have: %s !'), $current_version, $c->version_string) ); + } + else { + $result->setDescription( sprintf(i18n('Want: %s, Currently: %s'), $current_version, $c->version_string) ); + } } return $result; } @@ -360,9 +372,17 @@ $th_dependency = translate('Dependency'); $th_status = translate('Status'); $dependencies_table = build_dependencies_table(); +$heading_site_statistics = translate('Site Statistics'); if ( check_database_connection()->GetOK() ) { - $heading_site_statistics = translate('Site Statistics'); - $site_statistics_table = build_site_statistics(); + try { + $site_statistics_table = build_site_statistics(); + } + catch( Exception $e ) { + $site_statistics_table = "Statistics unavailable"; + } +} +else { + $site_statistics_table = "Statistics unavailable"; } $heading_config_clients = translate('Configuring Calendar Clients for DAViCal'); diff --git a/inc/always.php.in b/inc/always.php.in index a3ecdd6a..f0a67616 100644 --- a/inc/always.php.in +++ b/inc/always.php.in @@ -92,7 +92,9 @@ $c->dbg = array(); // Utilities +if ( isset($skip_errors) ) $skip_errors = true; if ( ! @include_once('AWLUtilities.php') ) { + if ( isset($skip_errors) ) $skip_errors = false; $try_paths = array( '../../awl/inc' , '/usr/share/awl/inc' // Where it ends up on Debian @@ -110,6 +112,7 @@ if ( ! @include_once('AWLUtilities.php') ) { @ob_flush(); exit(0); } } +if ( isset($skip_errors) ) $skip_errors = false; // Ensure that ../inc is in our included paths as early as possible set_include_path( '../inc'. PATH_SEPARATOR. get_include_path());