fix installation under PHP 8.1

This commit is contained in:
ralf 2022-12-05 15:55:30 +01:00
parent 7be8eb86f5
commit 65ad5fc1d0
5 changed files with 59 additions and 46 deletions

View File

@ -160,7 +160,7 @@ abstract class admin_cmd
*
* @return string
*/
function __tostring()
function __toString()
{
return $this->type;
}
@ -274,7 +274,7 @@ abstract class admin_cmd
* of the command (to not allow to send new commands with an earsdroped secret) and the md5 hash
* of the md5 hash of the config password and the install_id (egw_admin_remote.remote_hash)
*
* @return string sussess message
* @return string success message
* @throws Exception(lang('Invalid remote id or name "%1"!',$this->remote_id),997) or other Exceptions reported from remote
*/
protected function remote_exec()
@ -380,35 +380,42 @@ abstract class admin_cmd
$vars['type'] = substr($this->type, 11);
}
admin_cmd::$sql->init($vars);
if (admin_cmd::$sql->save() != 0)
try
{
return false;
}
if (!$this->id)
{
$this->id = admin_cmd::$sql->data['id'];
// if the cmd has no uid yet, we create one from our id and the install-id of this eGW instance
if (!$this->uid)
admin_cmd::$sql->init($vars);
if (admin_cmd::$sql->save() != 0)
{
$this->uid = $this->id.'-'.$GLOBALS['egw_info']['server']['install_id'];
admin_cmd::$sql->save(array('uid' => $this->uid));
return false;
}
if (!$this->id)
{
$this->id = admin_cmd::$sql->data['id'];
// if the cmd has no uid yet, we create one from our id and the install-id of this eGW instance
if (!$this->uid)
{
$this->uid = $this->id . '-' . $GLOBALS['egw_info']['server']['install_id'];
admin_cmd::$sql->save(array('uid' => $this->uid));
}
}
// install an async job, if we saved a scheduled job
if ($this->status == admin_cmd::scheduled && empty($this->rrule))
{
admin_cmd::_set_async_job();
}
// schedule periodic execution, if we have a rrule
elseif (!empty($this->rrule) && $this->status != admin_cmd::deleted)
{
$this->set_periodic_job();
}
// existing object with no rrule, cancel evtl. running periodic job
elseif ($vars['id'])
{
$this->cancel_periodic_job();
}
}
// install an async job, if we saved a scheduled job
if ($this->status == admin_cmd::scheduled && empty($this->rrule))
{
admin_cmd::_set_async_job();
}
// schedule periodic execution, if we have an rrule
elseif (!empty($this->rrule) && $this->status != admin_cmd::deleted)
{
$this->set_periodic_job();
}
// existing object with no rrule, cancle evtl. running periodic job
elseif($vars['id'])
{
$this->cancel_periodic_job();
catch (Api\Db\Exception $e) {
_egw_log_exception($e);
return false;
}
return true;
}
@ -461,7 +468,7 @@ abstract class admin_cmd
}
/**
* Instanciated the object / subclass using the given data
* Instantiate the object / subclass using the given data
*
* @static
* @param array $data

View File

@ -69,7 +69,7 @@ use HTTP_WebDAV_Server;
*/
class Vfs extends Vfs\Base
{
const PREFIX = Vfs\StreamWrapper::PREFIX;
const PREFIX = 'vfs://default'; // using the original definition sometimes gives an autoloading error: Vfs\StreamWrapper::PREFIX;
/**
* Name of the lock table

View File

@ -313,7 +313,7 @@ class setup_cmd_header extends setup_cmd
*
* @param string $arg current cli argument processed
* @param string $name name of the property
* @param array/string $data string with type or array containing values for type, allowed
* @param array|string $data string with type or array containing values for type, allowed
* @param mixed $value value to set
*/
private function _parse_value($arg,$name,$data,$value)
@ -321,7 +321,7 @@ class setup_cmd_header extends setup_cmd
static $domain=null;
if (!is_array($data)) $data = array('type' => $data);
$type = $data['type'];
$type = $data['type'] ?? '';
if (isset($data['allowed']))
{
@ -341,31 +341,37 @@ class setup_cmd_header extends setup_cmd
}
elseif ($value !== '')
{
self::_set_value($GLOBALS,str_replace('@',$domain,$type),$name,$value);
self::_set_global(str_replace('@', $domain, $type), $name, $value);
if ($type == 'egw_info/server/server_root')
{
self::_set_value($GLOBALS,'egw_info/server/include_root',$name,$value);
self::_set_global('egw_info/server/include_root', $name, $value);
}
}
}
/**
* Set a value in the given array $arr with (multidimensional) key $index[/$name]
* Set a value in $GLOBALS with (multidimensional) key $index[/$name]
*
* @param array &$arr
* @param string $index multidimensional index written with / as separator, eg. egw_info/server/
* @param string $name additional index to use if $index end with a slash
* @param mixed $value value to set
*/
static private function _set_value(&$arr,$index,$name,$value)
private static function _set_global($index, $name, $value)
{
if (substr($index,-1) == '/') $index .= $name;
$var =& $arr;
foreach(explode('/',$index) as $name)
$var = null;
foreach(explode('/',$index) as $n)
{
$var =& $var[$name];
if (isset($var))
{
$var =& $var[$n];
}
else
{
$var =& $GLOBALS[$n];
}
}
if (true) $var = $value;
$var = $value;
}
}
}

View File

@ -109,8 +109,8 @@ class setup_cmd_install extends setup_cmd
$setup_info = self::$egw_setup->detection->upgrade_exclude($setup_info);
// Set the DB's client charset if a system-charset is set
self::$egw_setup->system_charset = strtolower($this->charset);
self::$egw_setup->db->Link_ID->SetCharSet($this->charset);
self::$egw_setup->system_charset = 'utf-8';
self::$egw_setup->db->Link_ID->SetCharSet(self::$egw_setup->db->Type === 'mysql' ? 'utf8' : 'utf-8');
$_POST['ConfigLang'] = $this->lang;
if ($this->verbose) echo lang('Installation started, this might take a few minutes ...')."\n";
@ -120,4 +120,4 @@ class setup_cmd_install extends setup_cmd
return lang('Installation finished');
}
}
}

View File

@ -30,7 +30,7 @@ if(file_exists(__DIR__.'/../../header.inc.php'))
include_once(__DIR__.'/../../header.inc.php');
}
// for an old header we need to setup a reference for the domains
if (!is_array($GLOBALS['egw_domain'])) $GLOBALS['egw_domain'] =& $GLOBALS['phpgw_domain'];
if (!isset($GLOBALS['egw_domain']) && isset($GLOBALS['phpgw_domain'])) $GLOBALS['egw_domain'] =& $GLOBALS['phpgw_domain'];
/* If we included the header.inc.php, but it is somehow broken, cover ourselves... */
if(!defined('EGW_SERVER_ROOT') && !defined('EGW_INCLUDE_ROOT'))
@ -88,4 +88,4 @@ if (!function_exists('version_compare') || version_compare(PHP_VERSION,$GLOBALS[
echo "EGroupware now requires PHP {$GLOBALS['egw_setup']->required_php_version} or greater.\nYour PHP version is: ".PHP_VERSION."\n";
echo 'Please contact your System Administrator.';
exit;
}
}