- Merge request !89Issue #3076946: Failed to validate remote image with no file extension → (Open) created by mpaulo
- First commit to issue fork.
- last update
over 1 year ago 703 pass - @elaman opened merge request.
- last update
over 1 year ago 703 pass - last update
over 1 year ago 703 pass Had to import XLSX files that similarly did not have a filename in the path. Used content-disposition / content-type headers. If someone finds this useful, this worked for me, up to now.
- 🇳🇱Netherlands megachriz
Because tests are failing, I added a task to the list that says "Try to adjust the code or the tests so that they pass.".
- 🇳🇱Netherlands megachriz
@arccoss and I looked at this issue yesterday at the DICTU Drupal Developers Day in Assen.
@arccoss confirmed that the MR !89 fixes the issue for images. We also found out why the test is currently failing. It is because the call toDrupal\feeds\Feeds\Target\File::getMimeSubtypeFromUrl()
doesn't work in a Kernel test. The method is using cURL and since a Kernel test only has PHP and a database, but not an accessible site via HTTP, trying to retrieve something from a url like "http://localhost/modules/custom/feeds/tests/resources/assets/attersee_no..." will result into a 404 HTML-document, hence why the test said the extension is html, because that is whatDrupal\feeds\Feeds\Target\File::getMimeSubtypeFromUrl()
will get from a 404.A way to deal with this and keep the Kernel test, is to somehow override the curl part of
Drupal\feeds\Feeds\Target\File::getMimeSubtypeFromUrl()
in the test. So here are some thoughts about what we could do:- The method could be split up into two parts, one that does the curl thing and one that does the "finfo" thing.
- In FileTest.php and in ImageTest.php we add a class that extends
Drupal\feeds\Feeds\Target\File
andDrupal\feeds\Feeds\Target\Image
respectively and changeFileTest::getTargetPluginClass()
andImageTest::getTargetPluginClass()
to return the newly created classes. In these classes a method would need to be overridden: getMimeSubtypeFromUrl()
could be completely overridden, returning just an extension string.- Or just the curl part would get overridden, but that method override must be capable of returning something similar as what curl can do and I don't know enough about curl to know if that's doable.
- An other thought, instead of using curl directly here, replace the logic with using a service. I'm not sure if the same result could be achieved using Guzzle?
- I believe that there's also a possibility that curl is not available and perhaps the code should also account for that situation. At least in the D7 version of Feeds there was a check for this in the function
http_request_use_curl()
. Maybe we can avoid doing a check like this if we can replace the usage of curl with a service, as said in the point above.
I also wondered why what there is another MR here. It seems like an other approach, but there's no clear explanation of why it exists.
@imash Can you explain why you opened another MR? Did the other MR not work or does your MR solves something that is not covered by the other one?