Closed (fixed)
Project:
Drupal core
Version:
10.1.x-dev
Component:
taxonomy.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
26 Apr 2022 at 19:48 UTC
Updated:
28 Nov 2023 at 20:39 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
berdirComment #3
andregp commentedHere is a patch :)
Comment #4
hmendes commentedTested the patch here and it worked for me, and the code follows the "Proposed resolution".
Steps:
Changing this to RTBC.
Comment #7
berdirLooks like a random fail.
Comment #9
ravi.shankar commentedRetested patch #3 on Drupal 9.5.x. It's green so back to RTBC as per comment #4 and #7.
Comment #10
alexpottGiven we obviously have no test coverage of this I feel it is worth adding some.
We should be able to use \Drupal\Tests\taxonomy\Functional\TaxonomyImageTest as the basis for a test - we could make it a FunctionalJavascript test and go from there.
Comment #11
joachim commentedThat test got removed in #3305410: remove TaxonomyImageTest -- someone working on this will need to retrieve the test class from git history (removal commit is 0cf5ca1 on 10.1.x).
Comment #14
plopescNew patch including tests.
Instead of replicating the scenario in a new FunctionJavascript test, it makes the form validation less restrictive to make the bug visible.
Comment #16
smustgrave commentedConfirmed the issue described and the patch #14 solves it.
And the failing test shows the issue is being solved.
Comment #18
Ajeet Tiwari commentedPlease review.
Comment #19
smustgrave commentedRemoving credit for #18
As there was no interdiff
No explanation of change
And reroll removed most of the changes.
Failure in #14 seems random. Retesting but going to mark too.
Comment #20
lauriiiI don't think allowing to save an invalid term is best way to test this because it's certainly not a behavior we want to have to support.
Comment #21
berdirI'm unsure, I agree it's somewhat uncommon, but that's already a fairly common scenario that we do "support", the way it works is that you then generate a node title/term name based on some other fields, for example with https://www.drupal.org/project/auto_entitylabel. Typically you hide the field then though (and can do that with nodes through the UI) but that's a minor difference. The same would indeed also happen there.
Comment #22
lauriiiIf the module wanted to ensure that the entity is only saved if it's valid, it should generate the title before saving it. Looks like it's currently done in
hook_entity_insert()which means it's done after it has been saved. 🤷♂️Comment #23
lauriiiHere's a test that uses the steps from the issue summary.
Comment #25
berdirloading the term by name to display it's name is a bit unecessary. imho it's sufficient to just check the success message based on $edit directly, we don't need to check that the term really exists?
Comment #26
lauriiiAddressed #25 👍
Comment #27
lauriiiNow that I'm looking at this again, it looks like
\Drupal\taxonomy\TermInterface::getNameis supposed to always returnstringbut\Drupal\Core\Entity\EntityInterface::labelmight returnstring|\Drupal\Core\StringTranslation\TranslatableMarkup|null. I think the right fix would be for\Drupal\taxonomy\Entity\Term::getNameto return empty string when\Drupal\Core\Entity\ContentEntityBase::labelreturnsnull.Comment #28
smustgrave commentedMakes sense to me and can see the test-only patch fail in 23.
Ran locally too
Exception : Deprecated function: trim(): Passing null to parameter #1 ($string) of type string is deprecated
Drupal\taxonomy\TermForm->buildEntity()() (Line: 152)
Comment #29
quietone commentedThe issue summary is clear and there is a proposed resolution. I read the comments and all questions have been answered. However, I notice that the last comment has changed the solution making the proposed resolution incorrect. And the title isn't quite right any more.
I looked at the patch and noticed a doc block missing, the use statements were not sorted, $module should have an @inheritdoc. I have made a patch for those.
I have updated the proposed resolution and tried for an better title.
Comment #31
bhanu951 commentedGot hit by this issue on 9.5.x . But patch from #29 did not fix it.
Seems Patch from #29 has random failure, rerunning the tests.
Comment #32
smustgrave commentedSeems changes in #29 are good/all green
@Bhanu951 can you post the error/steps you're taking to get this issue?
Comment #34
quietone commentedRetesting.
Comment #36
lauriiiMoved #29 into MR. Looks like the CI is passing so moving back to RTBC.
Comment #37
xjm@lauriii Please remember to hide patch files from the IS when opening an MR. Thanks!
Comment #38
xjmI queued the test-only job. Results:
That is not the failure I expected.
Comment #39
xjmhttps://www.drupal.org/pift-ci-job/2723504 documents the expected test-only result, so the issue with the test-only job is not blocking. I reached out to the DA and committer team about it.
Comment #41
xjmI fixed a few nitpicks. Apparently the weird failure from the test-only job might be due to the MR not being rebased, so also fixed that. (Adding credit for @fjgarlin for identifying that issue.)
Meanwhile, saving issue credits.
Comment #42
xjmThe rebase did yield the correct test-only result:
Comment #46
xjmI could not think of any way that no longer returning an invalid
NULLfrom this would be particularly disruptive, so I committed this to 11.x, 10.2.x, and 10.1.x. Thanks!Comment #47
xjm