Needs review
Project:
Entity Embed
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
26 Aug 2019 at 14:31 UTC
Updated:
3 Feb 2025 at 03:59 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
scotthooker commented+1
Comment #3
bkosborneThis is the quick fix to prevent the logging if the value of the attribute is an empty string.
Comment #4
alisonOh man this was driving me bananas, thank you @bkosborne!
Love the added comma ;-)
Should the "empty" check come first.....? Or is it no difference either way?
Comment #5
alisonPatch applies cleanly *and* quells the flood of messages for me. (! screams in relief on the inside !)
Comment #6
peterwcm commentedTested and working. Thanks for the patch.
Comment #7
dragos-dumi commentedHi,
Attaching a patch to filter empty $context values before merge default values.
Comment #8
dragos-dumi commentedComment #9
dragos-dumi commentedComment #10
dww@dragos-dumi: Would you be willing to?:
A) Explain why you think you need the change you're proposing. At first glance, it's causing lots of existing tests to fail, which smells like a regression.
B) Provide interdiffs with your patches.
C) Use a follow-up issue to work on your change. #3 is RTBC for fixing a very common bug affecting a bunch of sites. While you/we sort out what you're trying to accomplish, at least folks could get relief from the bug described/fixed here. Just looking at patch #9 it seems basically unrelated to what's happening here.
D) Write a test that shows the bug you're trying to fix.
I'm re-uploading exactly patch #3 (so the testbot doesn't get confused) and restoring the RTBC status.
I've been using this patch in production and it's a huge win for silencing bogus warnings in the log. Patch looks clean. We could complain there's no test coverage showing the bug we're fixing. ;) But I'm not sure we need to hold up progress for that. I'll leave that for the maintainers to decide...
Thanks,
-Derek
p.s. Another note to committers: d.o is now confused about issue credits and patch authorship here. Please list @bkosborne as the author of this fix and give them first listing in the commit message. IMHO, I'd remove credit/authorship from @dragos-dumi for this issue, and give them credit in the forth-coming follow-up issue if/when that's fixed.
Comment #11
alisonJust, FWIW -- #10 works great, thank you all!
Comment #12
richardbporter commentedPatch in #10 worked for me as well.
Comment #13
acbramley commented#10 fixes the issue, retriggered tests as the failures looked unrelated.
Comment #14
jacobbell84 commentedPatch #10 fixed this for me as well. We've been running this in production for a while.
Comment #15
pobster commentedSee https://www.drupal.org/project/entity_embed/issues/3069448#comment-13315334
Comment #16
grimreaperHello,
Patch #10 fixed the issue for me too. Thanks!
Comment #17
pobster commentedNote this patch isn't fixing anything, it's merely working around displaying the warning in the logs. The underlying issue is solved via a combination of; https://www.drupal.org/project/entity_embed/issues/3069448#comment-13315334
...and editing your content to remove any instances of where the filter has previously entered;
This is the actual issue - as the empty string is obviously then not an array.
Comment #18
kim.pepperComment #19
nicolas s. commentedHello,
Patch #10 works for me.
Thanks
Comment #20
phenaproximaIs there any chance we could get automated test coverage for this? Even a simple kernel or unit test would be sufficient, IMHO.
Comment #21
pobster commentedAgain, this is only fixing the symptoms of the problem - it isn't fixing the problem.
Comment #22
dutchyodaComment #10 does prevent flooding the logs, so it is useful to a certain extend.
However why not adding the extra argument to the original if-statement,
that would clean up the patch file as well since you only change one line.
Comment #23
eelkeblok@pobster We should definitely also solve the actual problem. However, even if that would prevent the issue for future additions, if you already have a site filled with entries with this problem, you're up a certain creek without a paddle. I don't think trying to convert existing entries containing the problem in an update hook is in any way practical, nor is asking a client to go through all content to resave content. Is there an alternative where we don't hide the problem but also do not flood the logs?
Comment #24
tobiasbUse the patch from #3069448: Array to string conversion for Media Image to remove empty data-entity-embed-display-settings attribute for new/ updated content and this patch for existing content.
Comment #25
anikdas1995 commentedHii I upgraded php 7.4 to php 8.0 for testing on my dev environment. When i was testing the pages while using dblog module , I caught this error:
so I was trying to find workaround to solve this issue. I found this patch and added it. Patch #10
After adding the patch , I tested on my local environment then dev environment. It is working for me perfectly. No issues found as expected
Thank You!!
Comment #26
emptyvoid commentedConfirm error appears on php 8.1
Applying the patch in #25 suppresses the stuffing of the log with warnings.
Comment #27
neclimdulre #21 and #17 I mean, those are fixes but we can't just grep a database for every time something wrote a bad value in the past. Empty stream isn't an array but its clearly empty so we handle the value gracefully and only report _real_ errors. In that respect this fixes a bug and as you mention there are others.
Re #22 because
$context['data-entity-embed-display-settings'] = [];is still only in the outer diff so they can't be combined.Lot of happy people and we've been using this for a long time agree the code itself is RTBC but leaving it NR because of the testing.
Comment #28
pobster commentedWhat are error messages for, if not to tell you that something has been entered incorrectly? This is a genuine error - what's been entered is wrong. You're just saying, "I want to see error messages, just not this one" - it's not ideal for sure but it's also not that difficult to loop through content, indeed I only did it last week in an update hook.
Obviously, this is untested as the original code was for something else, but this is not a difficult task.
Comment #29
luigimannoni commentedI hate to be that guy, but updating nodes is not an option.
We have a 6 different sites with the main one topping at 4k nodes, grepping and stripping stuff from the entire prod databases gets me fired instantly and frowned upon from other devs.
Batching through all nodes and re-saving everything messes up the content view/last work for authors, we've done once previously and swore we never ever do it again not even under death threat.
What is the proper solution then because as it stands now, every time an entity is embedded using the button it comes through with data-entity-embed-display-settings as empty string.
So, this is not even user mistake from what I can see on our end, even more, why user-generated content is not gracefully managed? Feels like everyone has an easy way to trigger server errors by just edit the attribute.
Thanks for #10, much appreciated.
Comment #30
pobster commentedI've already stated the proper solution and my views on it - but if hiding the error works for you, that's also fine? Go for it, it doesn't have to be a perfect solution - but still, it's a workaround rather than a fix. Hence this patch shouldn't be merged.
Comment #31
luigimannoni commentedOk, let me rephrase the issue here:
I have an entity embed button on my CKEditor, everytime the content managers press the embed entity button the tag gets generated with an empty attribute as default.
My authors are absolutely non-HTML savvy therefore the text format I am offering to my authors doesn't have any way to access the field text as source. They are great at writing text but not editing attributes on tags.
So, let's assume I grep all node but this won't solve future content being written. Grepping all content is not the solution here.
Comment #32
pobster commentedAh! Now we get to the root of the problem! This is what I mentioned in a previous comment - the fix is here: https://www.drupal.org/project/entity_embed/issues/3077225#comment-14016784 / https://www.drupal.org/project/entity_embed/issues/3069448
Yes, this module has written bad config into your content - I can't see why you don't think that removing bad/ invalid config from your content is not the solution. If you can't node save in an update hook, then don't - just do it with a straight database query. Or ... as I said before, apply the patch to hide the warning - I just don't believe that a patch which hides a legitimate error should be merged into the project. But it isn't my project so who cares!!!
Comment #33
neclimdulYeah, maybe its possible to automate updating nodes but it doesn't actually fully address the problem because you'd actually be looking at updating any field-able entity. This means users, paragraphs, webforms, ECK entities, custom site specific entities, etc. Those updates also have side effects so its not without risk.
Technically even if you figured that out and fixed ever field-able entity you still wouldn't have solved the problem though because you can use filters outside of Fields API. For example I've got a site that has a full text field stored as a pair of values in KV because its a site setting but not something that can be stored in config for deployment reasons.
So I agree that when possible this module should fix the value. I just strongly disagree "fix all the field in an update" is the correct solution. Filters need to be as resilient as possible and the intent of the empty config is clear and can be handled without causing site side effects.
I'll go a step farther and say even if fixing all the previous bad values in an update was going to be implemented, this issue stands as its own fix that should be implemented because as I said, filters should be as resilient as possible.
Comment #34
pobster commentedSame! This is why I didn't bother putting that code in a patch file. I stuck it in here so people could decide whether or not they want to use it - in no way should it be forced on people to run in the module code. About your other point, obviously, it can cycle through all available entities too - it was just a base point to show how it's possible to "surface" all text-based fields for processing.
As I said before if this patch suits you - use it. Just, I don't feel like it's a solution that should be merged into the module, because it is hiding a legitimate error which yes, this module introduced - but nonetheless, it's still a legitimate error.
Comment #35
ammar qala commentedI faced the same issue and fixed it, instead of applying patch #10 I decided to know what is the root cause.
In my case I found out another related error which helped me out
and followed the below comment
https://www.drupal.org/project/entity_embed/issues/2982322#comment-12866696
Comment #36
acbramley commentedComing back to this issue after a long time, it seems like #3069448: Array to string conversion for Media Image is the correct fix. With that patch I can re-edit an embedded media entity and it correctly removes the empty string settings variable.