As super user on a fresh Drupal installation go to:
/admin/structure/types/manage/article/fields/node.article.field_tags
Chose / type a new (non-existing) tag for the default value and press "Save".
Expected behaviour:
- a new tag with the given value is set as the default tag of the content type "Article"
Actual behavior:
- The following error message appears: Fatal error: Call to a member function uuid() on a non-object in /var/www/drupal-8/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Field/FieldType/TaxonomyTermReferenceFieldItemList.php on line 74
- the default tag is not saved
Note: originally, the expected behavior wanted to save the default tag as well, but this is not a regression from Drupal 7 and is more a feature request.
(Found during the Drupal South 2014 Code Sprint in Wellington)
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 2195973-6.patch | 1 KB | swentel |
Comments
Comment #1
stefan lehmannComment #2
barrapontoIssue only happens when a new (non-existing) tag is chosen for the default value. Existing tags will work just fine.
Comment #3
stefan lehmannYep .. that's why I said fresh Drupal installation. There shouldn't be any tags yet.
Comment #4
barrapontoexplicit is better than implicit ;)
Comment #5
larowlanNeedsTests
Comment #6
swentel commentedThere's a larger problem at hand here. There's an error also on that page all the time:
Note: in Drupal 7, the default value widget does not save a tag. I would leave that as is, so that is not a regression. Saving it would be a (and also debatable) feature request.
However, it shouldn't blow up of course ;)
Attached patch fixes the error, but I'm not sure whether it's the right solution. We should probably look up further in the chain.
Comment #7
swentel commentedSetting to needs review just for sure, but we surely need tests.
Comment #8
swentel commentedComment #9
swentel commentedComment #10
amateescu commented@swentel, that's being fixed in #2193237: Warning because of empty value at array_flip() :)
Comment #11
swentel commented@amateescu - did you click on save ? Because apparently in the other one it crashes still heavily ? :)
Comment #12
amateescu commentedWell, the fix there is just for the warning on the settings page..
Comment #13
revagomes commentedI came across this issue when I was working on #2193237: Warning because of empty value at array_flip().
I was thinking about the solution we have right now and I'm not sure about some points.
Taking in count that the system has to save the non existing term in order to store the default value I think the best thing to do would be warn the user about the creation of the default term with a description message on the field.
Earlier I was thinking to approach this with a checkbox to allow the user to decide if he/she wants to create the default value if it doesn't already exists. The thing is that now it's the default behavior of Drupal so maybe the best solution is to be verbose and let the user to know how the system works.
As @barraponto said:
I'm not sure if the creation of the default term outside the "admin/structure/taxonomy/manage/[vocabulary]/add" page makes sense for everyone but if that's the way the system works the end user has to be aware. OMHO
Comment #14
swentel commented@amateescu: Ugh, right. Mine also still crashes if you fill in a non existing tag.
@revagomes: we need to keep the 'save a new one' as a feature request, it's not a regression.
Comment #15
swentel commentedSo this needs work too
Comment #16
stefan lehmannTried to make issue description more explicit, as suggested by barraponto.
Comment #17
stefan lehmannChanged
"- a existing tag with the given value is set as the default tag of the content type "Article""
to
"- a new tag with the given value is set as the default tag of the content type "Article"
That's still the expected behavior or am I wrong? Otherwise the whole issue has a wrong description or there should be an issue with a refactoring guide, I suppose.
Comment #18
swentel commentedNo, that's a feature request, it's not a regression compared to D7. We should fix the bug here first.
Comment #19
rodrigo panchiniak fernandes commentedI think the issue should be solved with an error message when the user tries to add a new tag as default tag. This would be the simplest way out. No term would be unexpectedly created, no feature request would be needed.
Comment #20
jhedstromThis is a duplicate of #1140188: Fatal errors during or after adding default values for autocomplete widgets.