Skip to content

Unable to generate unsecure URL if current URL is secure #6175

Closed
@Marko-M

Description

@Marko-M

Preconditions

  1. Magento 2 version 2.1.0
  2. Use \Magento\Framework\Url::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.

Metadata

Metadata

Assignees

Labels

Issue: Format is not validGate 1 Failed. Automatic verification of issue format is failedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentbug report

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions