Problem/Motivation

1. Upload image or file to image/file field
2. Install file_entity
3. Edit the image and save
Unexpected result:

PluginNotFoundException: The "entity:file:undefined" plugin does not exist. in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition()

This happens through validation.

Proposed resolution

Determine the bundle at some point before validation.

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Arla created an issue. See original summary.

Berdir’s picture

This should only happen while the initial convert queue is running. So not a huge problem I think. We don't want to make the special undefined bundle available I think, maybe just check and convert when editing?

Arla’s picture

Ah, didn't know about the convert queue. I see now that there's a dsm in hook_install about that. I guess there is nothing to do here then :)

maybe just check and convert when editing?

I do see a point in keeping that queue the only way to convert the entities. But yes, this could help.

thenchev’s picture

Added the check to the file_entity_file_load() not sure if there is a more appropriate place. Also some tests.

The last submitted patch, 4: pluginnotfoundexception-2712863-4-test-only.patch, failed testing.

The last submitted patch, 4: pluginnotfoundexception-2712863-4-test-only.patch, failed testing.

slashrsm’s picture

Status: Needs review » Needs work

Let's solve this on the form class (possibly in prepareEntity()).

thenchev’s picture

Moved the check to the form classes. I have one problem with testing the inline-edit modal. I need to simulate an ajax request and tried drupalPost and drupalPostAjaxForm but probubbly missing the correct values. Will look more into this...

Status: Needs review » Needs work

The last submitted patch, 8: pluginnotfoundexception-2712863-8.patch, failed testing.

The last submitted patch, 8: pluginnotfoundexception-2712863-8.patch, failed testing.

thenchev’s picture

Did some cleanup and removed the test for the inline form since we inherit the fix from the fileEditForm testing one should be enough to cover both.

slashrsm’s picture

Assigned: thenchev » Unassigned
Status: Needs review » Fixed
Issue tags: +D8Media

Committed. Reworded this comment along the way:

diff --git a/src/Tests/FileEntityFileTypeClassificationTest.php b/src/Tests/FileEntityFileTypeClassificationTest.php
index 05fc27a..080c181 100644
--- a/src/Tests/FileEntityFileTypeClassificationTest.php
+++ b/src/Tests/FileEntityFileTypeClassificationTest.php
@@ -68,8 +68,8 @@ class FileEntityFileTypeClassificationTest extends WebTestBase {
     $file_type = $this->getFileType($image_file);
     $this->assertEqual($file_type['type'], 'undefined', t('The image file has an undefined file type.'));
 
-    // When editing files before cron is run the bundle should have correct
-    // value.
+    // When editing files before cron has run the bundle should have been
+    // updated.
     $account = $this->drupalCreateUser(['bypass file access']);
     $this->drupalLogin($account);
     $this->assertNotEqual($image_file->bundle(), 'image', 'The image file does not have correct bundle before loading it.');

Status: Fixed » Closed (fixed)

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