Problem/Motivation
Upon hitting the Remove button for any Reference field of type File while in Quick Edit mode, the operation will fail with a 500:
AjaxError:
An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /quickedit/form/node/1/field_file/en/full?element_parents=field_file/widget/0&_wrapper_format=drupal_ajax&ajax_form=1
StatusText: 500 Service unavailable (with message)
ResponseText: The website encountered an unexpected error. Please try again later.Steps to reproduce:
- At /admin/structure/types/manage/article/fields/add-field create a new Reference field of type File ( You might want to configure it to support more extensions than only TXT files)
- At /node/add/article create a new article and make sure to upload a supported file
- Upon viewing the node, hover on the far right area of body field, then click on the pencil
- Select Quick Edit
- Now, hover on the attached file and click anywhere within the rectangle with the blue borders
- Click Remove

Proposed resolution
TBD
Remaining tasks
TBD
User interface changes
TBD
API changes
TBD
Data model changes
TBD
Original report
Uncaught PHP Exception LogicException: "The database connection is not serializable. This probably means you are serializing an object that has an indirect reference to the database connection. Adjust your code so that is not necessary. Alternatively, look at DependencySerializationTrait as a temporary solution." at /var/www/stuxnet/core/lib/Drupal/Core/Database/Connection.php line 1433
Steps to reproduce
- Create a content type with image field.
- Create new node of that type with image.
- Attempt to quickedit the image field of your new node.
- When the quick edit popup shows, click on "Delete" button to remove existing image.
- Nothing happens but an AJAX error occurs:
Server returns 500 error codeand PHP logsLogicException.
This issue was previously reported in #2475483: Cannot quickedit an image or date field and is reported as fixed however it's still present in 8.0.1. (at least for image fields).
| Comment | File | Size | Author |
|---|---|---|---|
| #53 | test-only-2635712-53.patch | 3.12 KB | bendeguz.csirmaz |
| #53 | 2635712-53.patch | 6.14 KB | bendeguz.csirmaz |
| #44 | 2635712-44.patch | 6.14 KB | bendeguz.csirmaz |
| #33 | 2635712-33.patch | 3.24 KB | sylvainm |
| #32 | 2635712-quickedit-file-removal-fix.patch | 2.55 KB | redgluten |
Comments
Comment #2
tim.plunkettComment #3
siliconmind commentedTim, it's not about deleting a field. It's about deleting contents of the field.
Comment #4
wim leersCan you provide more detailed exception information? Preferably a stack trace. Thanks!
Comment #5
swentel commentedError in console.log
Db error:
I've been stepping through it a couple of times already, not yet found where it happens :/
Will check for stack trace.
Comment #6
wim leersThis then sounds like an AJAX request triggered by a form, and the form is trying to save something to the DB that contains services that end up being serialized (presumably in the submit handler).
Also, note that #2475483: Cannot quickedit an image or date field indeed already fixed a bug that is nearly identical to this, and it added test coverage. But only for adding an image, not for deleting an image.
When we find the root cause, we should expand the test coverage in
QuickEditLoadingTest::testImageField().Comment #7
snehi commentedSame in my case.
I added a custom image field in article content type. I created a node of type article.
Through quickedit i am unable to delete the image when i click on remove nothing happens.
Comment #8
pmusaraj commentedI get the same issue, but not only when quick editing, I also get it when trying to delete an image or file from a field in regular editing form.
It's hard to tell under what circumstances this happens, though... it happens on some files but not others (on the same field).
Comment #9
wim leersComment #10
alexborsody commentedWhy not remove the feature if it doesn't work I also get the error, only, I can edit text without issue. It is custom image field displayed in a view. error is
Comment #11
wim leers#10: Because it's very hard to reproduce and not actually caused by Quick Edit, see #8.
Comment #12
chuongle commentedI want to confirm that this happens only when I use Quickedit for image field. I am able to delete the image in the backend. Is there any direction/instruction I can follow?
Comment #13
snehi commentedWhat is the mean of quick edit, if are not able to delete the image from the frontend.
I think it is correct bug for new patch.
Comment #14
swentel commentedThe problem is the validator. Thing is, it's not even used either, so why bother injecting it. Removing it fixes this.
Comment #15
flocondetoilePatch #14 fix issues using quick edit on paragraphs fields (with images field inside).
Comment #16
dbyers55 commentedTriaging Issue with @catapipper.
Comment #17
dbyers55 commentedissue reproduced with @catapipper. Able to reproduce bug in 8.2.x using same steps. Patch #14 solves ajax error but does not trigger the ability to save the change. If you re-upload an image the save submit button is available.
Comment #18
xjmThanks @catapipper and @dbyers55 for triaging the issue. Updating issue credit to include @dbyers55. @catapipper, if you are following, can you comment as well so we can ensure you are credited for the triage contribution?
Comment #19
xjmComment #20
DeFr commentedAdded the necessary JS bits in the patch attached to make quick edit image removal works.
What's going on here is that quick edit doesn't perceive the click on the Remove button as something that changes the form, and thus doesn't expose its Save button. Attached patch manually triggers the formUpdated event to make sure that everything's notified of the change.
Comment #21
sylvainm commentedPatch of #20 tried and it is working fine on Drupal 8.1.1, thx @DeFr
Comment #23
wim leers#2828528: Add Quick Edit Functional JS test coverage will make it much easier to write test coverage for this.
Comment #24
stuart_wagner commentedthis issue seems to persist (in core 8.2.4) -- this is such a great feature, i find it hard to believe that there aren't more posts about it... am i missing something
Comment #25
stuart_wagner commented#20 does not resolve the issue for 8.2.4
Comment #28
catchThanks for triaging this and confirming it's still a bug.
Discussed with @alexpott, @cilefen, @cottser, @laurii, and @xjm and we agreed on the major priority due to the user-facing error. There's a workaround for the actual image deletion to use the full node edit form.
Comment #29
jansete commentedThis happens with file field too. When add a new file (multiple instance field) and with file deletion.
Comment #31
redgluten commentedAs reported here this issue seems to affect all file fields not only images, wether or not they are single or multiple instance field. Is it possible to change the name of this issue to reflect that?
Comment #32
redgluten commentedAttached is an updated patch for 8.3.x and 8.4.x with the workaround of removing the typed data validator to prevent the issue. Certainly not a good long term solution but maybe it can be of some help to anyone with their projects or the maintainers to fix the issue.
Comment #33
sylvainm commentedI think the patch should look like the attached one for 8.4
Comment #35
redgluten commentedBump. Could a maintainer point to indications as which steps to follow to get one of these patches included in a 8.4.x or 8.5.x release? I’m willing to work on this but not sure what to do exactly.
Comment #36
wim leers#2828528: Add Quick Edit Functional JS test coverage landed! Now tests are totally feasible to write. Let's get this done!
Comment #37
anavarreIs this issue actually different from #2952906: Hitting the 'Remove' button to delete a file with Quick Edit fails with a 500?
Comment #38
wim leersI suspect it's indeed probably the same. Let's make this the canonical issue. Would you like to move over any relevant information from that other issue to this issue and marking it ?
Comment #39
anavarreSure, done.
Comment #40
wim leers🙏
Comment #42
bendeguz.csirmaz commentedAdded test.
Comment #44
bendeguz.csirmaz commentedJavaScript fix.
Comment #46
bendeguz.csirmaz commentedComment #47
bendeguz.csirmaz commentedAdded dependency on "file/drupal.file" to "quickedit/quickedit" library.
This enables entity browsers to work with Quick Edit (tested on Lightning media browser).
Comment #49
bendeguz.csirmaz commentedInstall file module in test.
Comment #50
bendeguz.csirmaz commentedComment #51
bendeguz.csirmaz commentedWe talked about this with @huzooka, and adding file.js is not the responsibility of Quick Edit, so I'll hide patch 47 and 49.
I'll also hide patch 42 because it failed testing.
Comment #52
wim leersThis means
quickeditnow depends onfileimplicitly. Hence the fail in #47.What we need to do instead is modify this asset library conditionally: if the
filemodule is installed,add this dependency.EDIT: actually, is this even truly necessary? AFAICT the core bug is fixed even without this.
YAY FOR TEST COVERAGE! 👍
But can you please upload a test-only patch too? That one should fail. If you upload 2 patches at the same time, the first one test-only, the second one test+fix, then it's perfectly clear whether there's adequate test coverage or not :)
Comment #53
bendeguz.csirmaz commentedI think it's not necessary, it was a bad idea. I think patch #44 is enough.
Here's patch #44 and the test only for comparison.
Comment #54
bendeguz.csirmaz commentedComment #55
wim leersPerfect! 👍
Comment #56
alexpottCommitted and pushed b3576bbe73 to 8.7.x and c1eaf1e75a to 8.6.x. Thanks!
Whilst there is a constructor change it is in a form class so not API and this is a long standing bug so it deserves to be fixed in 8.6.x. Great to see javascript tests for JS bugs.
Comment #59
wim leers