Problem/Motivation

I have an entity type with a file_url field. I create a new entity of said type and I fill the file_url field with a remote url. I save the entity, edit it and save it again creating a new revision. A critical error is thrown:

Drupal\Core\Entity\EntityStorageException: SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: 'http://www.example.com' for column 'fid' at row 1: INSERT INTO {file_usage}

This happens because the \Drupal\file_url\Plugin\Field\FieldType\FileUrlFieldItemList class adds file usages on entity updates when a new revision is created, but it doesn't check if the file is a remote one.

Proposed resolution

Add a check to see if the file is remote, like in the other portions of the class.

Remaining tasks

Tests.

User interface changes

None.

API changes

None.

Data model changes

None.

CommentFileSizeAuthor
#3 2899697-3.patch864 bytessardara

Comments

sardara created an issue. See original summary.

sardara’s picture

Priority: Normal » Critical
sardara’s picture

Assigned: sardara » Unassigned
Status: Active » Needs review
StatusFileSize
new864 bytes
claudiu.cristea’s picture

Status: Needs review » Reviewed & tested by the community

Good!

claudiu.cristea’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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