line 1185 reads:
$options[''] = $blank;
This results in the first actual term in the options dropdown to be overwritten with $blank.
Assigning $blank to element 0 explicilty fixes it:
$options[0] = $blank;
You could also use:
$options[] = $blank;
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | taxonomy.1.patch | 596 bytes | harry slaughter |
| #2 | Image1.png | 12.4 KB | harry slaughter |
Comments
Comment #1
harry slaughterI'm marking this critical as it does break taxonomy, although not in a severe way.
This problem may only manifest in view filters.
To see the problem, set up a site using 5.6, generate a *single select* taxonomy category. create a view that has an exposed taxonomy filter for this category.
Note in the exposed filter that the top term in this category is replaced with '- None -'.
Comment #2
harry slaughterIf this image uploads, notice the first term in the taxonomy filter is "Two" where it should be "One".
Comment #3
btully commentedsubscribe
Comment #4
zeta ζ commentedCould you mark this ? I know it’s only one line, but wouldn’t all those eager reviewers find a patch useful?
Comment #5
harry slaughterGood suggestion. Here's a patch against 5.7
Comment #6
zeta ζ commentedI’m guessing this is by design, as the row added here is not a term, so should be treated differently. It is not over-writing any other term as there are none to over-write, and;
gives;-
I can only guess that views is not expecting a non-integer key, or is not handling it properly.
I don’t think that passing a
0meaning to this function, is ideal –nullwould be better – and$blankis not an ideal name for this argument:if($blank) {...}doesn’t convey the logic of the code, in fact, the opposite.Using
''as the key is a little obscure if this array is being used elsewhere:'default'might be more explicit, but changing this might break other code that relies on''. ‘Magic’ values are always difficult.If the maintainers of taxonomy are happy to change the keys, and this fixes the issue – then fine, but I think this is caused by views.
Comment #7
drummAgreed with above review. Please re-open against either 6.0 or a contributed module if the problem persists.
Comment #8
btully commentedwe're not going to 6.0 any time soon unfortunately, so is the patch our only solution? It seems strange that the key would be changed just for the sake of changing it without an explanation of what the benefits are, do I doubt this is the case. However, changing the key back to $options[] = $blank fixes the issue with Views and doesn't appear to break anything else. Can someone explain why the key was changed to $options[''] = $blank and what I might be missing as having broken since changing it back using the patch?
Many thanks in advance and thanks to Harry for this patch.