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
1 changed files with 4 additions and 8 deletions

View File

@ -128,6 +128,7 @@ class addressbook_contactform
}
}
}
static $contact = null;
if (!is_array($content))
{
$preserv['tpl_form_name'] = $tpl_name;
@ -143,11 +144,7 @@ class addressbook_contactform
{
if ($name[0] == '#') // custom field
{
static $contact;
if (is_null($contact))
{
$contact = new Api\Contacts();
}
if (!isset($contact)) $contact = new Api\Contacts();
$content['show']['custom'.$custom] = true;
$content['customfield'][$custom] = $name;
$content['customlabel'][$custom] = $contact->customfields[substr($name,1)]['label'];
@ -178,8 +175,7 @@ class addressbook_contactform
$preserv[$name]=$value;
if ($name[0] == '#') // custom field
{
static $contact;
if (is_null($contact)) $contact = new Api\Contacts();
if (!isset($contact)) $contact = new Api\Contacts();
$content['show']['custom'.$custom] = true;
$content['customfield'][$custom] = $name;
$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);
}
}
}