Problem/Motivation

Steps to reproduce:

  1. Install Drupal with the Standard profile
  2. Make sure you have the Private file system set up
  3. Go to the storage settings of the Image field on the Article content type (admin/structure/types/manage/article/fields/node.article.field_image/storage), change the Upload destination to 'Private files' and upload a default image at the same time

Proposed resolution

Fix image_field_storage_config_update() and image_field_config_update().

Remaining tasks

Review.

User interface changes

Nope.

API changes

Nope.

Data model changes

Nope.

Original bug report:

When saving image for default image and in private destination it shows "Error The website has encountered an error. Please try again later." and when i check the error log it shows.

"Recoverable fatal error: Object of class Drupal\Core\Field\FieldItemList could not be converted to string in image_field_storage_config_update() (line 423 of /home/roald/sandox/drupal8-bug/core/modules/image/image.module)."

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

slashrsm’s picture

Version: 8.0.0-alpha14 » 8.0.x-dev
Issue tags: +Media Initiative
swentel’s picture

Assigned: roaldumandal » Unassigned
Status: Active » Postponed (maintainer needs more info)

Can't seem to reproduce, is this still an issue ?

jhedstrom’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

I'm guessing this was a passing issue. Feel free to re-open if it is still happening.

caspervoogt’s picture

I just encountered this in rc1, clean install with Standard profile. Steps to reproduce;

  • created a user, no special role, just Authenticated
  • uploaded a picture to this user's Picture field. Notice the thumbnail preview was broken due to 404. Checked file ownership/permission but this all seemed fine, even though the styles subdir existed but somehow the thumbnail subdir didn't get created. That may be a separate issue though.
  • At this point I still had the account Picture storage set to Public (as is the default). Then I went to admin/config/people/accounts/fields/user.user.user_picture/storage and changed it to Private. It let me change this even though it warned that this could no longer be changed since the field contained data. However, when I click "Save Settings" I do get that fatal error. When I go back to /admin/config/people/accounts/fields/user.user.user_picture/storage it does seem to have saved my changes though.
  • I then edited the user and removed the image anyway, to be on the safe side.
  • I re-edited the user, added a new picture, and now the thumbnail's showing fine. Still, any time I hit Save Settings on /admin/config/people/accounts/fields/user.user.user_picture/storage, I get that fatal error.
jhedstrom’s picture

Priority: Normal » Major
Status: Closed (cannot reproduce) » Active
caspervoogt’s picture

I am going to be dealing with this fatal error some more in coming days and hope to report back with some more details then. I hope others can reproduce this though.

jhedstrom’s picture

Status: Active » Postponed (maintainer needs more info)

I'm still unable to reproduce this, even following the steps in #4. That first issue:

uploaded a picture to this user's Picture field. Notice the thumbnail preview was broken due to 404. Checked file ownership/permission but this all seemed fine, even though the styles subdir existed but somehow the thumbnail subdir didn't get created. That may be a separate issue though.

Seems like it is probably at the root of this. I do not get broken thumbnails on user images with a clean install.

Do you see anything out of the ordinary on the status report page?

Dave Reid’s picture

Issue tags: -Media Initiative
caspervoogt’s picture

FileSize
282.88 KB

"Seems like it is probably at the root of this. I do not get broken thumbnails on user images with a clean install."
I have been playing around with it, just saving and re-saving some field / storage settings, and no longer get the fatal error. It did happen though, and shouldn't have - I just can't say for sure at this point what triggered it.

The situation now is that the default image I have set will not display - it gives a 403 Forbidden error. In fact, what seems to be happening is the default_images folder is not being created.

Example:
The thumbnail URL is:
/system/files/styles/thumbnail/private/default_images/default%20picture_2.png?itok=DP8YwAK1

But /system/files/styles/thumbnail/private/default_images does not exist although /system/files/styles/thumbnail/private does exist, while /system/files/default_images does exist and does contain the uploaded files, with correct permissions/ownership (even tried chmod 777 and ownership www-data:www-data, as a sanity check!!!).

I think perhaps I should have set the private file path and ensured correct ownership/permissions before messing at all with the User Picture settings, but permission issues still should not cause fatal errors; worst case it should result in a warning that the file can't be written. I'm unsure what exactly triggered it, at this point. I would need to run through it again from a fresh install, and properly document it.

caspervoogt’s picture

caspervoogt’s picture

FileSize
287.54 KB

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

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

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

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.

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.

alex.ksis’s picture

Status: Postponed (maintainer needs more info) » Needs review
FileSize
1.16 KB

I think, I found where is the error.
It happens because in the image_field_storage_config_update function, property $file_new->filename is used as string, however entity property returns an instance of the Drupal\Core\Field\FieldItemList class.
Please, check the attached patch.

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.

0Sarah0Al’s picture

Thanks @alex.ksis
I applied your patch and it worked.

amateescu’s picture

Status: Needs review » Needs work
+++ b/core/modules/image/image.module
@@ -404,7 +404,7 @@ function image_field_storage_config_update(FieldStorageConfigInterface $field_st
+    file_move($file_new, $directory . $file_new->get('filename')->value);

@@ -442,7 +442,7 @@ function image_field_config_update(FieldConfigInterface $field) {
+    file_move($file_new, $directory . $file_new->get('filename')->value);

You can simply use the getFilename() method of the File entity :)

alex.ksis’s picture

Status: Needs work » Needs review
FileSize
1.13 KB

@amateescu you're right, here is the new patch

amateescu’s picture

@alex.ksis, looks much better now :)

Turns out that this issue is quite easy to reproduce, I'll update the issue summary. Also wrote some tests for this.

The last submitted patch, 20: 2322421-20-test-only.patch, failed testing. View results

Berdir’s picture

Status: Needs review » Reviewed & tested by the community

Yay, tests. Looks good :)

catch’s picture

Status: Reviewed & tested by the community » Needs work

Needs a re-roll.

amateescu’s picture

The last submitted patch, 24: 2322421-24-test-only.patch, failed testing. View results

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.5.x and cherry-picked to 8.4.x. Thanks!

  • catch committed 6ea40f4 on 8.5.x
    Issue #2322421 by amateescu, alex.ksis, caspervoogt: Recoverable fatal...

  • catch committed 93fc131 on 8.4.x
    Issue #2322421 by amateescu, alex.ksis, caspervoogt: Recoverable fatal...

Status: Fixed » Closed (fixed)

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