Jump to content
thirty bees forum

Recommended Posts

Posted (edited)

UPDATED

After an upgrade to the latest bleeding edge I got the attached error. The error happens on the orders page in the backoffice and is obviously caused by the Whatsapp module. What puzzles me is that these function declarations and calls were the same under the old version where they didn't give a problem. The error message seems correct. Yet under the old version I didn't get an error.

After some search I found that the GetAdminLink function in Link.php had been changed.

The old version was:

    public function getAdminLink($controller, $withToken = true)
    {   $idLang = Context::getContext()->language->id;
        $params = $withToken ? ['token' => Tools::getAdminTokenLite($controller)] : [];
        return Dispatcher::getInstance()->createUrl($controller, $idLang, $params, false);
    }

The new version is:

    public function getAdminLink($controller, $withToken = true, $params = [])
    {   $idLang = Context::getContext()->language->id;
        if ($withToken) {
            $params['token'] = Tools::getAdminTokenLite($controller);
        }
        return Dispatcher::getInstance()->createUrl($controller, $idLang, $params, false);
    }

The puzzling thing is that the whatsappchat module calls it thus:

            $this->context->smarty->assign(array(
                'action' => $this->l('WhatsApp'),
                'action_whatsappchat' => $this->l('WhatsApp with this customer'),
                'admin_base_dir' => $this->currentPageURL(),
                'this_path_bo' => $this->_path,
                'iso_code' => $this->context->language->iso_code,
                'whatsappchat_admincontroller' => $this->context->link->getAdminLink('AdminWhatsappChat', true, $this->context->language->id),
                'url' => false,
                'show_button' => true,
                'token' => Tools::getValue('token')
            ));

So here the third argument is an integer.

coreupdate.jpg.thumb.jpg.b62f981a6987112237ebe4bc400e348a.jpg

 

Edited by musicmaster
Posted

Yeah, this is definitely a bug in the Whatsapp module. The proper way is to fix the module itself. Module should not pass integer as 3rd parameter. This method always accepted 2 parameters only (in ps16, and in all previous tb versions), so passing this 3rd parameter was always a no-op. 

We will see more issues like this in the future, with newer PHP versions being much more strict. 

Posted

The code I added was borrowed [with a twist] from the latest Prestashop 1.7. I haven't checked it but i wouldn't be surprised if for some PS versions this was what worked.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...