Problem/Motivation
Using a linked taxonomy term "Name" field in a view throws a fatal error on generating the URI. The error is: "The "taxonomy_term" entity type has not been saved, and cannot have a URI." This happens because we are using a stub entity created using entity_create() instead of loading the full term. The problematic code:
$term = entity_create('taxonomy_term', array(
'tid' => $tid,
'vid' => $this->getValue($values, 'vid'),
));
$this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = $term->getSystemPath();
It is trivial to create such a view, just go to the new View wizard and create a taxonomy view page with all the default options to expose the bug.
Proposed resolution
Get the full entity from the result row for rendering the link.
Remaining tasks
Review. Commit.
User interface changes
No fatal error when creating taxonomy field views.
API changes
None.
Comments
Comment #1
rbayliss CreditAttribution: rbayliss commentedPatch.
Comment #2
blazey CreditAttribution: blazey commentedFixes the issue.
Comment #3
tim.plunkettNice find! This could use some test coverage.
Comment #4
rbayliss CreditAttribution: rbayliss commentedI realized that the term is already loaded at this point, so we can just use the getEntity() method. Also added a test.
Comment #5
rbayliss CreditAttribution: rbayliss commentedComment #6
Gábor HojtsyFatal error so should at least be major. The fix and test looks good to me.
Comment #8
Gábor HojtsyClosed down #2320275: Taxonomy views do not work (fatal error) as duplicate. The default taxonomy views setting is fields based, so people cannot create a taxonomy view with the defaults thanks to this bug. Elevating to critical because that one was. (It is a fatal error you get by using a feature with default options means it is very common).
Comment #10
dawehnerI really hope that with #1857256: Convert the taxonomy listing and feed at /taxonomy/term/%term to Views we do have enough test coverage.
Comment #11
Gábor HojtsyThe taxonomy term base fields are now in taxonomy_term_field_data (see #1498660: Refactor taxonomy entity properties to multilingual), the test view should reflect that.
Comment #12
Gábor Hojtsy@dawehner: Looking at the patch and the view being patched by #1857256: Convert the taxonomy listing and feed at /taxonomy/term/%term to Views, it does not use the
link_to_taxonomy
option and therefore does not expose this bug. This bug is basically appearing with taxonomy views using the taxonomy name and the link_to_taxonomy option. That is also used in default taxonomy views created by picking no custom options in the Views wizard, just providing a name and asking for a taxonomy page, which is why it was elevated so high as a bug.Comment #13
Gábor HojtsyUpdates issue summary.
Comment #14
dawehnerLooks good!
Comment #15
jhodgdonI tested this also. Agree it works.
Did someone verify that the test fails without the patch though?
Comment #16
Gábor HojtsyTest only patch from 11 without the fix that will fail and 11 again so it keeps passing :)
Comment #18
Gábor HojtsyThe test only patch feedback from testbot shows the bug proper :)
Comment #19
jhodgdonGreat! +1 for RTBC then.
Comment #20
alexpottCommitted fb27c45 and pushed to 8.0.x. Thanks!
Comment #22
Gábor HojtsyYay, thanks!