From 0da6e258817c8fa814d44302ba0f2d7ccf910623 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 19 Dec 2024 11:23:45 +0100 Subject: [PATCH] FIX backport from develop to avoid php warning --- htdocs/core/ajax/ajaxtooltip.php | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/htdocs/core/ajax/ajaxtooltip.php b/htdocs/core/ajax/ajaxtooltip.php index 129658ef8fd18..4dcf81f0d9531 100644 --- a/htdocs/core/ajax/ajaxtooltip.php +++ b/htdocs/core/ajax/ajaxtooltip.php @@ -34,23 +34,40 @@ if (!defined('NOREQUIREAJAX')) { define('NOREQUIREAJAX', '1'); } +if (!defined('NOHEADERNOFOOTER')) { + define('NOHEADERNOFOOTER', '1'); +} + include '../../main.inc.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; +/** + * @var Conf $conf + * @var DoliDB $db + * @var HookManager $hookmanager + * @var Translate $langs + * @var User $user + */ $id = GETPOST('id', 'aZ09'); $objecttype = GETPOST('objecttype', 'aZ09arobase'); // 'module' or 'myobject@mymodule', 'mymodule_myobject' $params = array('fromajaxtooltip' => 1); if (GETPOSTISSET('infologin')) { - $params['infologin'] = GETPOST('infologin', 'int'); + $params['infologin'] = GETPOSTINT('infologin'); } if (GETPOSTISSET('option')) { $params['option'] = GETPOST('option', 'restricthtml'); } - +$element_ref = ''; +if (is_numeric($id)) { + $id = (int) $id; +} else { + $element_ref = $id; + $id = 0; +} // Load object according to $element -$object = fetchObjectByElement($id, $objecttype); +$object = fetchObjectByElement($id, $objecttype, $element_ref); if (empty($object->element)) { httponly_accessforbidden('Failed to get object with fetchObjectByElement(id='.$id.', objecttype='.$objecttype.')'); } @@ -78,10 +95,11 @@ $html = ''; if (is_object($object)) { + '@phan-var-force CommonObject $object'; if ($object->id > 0 || !empty($object->ref)) { /** @var CommonObject $object */ $html = $object->getTooltipContent($params); - } elseif ($res == 0) { + } elseif ($id > 0) { $html = $langs->trans('Deleted'); } unset($object);