fix diverse undefined array-key or variable warnings

This commit is contained in:
ralf 2022-04-29 12:44:43 +02:00
parent 0758e17d24
commit 4fd00df861
6 changed files with 16 additions and 14 deletions

View File

@ -557,7 +557,7 @@ class Asyncservice
{
$row['async_times'] = json_php_unserialize($row['async_times']);
// check for broken value during migration
if ($row['async_data'][0] == '"' && substr($row['async_data'], 0, 7) == '"\\"\\\\\\"')
if (($row['async_data'][0]??null) === '"' && substr($row['async_data'], 0, 7) == '"\\"\\\\\\"')
{
$row['async_data'] = null;
$this->write(Db::strip_array_keys($row,'async_'), true);

View File

@ -232,7 +232,7 @@ class Categories
if ($parent_id && !in_array($cat['parent'],(array)$parent_id)) continue;
// return global categories just if $globals is set
if (!$globals && $cat['appname'] == self::GLOBAL_APPNAME)
if (!$globals && !empty($cat['appname']) && $cat['appname'] === self::GLOBAL_APPNAME)
{
continue;
}
@ -525,9 +525,9 @@ class Categories
}
// Read access to global categories
if ($needed == Acl::READ && (($is_global=array_intersect(explode(',',$category['owner']),$this->global_owners)) ||
if ($needed == Acl::READ && (($is_global=isset($category['owner']) && array_intersect(explode(',',$category['owner']),$this->global_owners)) ||
$no_acl_check && $category['access'] == 'public') && // no_acl_check only means public cats
($category['appname'] == self::GLOBAL_APPNAME || $category['appname'] == $this->app_name ||
(($category['appname'] ?? null) === self::GLOBAL_APPNAME || ($category['appname'] ?? null) == $this->app_name ||
$is_global && $allow_global_read))
{
//echo "<p>".__METHOD__."($needed,$category[name]) access because global via memberships</p>\n";
@ -535,7 +535,7 @@ class Categories
}
// Full access to own categories
if ($category['appname'] == $this->app_name && $category['owner'] == $this->account_id)
if (($category['appname'] ?? null) == $this->app_name && $category['owner'] == $this->account_id)
{
return true;
}
@ -547,15 +547,15 @@ class Categories
}
// Load the application grants
if ($category['appname'] == $this->app_name && is_null($this->grants))
if (($category['appname'] ?? null) == $this->app_name && isset($this->grants))
{
$this->grants = $GLOBALS['egw']->acl->get_grants($this->app_name,true);
}
// Check for ACL granted access, the self::GLOBAL_ACCOUNT user must not get access by ACL to keep old behaviour
$acl_grant = $this->account_id != self::GLOBAL_ACCOUNT && $category['appname'] == $this->app_name;
$acl_grant = $this->account_id != self::GLOBAL_ACCOUNT && ($category['appname'] ?? null) == $this->app_name;
$owner_grant = false;
foreach(explode(',',$category['owner']) as $owner)
foreach(!empty($category['owner']) ? explode(',',$category['owner']) : [] as $owner)
{
$owner_grant = $owner_grant || (is_array($this->grants) && !empty($this->grants[$owner]) && ($this->grants[$owner] & $needed) &&
($category['access'] === 'public' || ($this->grants[$owner] & Acl::PRIVAT)));

View File

@ -1648,7 +1648,7 @@ class Db
throw new Db\Exception\InvalidSql("db::column_data_implode('$glue',".print_r($array,True).",'$use_key',".print_r($only,True).",<pre>".print_r($column_definitions,True)."</pre><b>nothing known about column '$key'!</b>");
}
}
$column_type = is_array($column_definitions) ? @$column_definitions[$col]['type'] : False;
$column_type = is_array($column_definitions) ? ($column_definitions[$col]['type'] ?? false) : False;
$not_null = is_array($column_definitions) && isset($column_definitions[$col]['nullable']) ? !$column_definitions[$col]['nullable'] : false;
$maxlength = null;

View File

@ -710,6 +710,7 @@ class Widget
$row_cont = $cont[$row] ?? null;
$col_row_cont = $cont[$col.$row] ?? null;
$er = error_reporting(0);
try {
eval('$name = "' . str_replace('"', '\\"', $name) . '";');
}
@ -717,6 +718,7 @@ class Widget
error_log(__METHOD__."() eval('\$name = \"".str_replace('"', '\\"', $name) . "\";)");
_egw_log_exception($e);
}
error_reporting($er);
unset($col_, $row_, $row_cont, $col_row_cont); // quieten IDE warning about used vars, they might be used in above eval!
}
if ($is_index_in_content)

View File

@ -498,9 +498,9 @@ abstract class Framework extends Framework\Extra
}
$app = $GLOBALS['egw_info']['flags']['currentapp'];
$app_title = isset($GLOBALS['egw_info']['apps'][$app]) ? $GLOBALS['egw_info']['apps'][$app]['title'] : lang($app);
$app_title = $GLOBALS['egw_info']['apps'][$app]['title'] ?? lang($app);
$app_header = $GLOBALS['egw_info']['flags']['app_header'] ?? $app_title;
$site_title = strip_tags($GLOBALS['egw_info']['server']['site_title'].' ['.($app_header ? $app_header : $app_title).']');
$site_title = strip_tags(($GLOBALS['egw_info']['server']['site_title']??'').' ['.$app_header.']');
// send appheader to clientside
$extra['app-header'] = $app_header;

View File

@ -352,7 +352,7 @@ class Sharing extends \EGroupware\Api\Sharing
{
throw new Api\Exception\AssertionFailed("Could NOT create temp. file '$tmp_file'!");
}
if ($fp) fclose($fp);
if (isset($fp)) fclose($fp);
if (is_dir($path) && !Vfs::copy_files(array($path), $tmp_file) ||
!is_dir($path) && !copy($path, Vfs::PREFIX.$tmp_file))