Jump to content

Edit History

alerax

alerax

4 hours ago, AddWeb Solution said:

Hi,

To fix this issue, you can modify your code to handle the potential null value returned by Tab::getIdFromClassName($tab)

$tabId = Tab::getIdFromClassName($tab);
if ($tabId !== null) {
    return Tools::getAdminToken($tab . (int) $tabId . (int) $context->employee->id);
} else {
	error_log("Error: Tab ID is null for tab '$tab'");
	return false; // Or any default value you want
}

I hope this would help!

Thanks.

Hello thanks your for your reply. I don't understand how do you mean to change original code with your code. Do you mean to change all or add?

can explain me better?

thx

Original code

 

/**
     * @param string $tab
     * @param Context $context
     *
     * @return bool|string
     */
    public static function getAdminTokenLite($tab, Context $context = null)
    {
        if (!$context) {
            $context = Context::getContext();
        }

        return Tools::getAdminToken($tab . (int) Tab::getIdFromClassName($tab) . (int) $context->employee->id);             <----- LINE 1307
    }

alerax

alerax

4 hours ago, AddWeb Solution said:

Hi,

To fix this issue, you can modify your code to handle the potential null value returned by Tab::getIdFromClassName($tab)

$tabId = Tab::getIdFromClassName($tab);
if ($tabId !== null) {
    return Tools::getAdminToken($tab . (int) $tabId . (int) $context->employee->id);
} else {
	error_log("Error: Tab ID is null for tab '$tab'");
	return false; // Or any default value you want
}

I hope this would help!

Thanks.

Hello thanks your for your reply. I don't understand how do you mean to change original code with your code. Do you mean to change all or ad?

can explain me better?

thx

Original code

 

/**
     * @param string $tab
     * @param Context $context
     *
     * @return bool|string
     */
    public static function getAdminTokenLite($tab, Context $context = null)
    {
        if (!$context) {
            $context = Context::getContext();
        }

        return Tools::getAdminToken($tab . (int) Tab::getIdFromClassName($tab) . (int) $context->employee->id);             <----- LINE 1307
    }

×
×
  • Create New...