4

We are facing a regression during an Magento update from 2.1.12 to 2.2.5 which I want to understand better.

Our code looks like this and is in a block on a tab of the backend order sales

public function getPostUrl()
{
    return $this->getUrl('orderattachments/upload/index');
}

The result of this call includes the order_id key in the URL, for example is

https://example.com/admin/orderattachments/upload/index/order_id/123/key/ada29d4295d76eaabd08a9c8ec6842bf2891da81a3e3c3bd5d5b0f7b8af3c4b8/

Now in 2.2.5 we get only

https://example.com/admin/orderattachments/upload/index/key/ada29d4295d76eaabd08a9c8ec6842bf2891da81a3e3c3bd5d5b0f7b8af3c4b8/

After lots of debugging I tracked this down to

https://github.com/magento/magento2/blob/2.2.5/app/code/Magento/Backend/Model/Url.php#L231

vs

https://github.com/magento/magento2/blob/2.1.12/app/code/Magento/Backend/Model/Url.php#L231

In the recent version, _getRouteParams is not called anymore, which, during my debugging session, revealed that this adds they order_id parameter.

Is this intended (so essentially like https://xkcd.com/1172/) and I should now add the order_id manually or is this a regression in the core that should be patched?

0

I have been told, that is makes more sense to supply that parameter manually and not to expect that request params are added automatically.

It was an easy fix:

public function getPostUrl()
{
    return $this->getUrl('orderattachments/upload/index',
         ['order_id' => $this->getOrder()->getId()]
    );
}

Workflow

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.