Problem/Motivation
One of our projects is hosted behind a reverse proxy (Squid) that is enforcing a network policy to only allow TCP traffic, and is dropping HTTP traffic. I was experiencing timeouts running the rokka_post_update_generate_missing_thumbnails() which I tracked down to this proxy issue.
The problem is in RokkaMetadataStorage::getImageDimensions(). It uses the ::parseFile() function from the GD toolkit to get image dimensions, but this fails in my situation because it cannot reach the Rokka servers.
Steps to reproduce
When PHP is operated behind a TCP only proxy, it cannot access HTTP resources through the functions from the standard library. For example a simple function like this will fail:
file_get_contents('https://myproject.rokka.io/dynamic/3f5f461dc4dac5d89c01d7a44f89e45e7ce3e630.jpg')
Proposed resolution
A robust practice in PHP for accessing online resources is to use dedicated HTTP clients (like Guzzle) which can handle the TCP protocol directly. You can see this also used in the Rokka PHP library for example. It is using file_get_contents() for accessing local files, but Guzzle for accessing files hosted on Rokka.
The GD toolkit doesn't use Guzzle obviously, but uses the internal PHP functions. The solution is to use the HTTP client for this. This is not a controversial change because we are already using this pattern everywhere else, for example the sister method RokkaMetadataStorage::getFileSize() also uses it for getting the file size. We just need to follow the same pattern.
Remaining tasks
Retrieve the image through the HTTP client instead of through the GD toolkit, before calculating the dimensions.
Issue fork rokka-3576209
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #5
pfrenssen