fix PHP 8.0 errors around ACL dialog and policy:

- bitwise AND operator gives TypeError if both values are neither a number nor a numeric string, eg: null, "run"
- Etemplate::setElementAttribute() must NOT be called before instantiating an Etemplate object, you will get fatal error otherwise, because no request object
This commit is contained in:
Ralf Becker 2021-10-08 09:05:58 +02:00
parent d43c27a31b
commit fac81f660d
2 changed files with 5 additions and 1 deletions

View File

@ -1044,6 +1044,10 @@ class Widget
*/ */
public static function &setElementAttribute($name,$attr,$val) public static function &setElementAttribute($name,$attr,$val)
{ {
if (!isset(self::$request))
{
throw new \Exception(__METHOD__."('$name', '$attr', ".json_encode($val)." called before instanciating Api\Etemplate!");
}
//error_log(__METHOD__."('$name', '$attr', ...) request=".get_class(self::$request).", response=".get_class(self::$response).function_backtrace()); //error_log(__METHOD__."('$name', '$attr', ...) request=".get_class(self::$request).", response=".get_class(self::$response).function_backtrace());
$ref =& self::$request->modifications[$name][$attr]; $ref =& self::$request->modifications[$name][$attr];
if(self::$request && self::$response) if(self::$request && self::$response)

View File

@ -839,7 +839,7 @@ class Select extends Etemplate\Widget
} }
foreach((array)$options as $right => $name) foreach((array)$options as $right => $name)
{ {
if(!!($value & $right)) if (!!((int)$value & (int)$right))
{ {
$new_value[] = $right; $new_value[] = $right;
} }