mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-23 16:33:17 +01:00
merged setup-cli related bugfixes 27105, 27106 and 27109
This commit is contained in:
parent
4fa8fba8c0
commit
a305a7fbbf
@ -1433,6 +1433,10 @@ function egw_exception_handler(Exception $e)
|
||||
{
|
||||
$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
|
||||
{
|
||||
$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
|
||||
if(!isset($_SERVER['HTTP_HOST']) || $GLOBALS['egw_info']['flags']['no_exception_handler'] == 'cli')
|
||||
{
|
||||
echo $headline.': '.$e->getMessage()."\n";
|
||||
echo $e->getTraceAsString()."\n";
|
||||
echo ($headline ? $headline.': ' : '').$e->getMessage()."\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
|
||||
}
|
||||
// regular GUI exception
|
||||
|
@ -15,6 +15,11 @@
|
||||
*/
|
||||
class setup_cmd_install extends setup_cmd
|
||||
{
|
||||
/**
|
||||
* Allow to run this command via setup-cli
|
||||
*/
|
||||
const SETUP_CLI_CALLABLE = true;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
|
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.');
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
* @link http://www.egroupware.org
|
||||
* @package setup
|
||||
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
||||
* @copyright (c) 2006-8 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
||||
* @copyright (c) 2006-9 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @version $Id$
|
||||
*/
|
||||
@ -22,6 +22,7 @@ elseif ($_SERVER['argc'] > 1)
|
||||
$arguments = $_SERVER['argv'];
|
||||
array_shift($arguments);
|
||||
$action = array_shift($arguments);
|
||||
list($_POST['FormDomain']) = explode(',',$arguments[0]); // header include needs that to detects the right domain
|
||||
}
|
||||
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
|
||||
}
|
||||
// setting up the $GLOBALS['egw_setup'] object AND including the header.inc.php if it exists
|
||||
$_POST['FormDomain'] = $arguments[0];
|
||||
$GLOBALS['egw_info'] = array(
|
||||
'flags' => array(
|
||||
'currentapp' => 'setup',
|
||||
@ -112,7 +112,8 @@ switch($action)
|
||||
if (substr($action,0,2) == '--' && class_exists($class = str_replace('-','_',substr($action,2))) &&
|
||||
is_subclass_of($class,'admin_cmd') && constant($class.'::SETUP_CLI_CALLABLE'))
|
||||
{
|
||||
$args = null;
|
||||
$args = array();
|
||||
$args['domain'] = array_shift($arguments); // domain must be first argument, to ensure right domain get's selected in header-include
|
||||
foreach($arguments as $arg)
|
||||
{
|
||||
list($name,$value) = explode('=',$arg,2);
|
||||
@ -120,8 +121,16 @@ switch($action)
|
||||
{
|
||||
throw new egw_exception_wrong_userinput(lang("Invalid argument '%1' !!!",$arg),90);
|
||||
}
|
||||
if (substr($name,-1) == ']') // allow 1-dim. arrays
|
||||
{
|
||||
list($name,$sub) = explode('[',substr($name,0,-1),2);
|
||||
$args[$name][$sub] = $value;
|
||||
}
|
||||
else
|
||||
{
|
||||
$args[$name] = $value;
|
||||
}
|
||||
}
|
||||
$cmd = new $class($args);
|
||||
$msg = $cmd->run();
|
||||
if (is_array($msg)) $msg = print_r($msg,true);
|
||||
@ -252,7 +261,8 @@ function do_update($arg)
|
||||
{
|
||||
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'];
|
||||
if ($domain && $domain != 'all')
|
||||
@ -261,8 +271,7 @@ function do_update($arg)
|
||||
}
|
||||
foreach($domains as $domain => $data)
|
||||
{
|
||||
$options[0] = $domain;
|
||||
$arg = implode(',',$options);
|
||||
$arg = "$domain,$user,$password,$backup";
|
||||
|
||||
_check_auth_config($arg,14);
|
||||
|
||||
@ -272,18 +281,10 @@ function do_update($arg)
|
||||
}
|
||||
else
|
||||
{
|
||||
echo lang('Start updating the database ...')."\n";
|
||||
|
||||
do_backup($arg,true);
|
||||
|
||||
ob_start();
|
||||
$GLOBALS['egw_setup']->process->init_process(); // we need a new schema-proc instance for each new domain
|
||||
$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";
|
||||
$cmd = new setup_cmd_update($domain,$user,$password,$backup,true);
|
||||
echo $cmd->run()."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user