Problem/Motivation
When creating a glossary view for taxonomy terms, the character "0" (zero) is replaced with "Uncategorized".
This comes from the value of the "empty field name" for the argument handler of taxonomy_term_field_data tid.
\Drupal\views\Plugin\views\argument\ArgumentPluginBase::summaryName() uses a empty check which returns false for 0, so the value above from the definition is used.
This doesn't happen for nodes as it doesn't have this value filled in for the related argument handler.
Steps to reproduce
- Create a view to list taxonomy terms;
- Add and configure an attachment to show as glossary, limiting the labels to the first character;
- Create a taxonomy term that starts with "0" (character zero);
- Visit the page. The label "Uncategorized" will be shown.
Proposed resolution
Add a !is_numeric() check to leave out string 0.
Remaining tasks
Tests and fix will be attached.
User interface changes
None.
API changes
None.
Data model changes
None.
Release notes snippet
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | interdiff_10-12.txt | 806 bytes | Ratan Priya |
| #12 | 3291520-12.patch | 11.13 KB | Ratan Priya |
| #4 | 3291520-4.patch | 11.06 KB | sardara |
| #5 | 3291520-5-TEST-ONLY-FAIL.patch | 10.34 KB | sardara |
Issue fork drupal-3291520
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:
- 3291520-incorrect-label-term-glossary
changes, plain diff MR !2415
Comments
Comment #3
cilefen commentedComment #4
sardara commentedAdding the same content of the merge request as patch for external reference. Also attaching the separate test-only patch as I failed to have the separate commit of the MR tested alone.
Comment #5
sardara commentedMessed up the test only patch.
Comment #7
sardara commentedThe test patch failed as expected.
Comment #8
lendudeGreat work here, good expansion of the the test coverage so that it now actually tests the glossary!
Comment #10
alexpottI think this should be:
We have the same empty problem with the empty field name if you have 0 as the empty field name :) - I think isset-ness is fine here. The empty check here is odd. Mostly this is a TranslatableMarkup object and the empty check will not work the same at all.
Comment #11
Ratan Priya commentedComment #12
Ratan Priya commented@alexpott,
I made the changes you required at comments #10
Needs review.
Comment #13
andras_szilagyi commentedTest looks good, and the fix works as expected.
Comment #14
smustgrave commentedVerified the issue exists without the patch
Verified patch applies to 9.5.x cleanly
Verified patch resolved the issue described in the issue summary.
See there is a tests-only patch in #4
Reviewing the code looks good.
Moving to RTBC
Comment #15
alexpottI've run the tests locally on 10.1.x and it works great. This is a nice fix to views for an odd use-case. We definitely need to learn to be better at handling strings and empty() checks.
As this is a bug fix and does not involve API changes backporting to 9.5.x
Comment #19
alexpottDiscussed with @longwave - we agreed to backport to 9.4.x
Committed f4f5725 and pushed to 9.4.x. Thanks!