Magento2: Unable to generate unsecure URL if current URL is secure

Created on 16 Aug 2016  路  10Comments  路  Source: magento/magento2

Preconditions

  1. Magento 2 version 2.1.0
  2. Use MagentoFrameworkUrl::getUrl() from secure area of the store

Steps to reproduce

  1. Make sure code is executed in secure area of the store (HTTPS)
  2. Generate URL in code
    /**
     * @var \Magento\Framework\Url
     */
    protected $url;
...
    $this->url->getUrl(
        'test/test/test',
        [
            '_secure' => false
        ]
    )
  1. Resulting URL is https://example.com/test/test/test

    Expected result

  1. Make sure code is executed in secure area of the store (HTTPS)
  2. Generate URL in code
    /**
     * @var \Magento\Framework\Url
     */
    protected $url;
...
    $this->url->getUrl(
        'test/test/test',
        [
            '_secure' => false
        ]
    )
  1. Resulting URL is http://example.com/test/test/test

Reason behind such behavior is:

https://github.com/magento/magento2/blob/2.1.0/lib/internal/Magento/Framework/Url.php#L364-L366

where code assumes that if current request is secure, requested url should be secure as well, regardless to '_secure' parameter saying otherwise.

Format is not valid Ready for Work bug report

Most helpful comment

Hi @piotrekkaminski, thanks for status update.

But I'm not sure why is this one marked with an improvement tag when it's about already implemented feature, the _secure switch to MagentoFrameworkUrl::getUrl whose functionality breaks under described circumstances aka a bug.

All 10 comments

Thank you for your submission.

We recently made some changes to the way we process GitHub submissions to more quickly identify and respond to core code issues.

Feature Requests and Improvements should now be submitted to the new Magento 2 Feature Requests and Improvements forum (see details here).

We are closing this GitHub ticket and have moved your request to the new forum.

Hi @piotrekkaminski, thanks for status update.

But I'm not sure why is this one marked with an improvement tag when it's about already implemented feature, the _secure switch to MagentoFrameworkUrl::getUrl whose functionality breaks under described circumstances aka a bug.

I am also facing the same issue. Is this issue had been fixed?

Marked as feature/improvement request therefore closed. Nevertheless still an issue within Magento 2.1.4 codebase:

https://github.com/magento/magento2/blob/2.1.4/lib/internal/Magento/Framework/Url.php#L364-L366

Ok, but in feature/improvement request also it is not resolved. This is a very disappointment thing that such a basic functionality is also not working.

Internal ticket MAGETWO-62500

Please can anyone tell me how to check the status of internal ticket created MAGETWO-62500.

I will check this

Internal ticket to track issue progress: MAGETWO-70591

Internal ticket to track issue progress: MAGETWO-70736

Was this page helpful?
0 / 5 - 0 ratings