I have a view that displays a "fully rendered term" for a referenced term.

A term was deleted and due to #1281114: Database records not deleted for Term Reference Fields after Term is Deleted this means that there is a tid being passed from the View to display suite that reference a term that no longer exists.

taxonomy_term_view() throws a fatal error in ds_field_formatter_view() when taxonomy_term_load() comes back with an empty record.

CommentFileSizeAuthor
#8 2045529-8.patch650 bytesmeeli

Comments

thedavidmeister’s picture

Should maybe look like:

      else {
        $term = taxonomy_term_load($item['tid']);
        if (!empty($term)) {
          $build = taxonomy_term_view($term, $view_mode, $langcode);
        }
        else {
          $build['#markup'] = '';
        }
      }
swentel’s picture

Priority: Major » Normal

Oh Drupal core ..

thedavidmeister’s picture

You think I should open an issue against core for taxonomy_term_view()?

I do feel like that it's DS's responsibility to use the core API correctly, even if it's awkward that the API doesn't let you reliably put "load" straight into "view".

Maybe there should be two open issues for this?

Also, shouldn't fatal errors for a common use-case be major? It's not exactly unlikely that you would want to display a term rendered by a view and also be allowed to delete terms.

swentel’s picture

The issue should be ideally be fixed in #1281114: Database records not deleted for Term Reference Fields after Term is Deleted, but I don't see that happening soon.

I don't necessarily consider this major as I find it curious to way the tid is even still there in ds_field_formatter_view() when the node is being rendered.

I'll make a hotfix for this one anyway, don't worry :)

swentel’s picture

Nevermind, I see why it's still there.

thedavidmeister’s picture

I'm using Views to display a "full rendered term" for a term referenced by a product line item in commerce, there's no nodes involved, it's a field in Views.

It seems that Views gets the tid from the query it builds and blindly sends it off to be rendered with the default view mode for taxonomy terms.

thedavidmeister’s picture

Priority: Normal » Major

From https://drupal.org/node/45111

Issues which have significant repercussions but do not render the whole system unusable are marked major. An example would be a PHP error which is only triggered under rare circumstances or which affects only a small percentage of all users. These issues are prioritized in the current development release and backported to stable releases where applicable. Major issues do not block point releases.

This issue is perfectly described by the example in the formal definition of major issues ;)

meeli’s picture

Status: Active » Needs review
StatusFileSize
new650 bytes

Patch for the code described above attached here.

swentel’s picture

Version: 7.x-2.4 » 8.x-2.x-dev
Status: Needs review » Patch (to be ported)

Committed and pushed to 7.x-2.x, moving to 8.x-2.x

swentel’s picture

Status: Patch (to be ported) » Closed (fixed)

committed and pushed to 8.x-2.x