Problem/Motivation
When adding fields of type "Reference" and some other types to a content type, the message "Oops, something went wrong. Check your browser's developer console for more details." is generated, with an accompanying "Uncaught" exception in the console.
- Windows 11
- WAMP server running Apache 2.4.57.3, PHP 8.2.13, MySQL 8.0.32
- Drupal 10.2.0
- Firefox and Edge as the browser, both showing same behaviour.
Steps to reproduce
Create a new content type A. Create a taxonomy / vocabulary B. Create another content type C. Add a reference field to content type C of type Content. Attempt to pick content type A as the referring type. Error generated.
Add another reference field to content type C of type Taxonomy. Attempt to pick vocabulary B. Error generated.
The error also seems to be generated when attempting to change the display of the label from "Above" to "Inline" after having added a number of fields to content type C:
Uncaught
Object { message: '\nAn AJAX HTTP error occurred.\nHTTP Result Code: 200\nDebugging information follows.\nPath: /admin/structure/types/manage/project/display?ajax_form=1\nStatusText: OK\nResponseText: [{"command":"settings","settings":{"ajaxPageState":{"theme":"claro","theme_token":"gNBkdUwZ3Dm97PoEDNJJoWphmNujk2zamwW_Vi1zy6U","libraries":"eJx9UkFywyAM_BDGb-hLPDIojlIsUQGepK8vTow7TtJeYLW7Gi2MwM_EQxYJI2i_3TYrooE_JXuWBZU4I-ej7X6n3UxO2ACzFHY4V3caToi-91oiBPuq2K3TjDQNkSL2DRgXQKV1MixdhjFt7BRkhNClfAvEk6lTM15zgdD8v0xXHZ_pf0sL4URxz-oyLXjvPvBOQoCY8EDWaAG9wvSetXCB66ukmKJwqmMe2vrBylW9fBXUmz2Jzg-FK4JA32g8LlifsJ57bOSFVHj91YHYk4Ms2ia9Fc2JMPhhUimxf-BCpoHWugvpLJpdyU1otXlalufaYnIQ8WPdGFMS7qFWfF-W9ANoHABw"},"fieldUIRowsData":{"field-client":{"rowHandler":"field","defaultPlugin":"entity_reference_label","name":"field_client","region":"content"},"field-client-rfx-number":{"rowHandler":"field","defaultPlugin":"string","name":"field_client_rfx_number","region":"content"},"field-description":{"rowHandler":"field","defaultPlugin":"text…', name: "AjaxError", stack: "@http://rp10.local/core/misc/ajax.js?v=10.2.0:196:32\n@http://rp10.local/core/misc/ajax.js?v=10.2.0:1915:3\n" }Going back to add a new field. Attempted to add a Reference field. As soon as I clicked the radio button, error:
Uncaught
Object { message: '\nAn AJAX HTTP error occurred.\nHTTP Result Code: 200\nDebugging information follows.\nPath: /admin/structure/types/manage/project/fields/add-field?ajax_form=1\nStatusText: OK\nResponseText: [{"command":"update_build_id","old":"form-AH1mp4QXqU3cjjrjzp4nYqgnBnxM3T8IpHXWBR7t99c","new":"form-NCqER1WPUgYCoXCqXqSDvo5kCCLxd_PCo-3VPafQolc"},{"command":"insert","method":null,"selector":null,"data":"\\u003Cdiv id=\\u0022group-field-options-wrapper\\u0022 class=\\u0022group-field-options-wrapper\\u0022\\u003E\\u003Clabel data-drupal-selector=\\u0022edit-label\\u0022 for=\\u0022edit-label--zUHmO2HZw88\\u0022 class=\\u0022form-item__label js-form-required form-required\\u0022\\u003EChoose an option below\\u003C\\/label\\u003E\\u003Cdiv class=\\u0022group-field-options js-form-wrapper form-wrapper\\u0022 data-drupal-selector=\\u0022edit-fields\\u0022 id=\\u0022edit-fields--8DH0tjsuWA0\\u0022\\u003E\\u003Cdiv class=\\u0022js-click-to-select subfield-option field-suboption__item\\u0022\\u003E\\n \\u003Cinput class=\\u0022field-option-radio form-radio form-boolean form-boolean--type-radio\\u0022 data-once=\\u0022field-click-to-select\\u0022 data-drupal-selector=\\u0022field-uientity-referencenode\\u0022 aria-describedby=\\u0022field_ui:entity_reference:node--description\\u0022 type=\\u0022radio\\u0022 id=\\u0022field_ui:entity_reference:node\\u0022 name=\\u0022group_field_options_wrapper\\u0022 value=\\u0022field_ui:entity_reference:node\\u0022\\/\\u003E\\n \\u003Clabel for=\\u0022field_ui:entity_reference:node\\u0022 class=\\u0022form-item__label option\\u0022\\u003EContent\\u003C\\/label\\u003E\\n \\u003Cdiv id=\\u0022field_ui:entity_reference:node--description\\u0022\\u003E\\n \\u003Cdiv class=\\u0022item-list\\u0022\\u003E\\u003Cul\\u003E\\u003C\\/ul\\u003E\\u003C\\/div\\u003E\\n \\u003C\\/div\\u003E\\n \\u003C\\/div\\u003E\\n\\u003Cdiv class=\\u0022js-click-to-select subfield-option field-suboption__item\\u0022\\u003E\\n \\u003Cinput class=\\u0022field-option-radio form-radio form-boolean form-boolean--type-radio\\u0022 data-once=\\u0022field-click-to-select\\u0022 data-drupal-selector=\\u0022field-uientity-referencetaxonomy-term\\u0022 aria-describedby=\\u0022field_ui:entity_reference:taxonomy_term--description\\u0022 type=\\u0022radio\\u0022 id=\\u0022field_ui:entity_reference:taxonomy_term\\u0022 name=\\u0022group_field_options_wrapper\\u0022 value=\\u0022field_ui:entity_reference:taxonomy_term\\u0022\\/\\u003E\\n \\u003Clabel for=\\u0022field_ui:entity_reference:taxonomy_term\\u0022 class=\\u0022form-item__label option\\u0022\\u003ETaxonomy term\\u003C\\/label\\u003E\\n \\u003Cdiv id=\\u0022field_ui:entity_reference:taxonomy_term--description\\u0022\\u003E\\n \\u003Cdiv class=\\u0022item-list\\u0022\\u003E\\u003Cul\\u003E\\u003C\\/ul\\u003E\\u003C\\/div\\u003E\\n \\u003C\\/div\\u003E\\n \\u003C\\/div\\u003E\\n\\u003Cdiv class=\\u0022js-click-to-select subfield-option field-suboption__item\\u0022\\u003E\\n \\u003Cinput class=\\u0022field-option-radio form-radio form-boolean form-boolean--type-radio\\u0022 data-once=\\u0022field-click-to-select\\u0022 data-drupal-selector=\\u0022field-uientity-referenceuser\\u0022 aria-describedby=\\u0022field_ui:entity_reference:user--description\\u0022 type=\\u0022radio\\u0022 id=\\u0022field_ui:entity_reference:user\\u0022 name=\\u0022group_field_options_wrapper\\u0022 value=\\u0022field_ui:entity_reference:user\\u0022\\/\\u003E\\n \\u003Clabel for=\\u0022field_ui:entity_reference:user\\u0022 class=\\u0022form-item__label option\\u0022\\u003EUser\\u003C\\/label\\u003E\\n \\u003Cdiv id=\\u0022field_ui:entity_reference:user--description\\u0022\\u003E\\n \\u003Cdiv class=\\u0022item-list\\u0022\\u003E\\u003Cul\\u003E\\u003C\\/ul\\u003E\\u003C\\/div\\u003E\\n \\u003C\\/div\\u003E\\n \\u003C\\/div\\u003E\\n\\u003Cdiv class=\\u0022js-click-to-select subfield-option field-suboption__item\\u0022\\u003E\\n \\u003Cinput class=\\u0022field-option-radio form-radio form-boolean form-boolean--type-radio\\u0022 data-once=\\u0022field-click-to-select\\u0022 data-drupal-selector=\\u0022entity-reference\\u0022 aria-describedby=\\u0022entity_reference--description\\u0022 type=\\u0022radio\\u0022 id=\\u0022entity_reference\\u0022 name=\\u0022group_field_options_wrapper\\u0022 value=\\u0022entity_reference\\u0022\\/\\u003E\\n \\u003Clabel for=\\u0022entity_reference\\u0022 class=\\u0022form-item__label option\\u0022\\u003EOther\\u003C\\/label\\u003E\\n \\u003Cdiv id=\\u0022entity_reference--description\\u0022\\u003E\\n \\u003Cdiv class=\\u0022item-list\\u0022\\u003E\\u003Cul\\u003E\\u003C\\/ul\\u003E\\u003C\\/div\\u003E\\n \\u003C\\/div\\u003E\\n \\u003C\\/div\\u003E\\n\\u003C\\/div\\u003E\\n\\u003C\\/div\\u003E","settings":null}', name: "AjaxError", stack: "@http://rp10.local/core/misc/ajax.js?v=10.2.0:196:32\n@http://rp10.local/core/misc/ajax.js?v=10.2.0:1915:3\n" }
ajax.js:196:32Click submit, get error that type wasn't chosen, and now selection is enabled below. Pick "User", submit, get to the next screen, attempt to choose "Name" by which to sort, get error:
Uncaught
Object { message: "\nAn AJAX HTTP error occurred.\nHTTP Result Code: 500\nDebugging information follows.\nPath: /admin/structure/types/manage/project/add-field/node/field_project_manager?destinations%5B0%5D%5Broute_name%5D=entity.node.field_ui_fields&destinations%5B0%5D%5Broute_parameters%5D%5Bentity_type%5D=node&destinations%5B0%5D%5Broute_parameters%5D%5Bfield_name%5D=field_project_manager&destinations%5B0%5D%5Broute_parameters%5D%5Bnode_type%5D=project&destinations%5B1%5D=/admin/structure/types/manage/project/fields/add-field\nStatusText: 500 Service unavailable (with message)\nResponseText: The website encountered an unexpected error. Try again later", name: "AjaxError", stack: "@http://rp10.local/core/misc/ajax.js?v=10.2.0:196:32\n@http://rp10.local/core/misc/ajax.js?v=10.2.0:1915:3\n" }
ajax.js:196:32Flushing all caches does not help.
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #70 | middleware-bypass-check--10-6-x.patch | 864 bytes | iceous |
| #67 | middleware-bypass-check--10-5-x.patch | 864 bytes | iceous |
| #66 | content-length-http-middleware-bypass-check--10-4-x.patch | 864 bytes | iceous |
| #53 | Screenshot 2024-05-11 at 12.38.45.png | 141.04 KB | astoker88 |
Comments
Comment #2
sdsheridanComment #3
cilefen commentedThe steps to reproduce seem like ordinary actions so there must be more steps to reproduce the error condition.
Comment #4
sdsheridanI wish there were, but no, that's about it. This all worked fine in 10.1.7. The only other thing I've not indicated is the contrib modules I've got, which are:
Comment #5
lauriiiIs there more information about what happened in the PHP error logs?
Comment #6
sdsheridanNothing appears in the PHP error log, or in the watchdog log when these errors occur now. The only thing that appeared in the watchdog was around trying to add a user reference field "Project manager" to a "Project" content type, as follows:
Comment #7
sunfire-design commentedI have the same problem after 10.2.0.
After submitting every ajax form sends an error to the developver console.
I deactivated almost every non core module but the error still appears.
Comment #8
nojj commentedsame here after update to 10.2.0
Comment #9
sdsheridanIf it helps, I observed this behaviour on both an updated site from 10.1.7, and on a fresh install of 10.2.0.
Comment #10
ikphilipI've looked at your issue and I think I encountered a similar error using Layout Builder. I identified what's happening in my instance so I will comment here in case this helps. I am unsure where this error originates.
What happened in my existing site:
That's all the time I've spent on this problem. If you believe my problem is similar to yours perhaps this patch workaround for 10.2.0 will alleviate the current issue. It doesn't fix the root of the problem which is why does ResponseText JSON reach the client without the closing bracket ']'.
I will note that I didn't encounter this problem on a new Drupal 10.2.0 site using standard profile and layout builder. I didn't encounter this issue in 10.1.7. Only after my upgrade to 10.2.0 did it appear. Downgrading from 10.2.0 to 10.1.7 appeared to help.
Contextual links (/contextual/render) were also affected by this problem. That feature sends an application/json response which was missing the final "}" character. So I'm beginning to believe this isn't strictly a problem with the ajax.module.
Comment #11
ikphilipFurther investigation into this issue.
As I mentioned in comment #10 I didn't encounter this problem in 10.1.7. I was able to downgrade my site and LayoutBuilder Ajax worked properly again. The JSON content response was formed correctly in 10.1.7.
I began experimenting with sending Content-Length header, which I noticed was missing from the Ajax responses. I found that the Content-Length didn't appear on my malformed application/json responses despite trying to add it in 10.2.0 site. Then I added the content header to my 10.1.7 site before Response::send() and I discovered the response was malformed! So I determined that setting Content-Length for certain applicaton/json responses appears to cause the issue where the JSON content arrives malformed to the browser/client.
I've attached another patch for testing. It doesn't address the root cause and is a naive attempt at removing Content-Length from the AjaxResponse class, no others. You'll either want to adjust or remove the condition if you need to target other types of Responses. However I hope this is starting to illuminate the underlying Drupal issue.
Next step will be to determine if somewhere between Drupal 10.1.7 and 10.2.0 a "Content-Length" was appended to this type of response when it wasn't previously.
Comment #12
catch@ikphilip that's good investigation, and means this issue is likely a duplicate of #3396559: Only set content-length header in specific situations - could you try the MR from there?
Comment #13
czigor commentedI have a commerce add to cart form that fails like this. The MR in #3396559: Only set content-length header in specific situations does not solve the issue, I guess because the AJAX response has a 200 status for which Content-Length is still added after applying the MR.
Comment #14
ikphilipI just tested the MR in #3396559: Only set content-length header in specific situations and it did not work for me. My site's failing AJAX responses are 200 and therefore deserving of a Content-Length header.
What I noticed is that my Content-Length byte count appears to be off by 1. If I modify this line in FinishResponseSubscriber.php the responses begin to work. Something like
$response->headers->set('Content-Length', mb_strlen($content) + 1, TRUE);Because I'm unable to replicate this problem on a fresh install of 10.2.0 I'm beginning to wonder if there is something the matter with specific data from the site's content.
In 10.1.x this function does not exist which is why I can rollback to that version and my Layout Builder and quickedit.attachments Ajax work again.
So for me adding +1 to the byte length helps. This is likely why in the browser/curl/client the response appears truncated. But why is strlen() failing?
Comment #15
czigor commentedIn my case it turned out to be extra white space in front of a
<?phptag. I used the regexp\s+<\?phpto find such occurences in my codebase.@ikphilip Looks like you have a similar issue.
Comment #16
William H. Olesen commentedI'm experiencing a similar issue after upgrading to D10.2.0 where I get the Ajax-error in the browser-console.
No problems locally though where this is the setup:
But on prod (on a subdomain) I get the error when trying to:
- Add an image via Media library
- Add media in a node.
- Edit Paragraphs in a node
- Filter Views in frontend (also when logged out)
Ajax seems to be down all the way around.
The set up is like this:
I tried turning off cache and aggregation, as well as Big Pibe.
I also checked for spaces infront of <?php
Tried in Chrome,Firefox,Edge and Safari.
UPDATE: The patch in #10 made things work for me again
Comment #17
ikphilipChecking for extra spaces in the the file is a good idea, thank you @czigor. I've checked for the existence of spaces before my opening PHP tags. No luck finding a culprit file...
I think the simplest work-around until the source of the issue is identified is to disable
Content-Lengthheader via patch on a site-by-site basis with something akin to my example patch in #11. Should I find anything related I'll report it here.Comment #18
catch#3410022: Regression from #3295790 content-length header set earlier than expected could be another cause here.
Comment #19
William H. Olesen commentedI experienced another symptom of the problem when synchronizing configuration - the patch in #10 IS put on and fixes my initial problems, but not this one.
When I click import the sync progress bar appears and after a little while I get the "Oops, something went wrong etc." and the following in a message above (but the synchronization has been completed correctly though):
An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /batch?id=9&op=do_nojs&op=do
StatusText: parsererror
ResponseText: {"status":true,"percentage":"75","message":"Completed step 3 of 4.","label":""
Comment #20
catch@William H. Olesen could you try applying the diff from #3410022: Regression from #3295790 content-length header set earlier than expected ?
Comment #21
ikphilip@William H. Olesen as the author of the patch in comment #10 I don't recommend you rely on it. Notice that the patch only checks for unclosed JSON arrays "[]" not objects "{}" and as a result your ResponseText in #19 won't be fixed.
You could probably modify Patch #10 to check for unclosed JSON objects, if you wish. Since the problem is server-side with the Content-Length I don't believe a patch like #10 is appropriate. Consider #11 or a similar patch to unset Content-Length from the AjaxResponse for the time being since it wasn't set in http responses prior to version 10.2.0.
As for me, no luck with 10.2.x patch from https://www.drupal.org/project/drupal/issues/3410022. My goal is to review the impact of various contrib modules to see if there is something akin to the solution in #15 but I've nothing to report yet. Since I can't replicate this in a fresh install of Drupal I'm wondering if it's something from contrib.
Comment #22
William H. Olesen commented@catch I'm a simple site builder and on pretty deep water here, so I'm not quite sure what you mean - I'll be happy to try if you can explain.
@ikphilip Thanks for the heads up - it allowed for editors to continue throwing in content before launch of the site, so as a temporary solution it did the job - I'll try to avoid putting it on live prod ;)
Comment #23
William H. Olesen commentedI just installed Drupal 10.1.2 where "#3410022: Regression from #3295790 content-length header set earlier than expected" was said to be fixed, but the issues I have persist if I don't use Patch #10.
Comment #24
chesn0kI'm having this issue in a new installation of Drupal.
1
drush si2 Try opening Announcements
I tracked the response body while calculating the content length, the response body is valid.
If assume that the length calculated is incorrect and add +1 this will solve the issue.
Drupal\Core\StackMiddleware\ContentLength:$response->headers->set('Content-Length', strlen($content) + 1, TRUE);I have no idea where to look for the bug next )
Comment #25
larowlanI wonder if you have a space before an opening PHP tag somewhere
Comment #26
chesn0kI checked the only file I created settings.php without a space.
I also deleted the installation and reinstalled it and now I can’t get this bug again.
In any case, I now think this is not connected with drupal, but with the IDE (PHPStorm) or the environment
Comment #27
sunfire-design commentedThanks for the advice.
In my case it was a whitespace in the bat module.
Comment #28
catch@sunfire-design is there an issue against the bat module for the extra whitespace?
I wonder whether phpcs picks this up already and those modules don't have gitlab pipelines enabled, or if we're missing a rule somewhere.
Comment #29
ikphilipI've finally resolved my site's issue. I found a new line before the open PHP tag in a module...my own custom module!
\n<\?phpwas a more helpful regular expression to discover the problem in my code. Thanks for the suggestions to look around for these instances.Comment #30
cilefen commentedThat looks good.
A slight adjustment to
\n+<\?phpwill match in cases where there is more than one new line.Comment #31
sunfire-design commented@catch i created an issue report. The whitespace is only in the 2.1 branch.
Comment #32
rcodinaOn Drupal 10.2.1, patch on #10 works for me, patch #11 doesn't apply and patch #14 breaks my site.
Comment #33
sdsheridanI checked my entire project directory, and found that indeed one of my own custom modules had a space before the opening '<?php' tag. Use the following to find them:
There were a number of items that showed up under
./vendor, and then my module.I now seem to be no longer getting "something went wrong" errors, and fields are adding correctly now.
Comment #34
drupalite1411 commentedIf I take the code from #11 and manually apply it ,it fixes ajax issue but quick edit issue is still there.
I have reported this issue here. I am facing ajax as well as contextual links not appearing issue.
https://www.drupal.org/project/drupal/issues/3414753
Also how to apply this patch using composer.json?
Comment #35
ikphilipI've created 2 more patches for Drupal for users who are having issues with Content-Length headers in Drupal responses in 10.2. These patches disable setting the header so that the responses resemble those from prior versions (<10.2). I discourage the usage of my patches #10, #11, #14 as they existed to fix a specific response and to illustrate the problem I was facing.
In 10.2.0 Content-Length response header was introduced and set in FinishResponseSubscriber.php. In 10.2.1 the logic was moved to a StackMiddleware class ContentLength which is enabled in core.services.yml. You must use the appropriate patch for your current version.
I do recommend checking to see if there is extra spacing anywhere before the opening PHP tag
<?phpas that appears to be the problem for many of us. However I understand that combing a codebase can take time and it took me some time to identify the problem file so these patches can help until the problem is identified.Comment #36
couloir007 commentedI used the 10.2.1 patch on 10.2.2, and it worked. It seems impractical to worry about spaces before an opening php tag, given how many of the vendor files contain these. Also, this was only an issue on my local Lando, not on my production servers.
Comment #38
ghost.3 commentedWhat helped on my end: Remove all php closing tags from your source code (?>). This is especially important when migrating older php code to Drupal 10.2.
Comment #39
jjmackow commentedI had been experiencing this Ajax error also, while creating a view. To be clear, the error was:
"Oops, something went wrong. Check your browser's developer console for more details."
what resolved the issue for me was to shorten the machine name of the view display. It had been 40+ characters long and I reduced it to something less than 16 characters.
Comment #40
catapipperWe used the 10.2.1 patch on 10.2.3 with no issues. Very weird issue as it only happened on one of our production servers but could not be reproduced anywhere where, including local. Thank you for this patch, it got us back up and running after 4 days of searching for an answer.
Comment #41
drupalite1411 commentedI have used #35 10.2.1 patch and it worked.
Updating comment .
On doing some more testing on the site, it fixes the issue but when I click on the configure or add section on layout builder second time ,it again gives error
An error occurred during the execution of the Ajax response: TypeError: Cannot read properties of null (reading 'style')
Steps to replicate:
1)Go to layout
2)Click on configure link on any section
3) It will open the window
4)Close the window,again click on configure link
5)Blank window will open and error in console.
Tried patch given in #16 https://www.drupal.org/project/drupal/issues/3414753 but did not work.
Comment #42
alfthecat commentedI applied the 10.2.0 patch on a 10.2.3 install and no luck.
I have this problem on all my sites, everywhere now. Mostly layout builder (can't add sections, can't add certain blocks) but also elsewhere (can't set default images for fields).
Comment #43
kylebehse commentedSOLVED: Drupal, "Oops, something went wrong. Check your browser's developer console for more details."
Yep, same here (line-break on line 1 of custom module).
To fix:
Go to a plain text editor, create new file, hit enter (to create a line-break), select all, copy.
Go to code editor, search entire site for:
Paste the line-break in, then type "<?"
It should find any line-breaks in line 1 of code. Note: I use the copy and paste technique because hitting enter in the search bar of the code editor means that you want it to search, not insert a new line.
This was hard to see, as VSCode had a helper icon blocking line #1.
Comment #44
erwangel commentedThe Ajax issue is still present on 10.2.4. In a custom module I have a very simple form, I simplified the ajax response to jus say "Hello", I switched to the default Olivero theme to be sure there is no interference with any other jquery or ajax call. This form was working with no problem on 10.1.2.
What I noticed in the console display of he error is that whatever the context of my form is used (and so producing variable ajax responses), it always has a
"settings"; nul'in the response text. This quote after nul sounds suspect to me.Extra line-breaks are mine to make it evident that there is a malformed json array, probably due tho the
nul'.I tried patch 10.2.1 from #35, it worked on the first call of the form (a click on submit button), but it didn't work on the next calls although there was no error displayed on the console.
Comment #45
klemendev commentedI would be happy to help further if I understood the details of this, but this issue is probably preventing many websites from updating to 10.2
Comment #46
marc.groth commentedSimilar to #42, I am also unable to add a default image. In fact I can't save any image field (new or re-used). The following error is logged:
I'm not able to add a dynamic 'Content' reference field:
Drupal\Core\Entity\EntityStorageException: 'field_storage_config' entity with ID 'node.field_content_reference' already exists. in Drupal\Core\Entity\EntityStorageBase->doPreSave() (line 519 of core/lib/Drupal/Core/Entity/EntityStorageBase.php).And also not able to add a regular 'Content' reference field:
InvalidArgumentException: Field field_new_content_reference is unknown. in Drupal\Core\Entity\ContentEntityBase->getTranslatedField() (line 616 of core/lib/Drupal/Core/Entity/ContentEntityBase.php). Drupal\Core\Entity\ContentEntityBase->get() (Line: 116)All of these issues are only in 10.2.x (including the 10.2.4). 10.1.8 and earlier work fine.
I did notice that the UI for this functionality has changed in the 10.2 branch; so assume this is related.
Comment #47
catch#46 looks unrelated to the original issues reported here (which are about whitespace in PHP files) - it looks more likely to be a contrib module altering a form that needs an update to 10.2 or similar. First check that your modules are all up-to-date.
@marc.groth are you using DER? https://www.drupal.org/project/dynamic_entity_reference
Comment #48
orizonmedia commentedhi all,
I'm on Drupal 10.2.4 with PHP8.2.17 I tried #35 10.2 and 10.1 (tried both) and got error cannot apply patch.
Am I missing something in my composer? Thanks in advance!
Comment #49
marc.groth commentedThanks @catch. That is a really good point! We have a number of outdated contrib modules. In the past we have been able to update Drupal core first; but it makes sense to get the contrib modules updated first.
And to answer your question, yes we are using the DER module.
Thanks for your suggestions and sorry for the temporary noise in this ticket :)
Everyone please disregard #46
Comment #50
tenten71 commented#15 worked for me. Thank you. Spent all day reading and researching this.
I had just updated our TEST server to 10.2.5 and was having AJAX errors caused while trying to run manual updates, add media, add images, remove images, edit fields in Views... Didn't have these issues on our DEV server which was running the same version. However we did copy our LIVE server over to our TEST server, so at first I thought it was something else.
Thank you for the regexp so I didn't have to look that up myself.
The culprit was in the web/sites/default/settings.php file. A lonely blank line above the opening <?php tag. The version on our DEV and LIVE servers did not have this line so I'm still trying to figure out who/how this appeared.
Comment #51
maxdmayhew commentedHaving this issue as well after upgrading to 10.2.2 from 10.1.6. Checked for spacing on <?php, no dice.
Patch #35 unfortunately did not work.
Comment #52
santhoshabraham commentedI am having same issue after updating Drupal. When I submit webform I get following error.
Oops, something went wrong. Check your browser's developer console for more details.
Comment #53
astoker88 commentedIf anyone else encounters this issue, i had updated the Cloudflare WAF rules to the latest version.
'/cdn-cgi/challenge-platform' was in the response for all ajax requests. Disabling the items in screenshot fixed the issue.
Comment #54
fcertal commentedThanks guys!
A break line before <?php in a custom module was causing an ajax parse error, breaking the batch update process.
Comment #55
gigimaorI am experiencing the same issue as ticket #54.
I followed up on #15 and found the issue pretty quickly.
Comment #56
joshua.boltz commentedI am running into this same issue. I believe this issue cropped up with a Drupal 10.2 upgrade, because I'm pretty sure it used to work on 10.1.
Basically, I can reproduce the issue by adding an entity reference field to any content type, and when I change options on the field (that do some Ajax operations) like changing the type of content to reference or changing limited/unlimited options, I get the Ajax error.
UPDATE: This is not only an issue with entity reference fields, it also happens with others like Link field or any other fields that have the "Limited/Unlimited" option. When changing that option, the issue happens.
It almost seems like some bug with the multi-step setup form of creating a new field where you first pick the field type, then you pick which option you want to use from available options on that field type. It seems like the timing of the processes may be off, where when its doing the Ajax events on the field, the field is not yet created and for some reason it's expecting it.
Comment #57
jprj commentedAlso happens when trying to 'add another item' to a Selection list field (in my case 'List (text)') and when trying to change the allowed number of values.
A bit more exploration: I realised only one of my sites has this problem, so this implies a contrib or custom module causing the problem. Built a clean site a module at a time and sure enough one of my custom modules is causing the problem. At this point of exploration I don't yet know what is happening. Will report back if I find anything interesting.
Comment #58
bob.hinrichs commentedIf you come across this, check your theme debug settings and make sure the feature is turned off.
Comment #59
linhnm commentedThanks guys!
#15 save my life.
Comment #60
cleverson.oliveira commented#10 worked for me!
Comment #61
nicolasgraphIn my case it was also a line break before
<?phpin a custom module which broke Ajax in many places.Comment #62
gukki commentedRan into this parse error, would happen on firefox and safari, but didnt occur with chrome
#10 also worked for me when working locally with DDEV, but it still wouldnt work on the stage site
In my case I noticed the response headers on the stage were missing the content-encoding: gzip
Tweaked our nginx.conf with some additional gzip settings and it finally worked
Comment #63
ziobudda commentedToday I upgraded from v9.5 to v10.3.6 and I also had the broken ajax issue. Solution #10 fixed the issue.
Comment #64
jasonsafro commentedThis may be related to https://www.drupal.org/project/drupal/issues/3494148. In the original issue, I can see where the last few characters of the AJAX response got cut off. If you are still experiencing this issue, please try the patch.
Comment #65
hanan alasari@czigor can you please let me know how used the regexp \s+<\?php to find such occurences in my codebase? i have the same issue and wanna be sure...
Comment #66
iceous commentedIf anyone needs it, I've created the updated patch #35 for 10.4.x
Comment #67
iceous commented#35 updated patch for 10.5.x
Comment #68
gurgolo commented#10 and #67 worked, thank you.
Comment #70
iceous commented