Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The hook_file_transfer function in xmlsitemap module (line 2223) expects parameter one to be a Response object.
It seems that the module file_entity invokes this hook and it passes following arguments:
\Drupal::moduleHandler()->invokeAll('file_transfer', array($file->getFileUri(), $headers));
So this generates a fatal error... I looked into the code of xmlsitemap_file_transfer and all it does is adding header to the response object... what is the use of this function, I don't think this is needed. If so it has to be done in "hook_file_download_headers_alter" though.
Comment | File | Size | Author |
---|---|---|---|
#6 | xmlsitemap_hook_file_transfer-2831733-6.patch | 871 bytes | Cyberwolf |
Comments
Comment #2
robin.ingelbrecht CreditAttribution: robin.ingelbrecht commentedComment #3
robin.ingelbrecht CreditAttribution: robin.ingelbrecht commentedAttached patch removes this function as I think it is obsolete...
Comment #4
TheodorosPloumisI came to this issue because function
xmlsitemap_file_transfer
caused fatal errors when trying to download files form the file_entity module widget. It was exactly the same problem.The patch solved the issue since it remove completely the xmlsitemap_file_transfer function.
Comment #5
TheodorosPloumisComment #6
Cyberwolf CreditAttribution: Cyberwolf at 2DotsTwice bvba commentedxmlsitemap_output_file() still uses xmlsitemap_file_transfer(), so actually loading /sitemap.xml is broken when using the previous patch.
I think the maning of xmlsitemap_file_transfer() is just coincidence and it was not intended as an implementation of hook_file_transfer().
Attached is a new patch which just renames the method.
Obviously it would be better to encapsulate this code in controller and/or service classes instead of leaving them hanging around in functions in the module file, but for now this fix is sufficient.
Comment #7
Cyberwolf CreditAttribution: Cyberwolf at 2DotsTwice bvba commentedComment #8
kalpaitch CreditAttribution: kalpaitch as a volunteer and commentedComment #9
kalpaitch CreditAttribution: kalpaitch as a volunteer and commentedYes that does seem exactly right @Cyberwolf.
Patch looks good. And works equally nicely.
Comment #10
kalpaitch CreditAttribution: kalpaitch as a volunteer and commentedComment #11
renatogMakes sense.
Comment #13
renatogFixed.
Committed to the dev branch.
Thank you very much guys.
Regards.