Problem/Motivation
When I try to arrange text formats and editors settings I get the following error.
Symfony\Component\Validator\Exception\LogicException: The LangcodeRequiredIfTranslatableValues constraint can only operate on the root object being validated. in Drupal\Core\Config\Plugin\Validation\Constraint\LangcodeRequiredIfTranslatableValuesConstraintValidator->validate() (line 26 of var/www/html/mysite/web/core/lib/Drupal/Core/Config/Plugin/Validation/Constraint/LangcodeRequiredIfTranslatableValuesConstraintValidator.php).
This was caused by #3427564: Require `langcode: …` only for simple config that contains translatable values.
Steps to reproduce
On Drupal 10.3, edit and then save a text format that uses CKEditor.
Proposed resolution
Convert the LogicException to a E_USER_DEPRECATED error. This is a quick fix for sites broken by Drupal 10.3. Another fix for 11.x can be done in a follow-up.
Remaining tasks
Implement.
User interface changes
None.
API changes
None.
Data model changes
None.
Release notes snippet
Text formats could not be saved due to config translation validation new in Drupal 10.3. The LogicException has been replaced with a E_USER_DEPRECATED error.
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | drupal-LangcodeRequiredIfTranslatableValues-3449851-13.patch | 1.57 KB | liam morland |
Issue fork drupal-3449851
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #1
Anonymous (not verified) commentedjaydenpearly created an issue. See original summary.
Comment #2
kopeboyI can confirm I'm having this error twice now (on two different sites), and it doesn't allow me to change any text format configuration that has CKEditor5 anymore.
Drupal 10.2.6 doesn't have this. This doesn't come out of the box but after playing around with CKEditor toolbar or removing a text format.
error trace
Comment #3
pingwin_cracow commentedConfirmed, I have the same problem after updating to Drupal 10.3.0-beta1
Exactly the same errors mentioned above.
Comment #4
cilefen commentedComment #5
pingwin_cracow commentedI updated to Drupal 10.3.0 and the problem still persists which is very irritating.
Is there a chance for a quick solution so that I can edit the text format settings?
Comment #6
cilefen commentedYes. Performing a
git bisecton a checkout of Drupal Core between a good and bad release tag will quickly find the issue that introduced the regression.Comment #8
cilefen commentedComment #9
liam morlandLangcodeRequiredIfTranslatableValuesis new in 10.3, added in #3427564: Require `langcode: …` only for simple config that contains translatable values.Comment #11
liam morlandThis merge request changes the
LogicExceptionto aE_USER_DEPRECATEDerror. This allows text formats to be saved. This may be a good short-term fix.Comment #12
liam morlandComment #13
liam morlandThis patch represents the current state of the merge request.
Comment #14
rei commentedin my case I was getting the same error message after adding ckeditor5_template button on the toolbar.
After applied the patch in #13, the editor doesn't show up/blank at node edit page.
this error did't occur with drupal 10.2.7
Comment #15
pingwin_cracow commentedDrupal 10.3.0
php 8.4
admin theme: Gin
fix #13 worked fine after clearing cache, Ckeditor 5 bar is correct for all options (Full, Office, etc.)
I hope the patch will be included in the next Drupal 10.3 patch
Thank you very much for help.
Comment #16
vincent.hoehnI can confirm that the patch in #13 fixes the issue. I hope it will be included in core soon!
Comment #17
smustgrave commentedChange should be turned to an MR.
Issue summary is incomplete so that should be updated using the standard template.
Have not reviewed patch
Comment #18
liam morlandThe change already is a MR; see #10. #13 is there to allow patching from Composer.
This was intentionally targeting Drupal 10.3 because this is a quick solution to fix broken sites and people will probably want some other fix in 11.x.
Issue summary updated.
Comment #19
smustgrave commentedit's missed the 10.3 boat unfortunately
Comment #20
liam morlandI was anticipating this would deploy with 10.3.1 to fix sites broken by 10.3.0.
Comment #21
smustgrave commentedLooking at the steps
this doesn't cause any issue, would imagine a test failure would of happened if so. So there needs to be determined what the issue is and have coverage for that.
But this missed 10.3 and can't be removed in 11 as that's out now too. So if anything it would be 10.4 and removed in 12 if it gets added.
MR should be made for 11.x (main branch)
Comment #22
liam morlandDid you look at the patch? I expect that if this patch were proposed to be merged into Drupal 11 or 12, that would be refused on the basis that the
LogicExceptionis correct and that the bug is buried elsewhere in the code. That is probably true. What we need now is a fix for the sites that were broken by the 10.3.0 upgrade.The issue only appears when saving a text format that uses CKEditor. It is possible that there is some other condition also required to trigger the problem. Several people are having this problem and the fix works for them.
Comment #23
smustgrave commentedOkay I'm going to leave this issue, I don't believe its going to be merged but will leave in review for others
Comment #24
liam morlandDo you have another suggestion for how to fix this?
If this cannot be quickly fixed, there should be a warning message to caution people against upgrading to Drupal 10.3.
Comment #25
smustgrave commentedI mean the exception is very vague, I imagine the scenario is that some config got in after #3427564: Require `langcode: …` only for simple config that contains translatable values so would be more useful to say what config is causing the issue. Then you could go and fix the file.
But that's an untested theory
Comment #26
liam morlandI didn't mean to switch the status.
Comment #27
smustgrave commentedOpened this yesterday too as I saw it with configuration inspector.
Comment #28
liam morlandWe are not using
config_inspectorand yet we see this error. So, my hunch is that the other issue should be closed as a duplicate of this. Perhaps the error message should point out what config is wrong, as you suggest in the other issue.Comment #29
shani mauryaI can confirm that the patch in #13 fixes the issue for drupal core 10.3
Comment #30
solideogloria commentedPatch #13 works in Drupal 10.3. (I don't use config_inspector either.)
Comment #31
dadderley commentedSame problem with 10.3.0
Cannot modify existing text format
Comment #32
solideogloria commented@dadderley If you still have a problem in 10.3, then your text format is using an invalid CKEditor plugin, or maybe something else is wrong in the text format's configuration. I had the same problem, too, prior to discovering that.
You need to discover why an error is being thrown. Even if the Exception is not thrown after applying the patch, there is still an error being triggered, and it will again throw an Exception in Drupal 11.
Comment #33
quietone commentedThe title becomes the commit message and an error message is not very useful when going through the logs. Can someone change this to what is being fixed?
Comment #34
solideogloria commentedHow's this?
Comment #35
solideogloria commentedComment #36
dadderley commented@solideogloria
I have a few sites that have been updated to D 10.3.0
This is happening in sites that use this plugin
Obfuscate Email
https://www.drupal.org/project/obfuscate_email
This is a new issue with the plugin that is related to the D 10.3.0 upgrade
https://www.drupal.org/project/obfuscate_email/issues/3457393
I cannot uninstall the plugin because a text format requires it.
I cannot disable the plugin because it throws this error when trying to save the text format.
Interestingly enough on one of the updated sites where I have the Obfuscate Email plugin installed, I don't get the error message, just a WSOD when I try to save the text format.
Is this helpful information?
Edit
There has been a new release of the Obfuscate Email module which seems to have cleared up the issue that I mentioned.
Comment #37
solideogloria commentedIf you still have the issue, try setting a breakpoint in the code where the error is thrown from. You might have another plugin throwing errors.
You could also try disabling all non-core modules and see if that fixes it, and try to figure out if it's related to a certain module.
Comment #38
dadderley commented@solideogloria
I found the offending Ckeditor plugin.
Thanks again.
See this issue
Symfony\Component\Validator\Exception\LogicException: The LangcodeRequiredIfTranslatableValues constraint can only operate on the root object being validated.
https://www.drupal.org/project/ckeditor_indentblock/issues/3457094
Comment #39
alexpottThis error indicates that
type: config_objecthas been added in an incorrect place in the schema. I agree that the friendly thing to do here is to emit a deprecation in 10.x and leave a break in 11.x as this is not a great thing. The config that has config_object placed at the wrong level will be invalid according to its schema.Comment #40
alexpottI've added some comments to address to the MR.
Comment #41
alexpottComment #42
catchNot sure what's best to do about the change record here, should we add a new CR alongside the ones that were already added for #3427629: `langcode: …` is now required for config objects that contain translatable values?
I think deprecation in 10.3 to exception in 11.x is OK given the config schema was invalid in these modules already.
Comment #43
catchMade an attempt at a CR https://www.drupal.org/node/3459863
Comment #45
alexpottI've fixed the 10.3.x MR and I've provided an 11.x that improves the exception message so it is less cryptic. The deprecation message for 10.x is also explicit now too.
Comment #48
smustgrave commentedHad to run the tests locally since can't run the test-only feature here
Love the updated text, super helpful
Comment #53
catchCommitted/pushed to 11.x, 11.0.x, 10.4.x and 10.3.x respectively, thanks!
Comment #56
xjmComment #57
xjmI seem to have invented a patch release in my head.