Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method strtolower break case sensitive aliases #1

Closed
weierophinney opened this issue Dec 31, 2019 · 4 comments
Closed

Method strtolower break case sensitive aliases #1

weierophinney opened this issue Dec 31, 2019 · 4 comments

Comments

@weierophinney
Copy link
Member

@weierophinney you was right with breakage. Simple case from Magento 2.3. Host is not always domain or IP address. When we using docker we can call host via container names.

Example:

host = MAGENTO2_varnish

When we call strtolower then we getting error:

[2019-03-12 11:10:23] main.CRITICAL: Unable to connect to magento2_varnish:80 . Error #0: stream_socket_client(): unable to connect to magento2_varnish:80 (php_network_getaddresses: getaddrinfo failed: Name or service not known) {"method":"GET","url":"http:/","invalidateInfo":{"server":"[object] (Zend\\Uri\\Uri: http://magento2_varnish:80/)","tagsPattern":".*"}} []

So MAGENTO2_varnish != magento2_varnish.

If anyone ( like me ) using aliases on magento then this patch break eg. Varnish Purge request.

Originally posted by @bmxmale in zendframework/zend-uri#29 (comment)


Originally posted by @bmxmale at zendframework/zend-uri#31

@weierophinney
Copy link
Member Author

@bmxmale What is the context for your usage of zend-uri? Is it with the HTTP client? or an incoming request? Or something else?


Originally posted by @weierophinney at zendframework/zend-uri#31 (comment)

@weierophinney
Copy link
Member Author

@weierophinney I'm just community contributor of magento but will try to explain it in simple way.

This case come from PurgeCache event when we are using Varnish Cache as FPC.
On magento we need to set http_cache_host config to tell Magento where it should send purge request.

Magento config with Varnish host ( used on docker env )

return [
    'http_cache_hosts' => [
        [
            'host' => 'MAGENTO2_varnish'
        ]
    ]
];

Here you can check this option on magento devdocs.

Docker compose used to:

version: '2'
services:
  magento2_nginx:
    container_name: MAGENTO2_nginx
    image: nginx:stable
    volumes:
      - ../magento/magento-2.3:/srv/magento2.3
      - ./mount/nginx/magento.conf:/etc/nginx/conf.d/default.conf
    network_mode: "DOCKER_network"
  magento2_php:
    container_name: MAGENTO2_php
    image: bmxmale/magento2-php:2.3
    volumes_from:
      - magento2_nginx
    network_mode: "DOCKER_network"
  magento2_varnish:
      container_name: MAGENTO2_varnish
      image: bmxmale/docker-magento-varnish:5.2.1
      volumes:
        - ./mount/varnish/varnish.vcl:/etc/varnish/default.vcl
      environment:
        - DEFAULT_VCL=0
      network_mode: "DOCKER_network"
      labels:
        - "traefik.backend=MAGENTO2_varnish"
        - "traefik.port=80"
        - "traefik.frontend.rule=Host:magento.udviklet.dk"
        - "traefik.docker.network=DOCKER_network"

Step by step

  1. When we Refresh/Flush cache on magento, it will send purge request to varnish server.
    Magento\CacheInvalidate\Model\PurgeCache::sendPurgeRequest

  2. Now sendPurgeRequest method call getUris method from cacheServer class. Magento\PageCache\Model\Cache\Server::getUris

  3. Here getUris method create UriFactory to create array of servers to send purge request. Zend\Uri\UriFactory::factory

  4. Method UriFactory create new Uri object. Zend\Uri\Uri::setHost

  5. Method setHost with param $host = 'MAGENTO2_varnish' execute strtolower.
    As result $host variable will contain magento2_varnish

I'm open to call with you to answer any other questions.

With best regards, Mateusz


Originally posted by @bmxmale at zendframework/zend-uri#31 (comment)

@weierophinney
Copy link
Member Author

@weierophinney any update on this?

In my opinion we have 2 options:

Please select one or suggest better solution and I can prepare PR for this.


Originally posted by @bmxmale at zendframework/zend-uri#31 (comment)

@weierophinney
Copy link
Member Author

This package is considered feature-complete, and is now in security-only maintenance mode, following a decision by the Technical Steering Committee.
If you have a security issue, please follow our security reporting guidelines.
If you wish to take on the role of maintainer, please nominate yourself

If you are looking for an actively maintained package alternative, we recommend:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant