Needs work
Project:
Automatic Entity Label
Version:
8.x-3.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
25 Apr 2018 at 13:39 UTC
Updated:
7 Jul 2026 at 03:31 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
iamweird commentedThat issue occurs because core Media returns its source name when media name is not set, causing Auto Entity Label to think that label is not empty. See \Drupal\media\Entity\Media::getName() for that logic.
Attached a patch with workaround for core media entities. Probably it would be better to get label key of the entity type, but this patch at least prevents the media form from showing validation error when creating new media with empty label.
Comment #3
iamweird commentedThere is still issue with patch #2 that the media label always gets overridden for optional setting, even if user enters label manually. These two patches address that issue. However, patching core is required, because core sets label for media, if it's empty, which was introduced in Move Media::save() logic into storage handler to prevent data integrity issues when media items with remote content are saved. When core issue Add entity methods and hooks for executing pre/post code outside of the save transaction is resolved, core patch will not be needed.
Comment #4
socialnicheguru commentedThe patch for auto_entitylabel no longer applies to Dev.
the core patch does apply to Drupal 9.3.18
Comment #5
mrinalini9 commentedRerolled patch #3 for auto_entitylabel, please review it.
Comment #6
socialnicheguru commentedDo we still need to apply both patches, and auto_entitylabel and core https://www.drupal.org/files/issues/2019-09-11/drupal-media-pre-prepares... from #3 or just the patch in #5?
Comment #7
pmunch commentedPatch #5 is a reroll of #3, you just need to apply #5.
Works fine.
Comment #8
socialnicheguru commentedNo longer applies to 3.0 version
Comment #9
kevinquillen commentedRe-rolled for 3.x. Worked for me in the following scenarios:
Comment #10
kevinquillen commentedAttaching patch.
Comment #11
kevinquillen commentedComment #12
kevinquillen commentedAnyone know what the test failures pertain to?
Comment #13
lars.stiebenz commentedThe patch is a re-roll of the one in #2965989-10: Does not work with core media against auto_entitylabel 3.3.0.
It requires the core patch from #2965989-3: Does not work with core media too: drupal-media-pre-preparesave-hook.patch
The core patch invokes a hook and the auto_entitylabel patch implements it.
Since there is still an ongoing discussion in #2992426: Add entity methods and hooks for executing pre/post code outside of the save transaction, the name of the hook might change or an event might be used instead of a hook.
Comment #14
socialnicheguru commenteddeleted comment
Comment #15
dqdSorry for a late maintainer's eye on it. Bookmarked now.
Correctly stated in the comment of lars.stiebenz 2 years ago, in core issue #2992426: Add entity methods and hooks for executing pre/post code outside of the save transaction the ongoing progress is relevant for us here to now which route to go.
Important comments there:
Is anyone involved in the latest patches here able to create an MR so that we can guide users to temporarely use this as work around until we know where to go?
We also should temporarely disable the AEL tab on media or at least the batch resave option to prevent users running accidently into empty required fields on batch resave of 100s of files. That would raise this issue to Critical.
For those who try to prefill the base "name" field (the required media label): try the source mapping of media under /admin/structure/media/manage/[type] instead. It has some options which could possibly help in some cases.