While trying to create a new CSV feed type, whenever changing the fetcher to 'csv', we receive the following ajax error:
AjaxError:
An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /admin/structure/feeds/add?ajax_form=1
StatusText: OK
ResponseText:
( ! ) Notice: Undefined index: allowed_extensions in /var/www/html/web/modules/contrib/feeds/src/Feeds/Fetcher/Form/UploadFetcherForm.php on line 72
Call Stack
#TimeMemoryFunctionLocation
10.0026398768{main}( ).../index.php:0
20.0108587296Drupal\Core\DrupalKernel->handle( ).../index.php:19
30.03721875288Stack\StackedHttpKernel->handle( ).../DrupalKernel.php:693
40.03721875288Drupal\Core\StackMiddleware\NegotiationMiddleware->handle( ).../StackedHttpKernel.php:23
50.03721875984Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle( ).../NegotiationMiddleware.php:52
60.03721875984Drupal\page_cache\StackMiddleware\PageCache->handle( ).../ReverseProxyMiddleware.php:47
70.03721875984Drupal\page_cache\StackMiddleware\PageCache->pass( ).../PageCache.php:78
80.03731875984Drupal\Core\StackMiddleware\KernelPreHandle->h… ajax.js:98:32
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | Screenshare - 2022-11-03 12_23_18 PM.mp4 | 3.61 MB | carolpettirossi |
| #8 | 3031019-8.patch | 479 bytes | hmendes |
| #2 | 3031019-undefined-index-ajax-2.patch | 923 bytes | pfrilling |
Issue fork feeds-3031019
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 #2
pfrillingThe attached should fix this issue.
Comment #3
megachrizI cannot reproduce this error. Can you describe what you do exactly? For example, did you select 'Upload file' first? Is your website slow? In my case changing fetcher, parser or processor happens in the blink of an eye.
Comment #4
pfrilling1. Using Firefox (and Opera).
2. We browse to: /admin/structure/feeds/add
3. We change 'fetcher' from 'download from url' to 'upload file' and the ajax error happens immediately.
The site is running locally using DDEV v1.5.2, Docker Desktop 2.0.0.2 on a Mac using OS 10.14.2. The performance of the site is normal, definitely not slow.
--
We do not receive the ajax error when we:
1. Browse to: /admin/structure/feeds/add
2. We change Fetcher from 'download from url' to 'Directory'
3. Then, we change 'Directory' to 'Upload file'.
Let me know if you need any additional information.
Comment #5
pfrillingSorry, I forgot to change the status back to active.
Comment #6
megachrizI just saw that the error reported in this issue was logged. I only don't receive the AJAX error on screen for some reason.
The question then is: why is Feeds performing form validations when changing fetcher, parser or processor? I think the form validation implementation should be confident that fields defined in
buildForm()should be available. So I think the patch in #2 only fixes a symptom of the issue.Comment #7
ivnishSame problem as #4.
Comment #8
hmendes commentedI was trying to understand this issue and about why is Feeds performing form validations when changing fetcher, parser or processor? : theses fields have an ajax callback, and AKAIK, when I have an ajax callback, it will call the validate function method ( i even saw a bunch of issues in core asking to implement an option to prevent this behavior )
So the flow is smt like:
Change the field (fetcher, parser or processor) -> validateForm() -> form() -> ajaxCallback()
And the field is only updated on the form(), after the validateForm is executed, so when the validate calls the validateConfigurationForm from UploadFetcherForm.php, the values are not updated.
Sending a patch to review. I only added the $form_state->IsSubmitted() to the validateForm skip the function if it is called from a place other than submit.
Comment #10
carolpettirossi commentedI faced the error below when trying to created a "Upload from File" feed type (watch recorded screencast attached):
The patch suggested in #8 could not be applied on
8.x-3.0-beta2I'm creating a Merge Request with the same code from #8.
Hopefully, it can be pushed to a new release soon ;)
Comment #13
carolpettirossi commentedMR !93 is the correct one. Sorry for creating MR 92 by mistake.
Comment #14
jsutta commented#12 worked for me in Drupal 9.5.2 with Feeds 8.x-3.0-beta3. Thank you @carolpettirossi!
Comment #15
chriswinger#12 worked for me too in Drupal 9.5.10 and Feeds 8.x-3.0-beta4. It resolved the error when creating a feed using an "Upload from File" feed type.
Comment #16
chriswingerComment #17
caspervoogt commented#12 worked a treat for me.
Comment #22
megachrizI've added test coverage for this issue. I had been working on these tests a while ago, but they were somehow failing. It looks like there's another error when trying to use the upload fetcher when the file module is not installed. But that's something for an other issue.
I closed MR 93 because I had trouble pushing code to it, because its branch name was the same as the branch in the Feeds repository. So I pushed the changes to a new branch called 3031019-fix.
The tests in branch 3031019-tests_only should fail.
Comment #23
caspervoogt commentedI had just queued two tests on #12 right before you posted here, Chris. I see they passed.
Comment #25
megachrizIt looks like there is no easy way to catch logged errors during a FunctionalJavascript test. So I went ahead and just merged this. Thanks all!
Comment #27
imclean commentedI'm still seeing this error with Feeds 3.2. The workaround in #4 avoids the issue.
This also resolves another issue: