fix PHP 8.4 Fatal error: Duplicate declaration of static variable $contact

This commit is contained in:
ralf 2024-04-09 13:19:22 +02:00
parent ab9434ae45
commit 7be3530b9d

View File

@ -128,6 +128,7 @@ class addressbook_contactform
} }
} }
} }
static $contact = null;
if (!is_array($content)) if (!is_array($content))
{ {
$preserv['tpl_form_name'] = $tpl_name; $preserv['tpl_form_name'] = $tpl_name;
@ -143,11 +144,7 @@ class addressbook_contactform
{ {
if ($name[0] == '#') // custom field if ($name[0] == '#') // custom field
{ {
static $contact; if (!isset($contact)) $contact = new Api\Contacts();
if (is_null($contact))
{
$contact = new Api\Contacts();
}
$content['show']['custom'.$custom] = true; $content['show']['custom'.$custom] = true;
$content['customfield'][$custom] = $name; $content['customfield'][$custom] = $name;
$content['customlabel'][$custom] = $contact->customfields[substr($name,1)]['label']; $content['customlabel'][$custom] = $contact->customfields[substr($name,1)]['label'];
@ -178,8 +175,7 @@ class addressbook_contactform
$preserv[$name]=$value; $preserv[$name]=$value;
if ($name[0] == '#') // custom field if ($name[0] == '#') // custom field
{ {
static $contact; if (!isset($contact)) $contact = new Api\Contacts();
if (is_null($contact)) $contact = new Api\Contacts();
$content['show']['custom'.$custom] = true; $content['show']['custom'.$custom] = true;
$content['customfield'][$custom] = $name; $content['customfield'][$custom] = $name;
$content['customlabel'][$custom] = $contact->customfields[substr($name,1)]['label']; $content['customlabel'][$custom] = $contact->customfields[substr($name,1)]['label'];
@ -234,4 +230,4 @@ class addressbook_contactform
return $tpl->exec($this->callback,$content,$sel_options,array(),$preserv); return $tpl->exec($this->callback,$content,$sel_options,array(),$preserv);
} }
} }