Avoid some PHP warnings

- Undefined array keys
- Undefined class variables
- Passing null to string functions
This commit is contained in:
nathan 2023-06-07 13:50:08 -06:00
parent f16cfd45fe
commit 492993e78e
6 changed files with 15 additions and 7 deletions

View File

@ -114,7 +114,7 @@ class Date extends Transformer
return $value; return $value;
} // otherwise we will get current date or 1970-01-01 instead of an empty value } // otherwise we will get current date or 1970-01-01 instead of an empty value
$format = $this->attrs['dataFormat'] ?? $this->attrs['data_format']; $format = $this->attrs['dataFormat'] ?? $this->attrs['data_format'] ?? "";
// for DateTime objects (regular PHP and Api\DateTime ones), set user timezone // for DateTime objects (regular PHP and Api\DateTime ones), set user timezone
if($value instanceof \DateTime) if($value instanceof \DateTime)
{ {

View File

@ -189,7 +189,7 @@ class Grid extends Box
foreach(array_merge(array($direct_child), $n ? array() : $direct_child->children) as $child) foreach(array_merge(array($direct_child), $n ? array() : $direct_child->children) as $child)
{ {
$pat = $child->id; $pat = $child->id;
while(($patstr = strstr($pat, '$'))) while($pat && ($patstr = strstr($pat, '$')))
{ {
$pat = substr($patstr, $patstr[1] == '{' ? 2 : 1); $pat = substr($patstr, $patstr[1] == '{' ? 2 : 1);

View File

@ -136,7 +136,7 @@ class Nextmatch extends Etemplate\Widget
} }
// Check for sort preference. We only apply this on first load so it can be changed // Check for sort preference. We only apply this on first load so it can be changed
if($GLOBALS['egw_info']['user']['preferences'][$app][$this->attrs['template'] . "_sort"]) if(array_key_exists($this->attrs['template'] . "_sort", $GLOBALS['egw_info']['user']['preferences'][$app]))
{ {
$send_value['sort'] = $GLOBALS['egw_info']['user']['preferences'][$app][$this->attrs['template'] . "_sort"]; $send_value['sort'] = $GLOBALS['egw_info']['user']['preferences'][$app][$this->attrs['template'] . "_sort"];
} }

View File

@ -644,7 +644,7 @@ class Select extends Etemplate\Widget
} }
// Legacy / static support // Legacy / static support
// Have to do this explicitly, since legacy options is not defined on class level // Have to do this explicitly, since legacy options is not defined on class level
$legacy_options = explode(',',$_legacy_options); $legacy_options = explode(',', $_legacy_options ?? "");
foreach($legacy_options as &$field) foreach($legacy_options as &$field)
{ {
$field = self::expand_name($field, 0, 0,'','',self::$cont); $field = self::expand_name($field, 0, 0,'','',self::$cont);

View File

@ -261,6 +261,10 @@ class Hooks
// some apps have setup_info for more then themselfs (eg. api for groupdav) // some apps have setup_info for more then themselfs (eg. api for groupdav)
foreach($setup_info as $appname => $data) foreach($setup_info as $appname => $data)
{ {
if(!array_key_exists('hooks', $data))
{
continue;
}
foreach((array)$data['hooks'] as $location => $methods) foreach((array)$data['hooks'] as $location => $methods)
{ {
if (is_int($location)) if (is_int($location))

View File

@ -51,6 +51,10 @@ class importexport_definitions_ui
* @var object * @var object
*/ */
var $plugin; var $plugin;
private Etemplate $etpl;
private string $clock;
private array $steps;
private $wizard_content_template;
function __construct() function __construct()
{ {