Warning: array_flip(): Can only flip STRING and INTEGER values! in Drupal\Core\Entity\FieldableDatabaseStorageController->loadMultiple() (line 149 of core/lib/Drupal/Core/Entity/FieldableDatabaseStorageController.php).
at
admin/structure/types/manage/article/fields
After a fresh D8 install, go at
admin/structure/types/manage/article/fields/node.article.field_tags
edit the label and save it.
I've found it using PHP 5.3.10, but it was also reported happening with PHP 5.5.9.
| Comment | File | Size | Author |
|---|---|---|---|
| #29 | after-applying-the-test.png | 3.87 KB | janoka |
| #29 | before-the-patching.png | 9.38 KB | janoka |
| #23 | interdiff-22-23.txt | 768 bytes | czigor |
| #23 | core-taxonomy_autocomplete_warning-2193237-23.patch | 1.57 KB | czigor |
| #22 | interdiff-21-22.txt | 561 bytes | czigor |
Comments
Comment #1
rodrigo panchiniak fernandes commentedThis patch solves the issue avoiding arrays with an empty value. Not sure if it was correctly generated. This is my first patch submission. :)
Comment #2
revagomes commentedThis If must be lowercase.
Comment #4
revagomes commentedHelping Panchiniak with his first patch ;)
Rerolling against HEAD.
Comment #5
rodrigo panchiniak fernandes commented#1 was generated over the wrong file. #4 is ready for review. Thank you @revagomes.
Comment #6
stefan lehmannComment #7
amateescu commentedI cannot reproduce this bug on a fresh standard D8 install. Can you please provide more steps to reproduce?
Comment #8
rodrigo panchiniak fernandes commentedComment #9
stefan lehmannI verify, that the notice appeared and that the Patch fixes this.
I found however, that a FATAL error appears, if you enter a default value and press Save, but this seems to be unrelated to this issue, as it also happens without applying the patch above.
Created a bug report for the issue mentioned above here: https://drupal.org/node/2195973
(Done during the Drupal South 2014 Code Sprint in Wellington)
Comment #10
rodrigo panchiniak fernandes commentedThank you for the comment and additional error report. I've found the crash with default term only happens when it is chosen a value that is not yet a term of the vocabulary (tags). I personally don't like the behaviour of creating a new content from auto complete fields. Mostly because, in this scenario, setting a field should not correspond to adding a content (considering taxonomy term as a content). So, the option of adding a Default term should be restricted only for non empty vocabularies, and, in my opinion, the auto complete should force on already available options. But, as you said, this is not related to the current issue. Other option would be dealing with default values only (or mostly) at the front end, with no previous filling of the taxonomy itself, until a real content is added.
Comment #11
barrapontoI followed the traceback to
TaxonomyAutocompleteWidgetand fixed it there.But I wonder if
$itemsshouldn't just be empty (and skip the whole foreach loop).Comment #12
amateescu commentedI think a better fix would be to check if $items is not empty before trying to compute the default value for the form element, just like Entity reference does.
Comment #13
amateescu commentedComment #14
barrapontoTested, it works fine.
Comment #15
revagomes commentedI've tested the #12 also and it's OK.
I was thinking about the solution we have right now and I'm not sure about this anymore.
Taking in count that the system has to have a tid in order to store the default value the best thing to do would be warn the user about the creation of the default term.
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 but now I realized that maybe the best solution is to be verbose and let the user to know how the system works. I'm not sure if the creation of the default term outside of the "admin/structure/taxonomy/manage/[vocabulary]/add" page makes sense for everyone but thats the way the system works. So the end user has to be aware.
What do you guys think about this?
Comment #16
revagomes commentedI've tested again trying to set 2 tags as the default value for the articles and I've got another error:
After that I clicked Back in the browser and I had the same error about the array_flip() plus a notice:
I'm moving the status back to Needs work.
Comment #17
barraponto@revagomes there's another issue for that: #2195973: Setting default value on Article->Tags field leads to FATAL error..
This issue is RTBC already.
Comment #18
catchLooks like we could add test coverage for this. Patch itself looks fine though.
Comment #19
barraponto@catch can't the test come from #2195973: Setting default value on Article->Tags field leads to FATAL error.? This is just a trivial fix, the other issue is the heavy thing.
Comment #20
rodrigo panchiniak fernandes commentedThank you for the review, @catch. Nevertheless the comment of @barraponto, considering this is a PHP bug fix, it should be accompanied by a test according to Core Gates. I will try to follow this guide for providing it.
Comment #21
czigor commentedAdded a test case to check if no PHP error is present on the field instance settings page for autocomplete widget.
Comment #22
czigor commentedAdding a missing newline.
Comment #23
czigor commentedThis patch contains only the test (and not the fix) so it should fail.
Comment #25
czigor commented22: core-taxonomy_autocomplete_warning-2193237-22.patch queued for re-testing.
Comment #27
czigor commented22: core-taxonomy_autocomplete_warning-2193237-22.patch queued for re-testing.
Comment #28
czigor commentedComment #29
janoka commentedI checked the page before applying the patch and after it.
Please see the screenshots.
Before:

After:

Comment #30
shkodrava commentedPatch #22 worked for me.
Comment #31
shkodrava commentedComment #32
alexpottCommitted a6658cd and pushed to 8.x. Thanks!
Comment #37
berdir