Still on Drupal 7? Security support for Drupal 7 ended on 5 January 2025. Please visit our Drupal 7 End of Life resources page to review all of your options.Marking this as a support request as I may be missing something.
The skip_hash_check boolean is set on the Processor. From what I can tell a feed that hasn't been modified throws an exception in the fetcher and dies before reaching the processor or parser.
My settings:
Fetcher: Download
Parser: custom loosely based on the xml parser
Processor: Node
Content Type: custom
Processor settings:
Update existing contents: Update existing contents
Advanced - Force update: checked
I dropped some debug statements into the fetcher and that is definitely throwing the exception. Then I threw some debugs into my parser and it was never reached.
The Feed URL of this particular item is the first time I have been using a static xml instead of one generated from a DB. I'm looking to test some image parsing and wanted full control over the feed source.
I got around the issue for now by adding the skip_hash_check boolean as a setting on the fetcher, and skipping the changed test if the skip hash check has been checked off. If that is how this should work then I can work up a patch that moves the boolean from the processor to the fetcher, but I wanted to see if I was missing something before moving forward with that.
| Comment | File | Size | Author |
|---|---|---|---|
| #20 | interdiff-2850888-11-19.txt | 5.52 KB | megachriz |
| #20 | feeds-always-download-2850888-19.patch | 6.06 KB | megachriz |
Comments
Comment #2
wolffereast commentedI also had to modify the fetcher's get cache key function to avoid the cached response from failing. Could this be an issue with my file system not correctly holding on to the cached file?
Comment #3
megachrizWhen a source feed has not been modified (and it returns a 304 HTTP status code), Feeds will throw an EmptyFeedException and the import will be aborted. The HTTP Fetcher has no knowledge of any settings on the processor, so the "Force update" setting will have no effect in this case.
I think that the "Force update" setting should be respected by the HTTP Fetcher. Maybe the setting needs to be moved to the general settings?
Comment #4
megachrizComment #5
joelpittetHow about something like this on the fetcher?
Comment #7
joelpittetThat's a bit of an annoying test, is it needed?
Comment #8
megachriz@joelpittet
This is a good idea, though I think it would be better to not use the cache at all when this option is enabled. We could then call the option "cache_http_result" as it is called in the D7 version:
Also needs two tests:
I looked if perhaps some tests from the D7 could be ported, but caching downloaded content in the D7 version works slightly different there. In the D8 version, only the headers are cached. In the D7 version also the complete file contents. Anyway, similar tests would be:
Comment #9
megachrizThis probably a slightly better option for the annoying HTTP Fetcher unit test:
$this->assertInternalType('array', $form);Comment #10
nchristensen commented#7 worked for me.
Was running into issue where my product's stock field data wouldn't update if the CSV I was importing hadn't been changed/data hadn't been updated, even when I had the "Force update" checkbox selected.
My workflow:
-> Initial stock of product set at 100
-> user then purchases 10 items of the product
-> remaining stock shows 90
-> cron runs, and feeds attempts to pull csv to update products (where product's stock is listed at 100)
-> feeds fails because stock data is the same as initial stock (100) so remaining stock remains at 90. (so even if client gets another shipment in to keep the stock at 100, feeds doesn't care)
After applying patch and leaving the "Force update" box checked, Feeds is now updating my product stock as hoped.
Comment #11
caesius commentedRerolling.
Comment #12
caesius commentedComment #13
joshua.boltz commentedThis patch is working great on Drupal 8.7.11 using Feeds and Feeds Extensible Parsers to import from 3rd party JSON API.
Previously, I had to append a query string parameter to the end of the API URL, such as https://jsonplaceholder.typicode.com/posts?abc, but now, with the "Always Download" setting added with this patch, that removes the need to do that each and every time I wanted to run the import, even if the previous import was unsuccessful and Drupal actually didn't have any feed items from the API yet, but due to caching of the headers, it was still requiring to use a query string so Feeds could try a re-import.
Comment #14
megachrizAdding this as a nice to have before beta phase.
Comment #15
ollie222 commentedThe patch in #11 applied cleanly to the latest dev feeds and so far things look and it's solved a problem for me.
I'd like to see this feature make it to the release version too.
Comment #16
megachriz@Ollie222
Do you want to write an automated test for this feature? This is needed to ensure that the feature keeps working in future versions. See also #8.
Comment #17
ollie222 commented@MegaChriz
While I've been using Drupal and creating custom modules and functions for many years now writing tests is not something that I've had huge exposure to although I'm aware it's becoming more and more important.
My understanding from the examples I've seen previously and the Drupal PHPUnit testing page is that there is quite a steep learning curve to get up to speed with writing tests. Is this thinking correct?
I don't have a great deal of free time at the moment and I don't think enough to learn something like this.
Comment #18
megachriz@Ollie222
I think you are mostly correct with that, yes. Writing tests can take some time to master. I remember mocking things in PHPUnit took me some time to understand. I think browser tests are the easiest to start with as these are the closest to what you would do as an user in the browser. Kernel tests are useful for testing API's with database backend and unit tests for testing a specific class.
For this issue, I think we need a kernel test: it needs to be tested how imports behave with this option turned on and I don't think we need to test any user interaction.
Comment #19
bbox1 commentedFor those looking for an easy drop-in solution, please see my solution below. Our use case was such that we wanted a new entity created on every Feeds fetch, even if the remote data had not changed.
I defined a new FeedsFetcher plugin, that extends the HttpFetcher plugin, and placed it in my module's directory under: my_module/src/Feeds/Fetcher/HttpUnconditionalFetcher.php
The code:
Hope it's helpful to someone somewhere.
Comment #20
megachrizIn addition of the patch in #11, this skips saving data to the cache when the option "Always download" is enabled.
Also adds tests, ported from the D7 version:
Comment #22
megachrizCommitted #20. Thanks to everyone who posted or reviewed patches!