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:

  1. 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)
  2. At /node/add/article create a new article and make sure to upload a supported file
  3. Upon viewing the node, hover on the far right area of body field, then click on the pencil
  4. Select Quick Edit
  5. Now, hover on the attached file and click anywhere within the rectangle with the blue borders
  6. 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

  1. Create a content type with image field.
  2. Create new node of that type with image.
  3. Attempt to quickedit the image field of your new node.
  4. When the quick edit popup shows, click on "Delete" button to remove existing image.
  5. Nothing happens but an AJAX error occurs: Server returns 500 error code and PHP logs LogicException.

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).

Comments

SiliconMind created an issue. See original summary.

tim.plunkett’s picture

Title: Cannot quickedit an image field » Cannot use quickedit to delete an image field
siliconmind’s picture

Title: Cannot use quickedit to delete an image field » Cannot use quickedit to delete an image

Tim, it's not about deleting a field. It's about deleting contents of the field.

wim leers’s picture

Status: Active » Postponed (maintainer needs more info)

Can you provide more detailed exception information? Preferably a stack trace. Thanks!

swentel’s picture

Error in console.log

POST: http://drupal8/quickedit/form/node/1/field_image/en/full?element_parents=field_image/widget&_wrapper_format=drupal_ajax&ajax_form=1&_wrapper_format=drupal_ajax

Uncaught AjaxError: 
An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /quickedit/form/node/1/field_image/en/full?element_parents=field_image/widget&_wrapper_format=drupal_ajax&ajax_form=1
StatusText: Internal Server Error
ResponseText: {}

Db error:

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. in Drupal\Core\Database\Connection->__sleep() (line 1433 of /home/drupal/drupal-core/core/lib/Drupal/Core/Database/Connection.php).

I've been stepping through it a couple of times already, not yet found where it happens :/
Will check for stack trace.

wim leers’s picture

Issue tags: +Needs tests

This 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().

snehi’s picture

Same 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.

pmusaraj’s picture

I 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).

wim leers’s picture

Title: Cannot use quickedit to delete an image » Cannot use Quick Edit to delete an image
Status: Postponed (maintainer needs more info) » Active
alexborsody’s picture

Why 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



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 /srv/bindings/806bfe9376874bacabadd75195a7312a/code/core/lib/Drupal/Core/Database/Connection.php line 1433
wim leers’s picture

#10: Because it's very hard to reproduce and not actually caused by Quick Edit, see #8.

chuongle’s picture

Version: 8.0.1 » 8.0.5
Issue tags: -Needs tests

I 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?

snehi’s picture

What 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.

swentel’s picture

Status: Active » Needs review
StatusFileSize
new2.18 KB

The problem is the validator. Thing is, it's not even used either, so why bother injecting it. Removing it fixes this.

flocondetoile’s picture

Patch #14 fix issues using quick edit on paragraphs fields (with images field inside).

dbyers55’s picture

Issue tags: +neworleans2016

Triaging Issue with @catapipper.

dbyers55’s picture

Status: Needs review » Needs work
Issue tags: +Triaged for D8 major current state

issue 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.

xjm’s picture

Thanks @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?

xjm’s picture

Version: 8.0.5 » 8.1.x-dev
DeFr’s picture

Status: Needs work » Needs review
StatusFileSize
new3.23 KB
new1.05 KB

Added 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.

sylvainm’s picture

Patch of #20 tried and it is working fine on Drupal 8.1.1, thx @DeFr

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

wim leers’s picture

Title: Cannot use Quick Edit to delete an image » [PP-1] Cannot use Quick Edit to delete an image
Status: Needs review » Postponed
Issue tags: +Needs tests

#2828528: Add Quick Edit Functional JS test coverage will make it much easier to write test coverage for this.

stuart_wagner’s picture

this 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

stuart_wagner’s picture

#20 does not resolve the issue for 8.2.4

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

catch credited catapipper.

catch’s picture

Issue tags: +Triaged core major

Thanks 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.

jansete’s picture

This happens with file field too. When add a new file (multiple instance field) and with file deletion.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

redgluten’s picture

As 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?

redgluten’s picture

StatusFileSize
new2.55 KB

Attached 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.

sylvainm’s picture

StatusFileSize
new3.24 KB

I think the patch should look like the attached one for 8.4

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

redgluten’s picture

Bump. 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.

wim leers’s picture

Title: [PP-1] Cannot use Quick Edit to delete an image » Cannot use Quick Edit to delete an image
Status: Postponed » Needs work
Related issues: +#2828528: Add Quick Edit Functional JS test coverage

#2828528: Add Quick Edit Functional JS test coverage landed! Now tests are totally feasible to write. Let's get this done!

anavarre’s picture

wim leers’s picture

I 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 Closed (duplicate)?

anavarre’s picture

Issue summary: View changes

Sure, done.

wim leers’s picture

🙏

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

bendeguz.csirmaz’s picture

Status: Needs work » Needs review
StatusFileSize
new6.44 KB

Added test.

Status: Needs review » Needs work

The last submitted patch, 42: 2635712-42.patch, failed testing. View results

bendeguz.csirmaz’s picture

Status: Needs work » Needs review
StatusFileSize
new6.14 KB

JavaScript fix.

Status: Needs review » Needs work

The last submitted patch, 44: 2635712-44.patch, failed testing. View results

bendeguz.csirmaz’s picture

Status: Needs work » Needs review
bendeguz.csirmaz’s picture

StatusFileSize
new6.56 KB

Added dependency on "file/drupal.file" to "quickedit/quickedit" library.
This enables entity browsers to work with Quick Edit (tested on Lightning media browser).

Status: Needs review » Needs work

The last submitted patch, 47: 2635712-47.patch, failed testing. View results

bendeguz.csirmaz’s picture

StatusFileSize
new7.19 KB

Install file module in test.

bendeguz.csirmaz’s picture

Status: Needs work » Needs review
bendeguz.csirmaz’s picture

We 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.

wim leers’s picture

Status: Needs review » Needs work
Issue tags: -Needs tests
  1. +++ b/core/modules/quickedit/quickedit.libraries.yml
    @@ -40,6 +40,7 @@ quickedit:
    +    - file/drupal.file
    

    This means quickedit now depends on file implicitly. Hence the fail in #47.

    What we need to do instead is modify this asset library conditionally: if the file module is installed,add this dependency.

    EDIT: actually, is this even truly necessary? AFAICT the core bug is fixed even without this.

  2. +++ b/core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditFileTest.php
    @@ -0,0 +1,100 @@
    +class QuickEditFileTest extends QuickEditJavascriptTestBase {
    

    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 :)

bendeguz.csirmaz’s picture

StatusFileSize
new6.14 KB
new3.12 KB

I 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.

bendeguz.csirmaz’s picture

Status: Needs work » Needs review
wim leers’s picture

Status: Needs review » Reviewed & tested by the community

Perfect! 👍

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 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.

  • alexpott committed b3576bb on 8.7.x
    Issue #2635712 by bendeguz.csirmaz, DeFr, redgluten, swentel, SylvainM,...

  • alexpott committed c1eaf1e on 8.6.x
    Issue #2635712 by bendeguz.csirmaz, DeFr, redgluten, swentel, SylvainM,...
wim leers’s picture

Issue tags: +JavaScript

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.