forked from extern/egroupware
- fixed in some cases not working setup-cli (domain not detected)
- make update a separat setup-cmd-object - fixed handling of egw_exception_wrong_userinput, to not include a trace (which is unneeded for regular input-validation)
This commit is contained in:
parent
5e9699a5b5
commit
6d72b2b297
@ -1433,6 +1433,10 @@ function egw_exception_handler(Exception $e)
|
|||||||
{
|
{
|
||||||
$headline = try_lang('Database error');
|
$headline = try_lang('Database error');
|
||||||
}
|
}
|
||||||
|
elseif ($e instanceof egw_exception_wrong_userinput)
|
||||||
|
{
|
||||||
|
$headline = ''; // message contains the whole message, it's usually no real error but some input validation
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$headline = try_lang('An error happend');
|
$headline = try_lang('An error happend');
|
||||||
@ -1446,8 +1450,8 @@ function egw_exception_handler(Exception $e)
|
|||||||
// exception handler for cli (command line interface) clients, no html
|
// exception handler for cli (command line interface) clients, no html
|
||||||
if(!isset($_SERVER['HTTP_HOST']) || $GLOBALS['egw_info']['flags']['no_exception_handler'] == 'cli')
|
if(!isset($_SERVER['HTTP_HOST']) || $GLOBALS['egw_info']['flags']['no_exception_handler'] == 'cli')
|
||||||
{
|
{
|
||||||
echo $headline.': '.$e->getMessage()."\n";
|
echo ($headline ? $headline.': ' : '').$e->getMessage()."\n";
|
||||||
echo $e->getTraceAsString()."\n";
|
if (!($e instanceof egw_exception_wrong_userinput)) echo $e->getTraceAsString()."\n";
|
||||||
exit($e->getCode() ? $e->getCode() : 9999); // allways give a non-zero exit code
|
exit($e->getCode() ? $e->getCode() : 9999); // allways give a non-zero exit code
|
||||||
}
|
}
|
||||||
// regular GUI exception
|
// regular GUI exception
|
||||||
|
80
setup/inc/class.setup_cmd_update.inc.php
Normal file
80
setup/inc/class.setup_cmd_update.inc.php
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* EGroupware setup - update one EGroupware instances
|
||||||
|
*
|
||||||
|
* @link http://www.egroupware.org
|
||||||
|
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
||||||
|
* @package setup
|
||||||
|
* @copyright (c) 2009 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
||||||
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* setup command: update one EGroupware instances
|
||||||
|
*/
|
||||||
|
class setup_cmd_update extends setup_cmd
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Allow to run this command via setup-cli
|
||||||
|
*/
|
||||||
|
const SETUP_CLI_CALLABLE = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param string|array $domain string with domain-name or array with all arguments
|
||||||
|
* @param string $config_user=null user to config the domain (or header_admin_user)
|
||||||
|
* @param string $config_passwd=null pw of above user
|
||||||
|
* @param string $backup=null filename of backup to use instead of new install, default new install
|
||||||
|
* @param boolean $verbose=false if true, echos out some status information during the run
|
||||||
|
*/
|
||||||
|
function __construct($domain,$config_user=null,$config_passwd=null,$backup=null,$verbose=false)
|
||||||
|
{
|
||||||
|
if (!is_array($domain))
|
||||||
|
{
|
||||||
|
$domain = array(
|
||||||
|
'domain' => $domain,
|
||||||
|
'config_user' => $config_user,
|
||||||
|
'config_passwd' => $config_passwd,
|
||||||
|
'backup' => $backup,
|
||||||
|
'verbose' => $verbose,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
//echo __CLASS__.'::__construct()'; _debug_array($domain);
|
||||||
|
admin_cmd::__construct($domain);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* run the command: update
|
||||||
|
*
|
||||||
|
* @param boolean $check_only=false only run the checks (and throw the exceptions), but not the command itself
|
||||||
|
* @return string serialized $GLOBALS defined in the header.inc.php
|
||||||
|
* @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2);
|
||||||
|
* @throws Exception('header.inc.php not found!');
|
||||||
|
*/
|
||||||
|
protected function exec($check_only=false)
|
||||||
|
{
|
||||||
|
global $setup_info;
|
||||||
|
|
||||||
|
// instanciate setup object and check authorisation
|
||||||
|
$this->check_setup_auth($this->config_user,$this->config_passwd,$this->domain);
|
||||||
|
|
||||||
|
$this->check_installed($this->domain,array(14),$this->verbose);
|
||||||
|
|
||||||
|
$setup_info = self::$egw_setup->detection->upgrade_exclude($setup_info);
|
||||||
|
|
||||||
|
self::_echo_message($this->verbose,lang('Start updating the database ...'));
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
self::$egw_setup->process->init_process(); // we need a new schema-proc instance for each new domain
|
||||||
|
self::$egw_setup->process->pass($setup_info,'upgrade',false);
|
||||||
|
$messages = ob_get_contents();
|
||||||
|
ob_end_clean();
|
||||||
|
if ($messages && $this->verbose) echo strip_tags($messages)."\n";
|
||||||
|
|
||||||
|
$this->restore_db();
|
||||||
|
|
||||||
|
return lang('Update finished.');
|
||||||
|
}
|
||||||
|
}
|
@ -22,6 +22,7 @@ elseif ($_SERVER['argc'] > 1)
|
|||||||
$arguments = $_SERVER['argv'];
|
$arguments = $_SERVER['argv'];
|
||||||
array_shift($arguments);
|
array_shift($arguments);
|
||||||
$action = array_shift($arguments);
|
$action = array_shift($arguments);
|
||||||
|
list($_POST['FormDomain']) = explode(',',$arguments[0]); // header include needs that to detects the right domain
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -37,7 +38,6 @@ if (ini_get('session.save_handler') == 'files' && !is_writable(ini_get('session.
|
|||||||
ini_set('session.save_path','/tmp'); // regular users may have no rights to apache's session dir
|
ini_set('session.save_path','/tmp'); // regular users may have no rights to apache's session dir
|
||||||
}
|
}
|
||||||
// setting up the $GLOBALS['egw_setup'] object AND including the header.inc.php if it exists
|
// setting up the $GLOBALS['egw_setup'] object AND including the header.inc.php if it exists
|
||||||
$_POST['FormDomain'] = $arguments[0];
|
|
||||||
$GLOBALS['egw_info'] = array(
|
$GLOBALS['egw_info'] = array(
|
||||||
'flags' => array(
|
'flags' => array(
|
||||||
'currentapp' => 'setup',
|
'currentapp' => 'setup',
|
||||||
@ -261,7 +261,8 @@ function do_update($arg)
|
|||||||
{
|
{
|
||||||
global $setup_info;
|
global $setup_info;
|
||||||
|
|
||||||
list($domain,,,$no_backup) = $options = explode(',',$arg);
|
list($domain,$user,$password,$backup) = explode(',',$arg);
|
||||||
|
_fetch_user_password($user,$password);
|
||||||
|
|
||||||
$domains = $GLOBALS['egw_domain'];
|
$domains = $GLOBALS['egw_domain'];
|
||||||
if ($domain && $domain != 'all')
|
if ($domain && $domain != 'all')
|
||||||
@ -270,8 +271,7 @@ function do_update($arg)
|
|||||||
}
|
}
|
||||||
foreach($domains as $domain => $data)
|
foreach($domains as $domain => $data)
|
||||||
{
|
{
|
||||||
$options[0] = $domain;
|
$arg = "$domain,$user,$password,$backup";
|
||||||
$arg = implode(',',$options);
|
|
||||||
|
|
||||||
_check_auth_config($arg,14);
|
_check_auth_config($arg,14);
|
||||||
|
|
||||||
@ -281,18 +281,10 @@ function do_update($arg)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
echo lang('Start updating the database ...')."\n";
|
|
||||||
|
|
||||||
do_backup($arg,true);
|
do_backup($arg,true);
|
||||||
|
|
||||||
ob_start();
|
$cmd = new setup_cmd_update($domain,$user,$password,$backup,true);
|
||||||
$GLOBALS['egw_setup']->process->init_process(); // we need a new schema-proc instance for each new domain
|
echo $cmd->run()."\n";
|
||||||
$GLOBALS['egw_setup']->process->pass($setup_info,'upgrade',false);
|
|
||||||
$messages = ob_get_contents();
|
|
||||||
ob_end_clean();
|
|
||||||
if ($messages) echo strip_tags($messages)."\n";
|
|
||||||
|
|
||||||
echo lang('Update finished.')."\n";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user