Comments

jsacksick’s picture

Status: Active » Needs review
StatusFileSize
new1.15 KB
bojanz’s picture

Status: Needs review » Fixed
StatusFileSize
new1.15 KB

Committed the attached patch (made the second chunk consistent with the first, $uri['path'] instead of $path['path']).

This is important if you want to provide per-vocabulary taxonomy pages.
Also, there is no guarantee that the entity url for a term will stay "taxonomy/term", that's just the default provided by the module.

bojanz’s picture

Status: Fixed » Needs work

Okay, didn't push yet.

We'll want to change:

$terms = taxonomy_term_load_multiple(array_keys(array_filter($terms)));

(There's no need for array_filter() since the value is always TRUE)

bojanz’s picture

Status: Needs work » Needs review
StatusFileSize
new1.12 KB

So maybe this?

Note that we are loading all found terms, which has a performance impact.
A better idea might be to just load the first term, though there is a possibility that the referenced term no longer exists, in which case no url could be returned (do we care about this? Probably not).

donquixote’s picture

If you are worried about loading only one term, just put it inside the loop.

donquixote’s picture

Btw, if anyone wondered about the uncommented stuff in lines 58 - 74:
This is in case we have multiple terms for an entity, and one is the parent of another. In this case, we want to pick the child, not the parent.
This desperately needs a comment. (I won't do it now to not mess around with line numbers until this patch is committed)

I also want to note that we have a lot of hardcoded entity urls in Crumbs. node/%, taxonomy/term/%, etc.
E.g. the entity_uri() in findParent__taxonomy_term_x() will have very limited effectiveness, if the method does not fire in the first place.

The goal is to have some smart detection which plugins should fire for a given path, without trying every plugin on every request. This should be discussed in a follow-up.

jsacksick’s picture

Loading multiple taxonomy terms is definetly much efficient than loading one by one I'd say.

if (!empty($uri)) {
  return $uri['path'];
}

We should probably fallback on taxonomy/term/tid if $uri returns NULL

donquixote’s picture

In 99% we only need the first one. So it is more efficient in this case to load only one. If we do that, we just put it inside the loop to be safe.
For the (!empty($uri)) I have no opinion, maybe you are right.

jsacksick’s picture

As a general remark, every crumbs multiplugin implements crumbs_MultiPlugin that only has the describe method, but it seems that every plugin implements a _findParentPath method(). Is there a reason for that ?
We should probably replace every hardcoded node/, user/ etc by entity_uri and use entity_load instead of taxonomy_term_load when needed.

bojanz’s picture

I agree with #8, loading 1 by 1 is fine, we'll load only 1 in 99.9% of the cases.
If $uri returns NULL, that means the term has no URI of its own, so defaulting to 'taxonomy/term/tid' makes no sense.

No need to rush with fixing other plugins, these are all edge cases, with taxonomy uri just being the most common of them.

I like #5, but since we're supporting NULL uris in the first part, let's do the same in the second part as well.

donquixote’s picture

Status: Needs review » Reviewed & tested by the community

I'm happy with #10.

bojanz’s picture

Status: Reviewed & tested by the community » Fixed

Committed. Yay, team! :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.