I've found and issue on panels module (or maybe ctools...) that appears when you try to access a panel page with an argument of type "taxonomy term", passed by title, and the same term is available on different vocabularies.
This is the error, returned n times (one for each taxonomy term in different vocabularies)
warning: Invalid argument supplied for foreach() in .../sites/all/modules/ctools/plugins/arguments/term.inc on line 49
The warning raises because in ctools "term.inc" there is:
case 'term':
$terms = taxonomy_get_term_by_name($arg);
if (count($terms) != 1) {
foreach ($terms as $potential) {
foreach ($conf['vids'] as $vid => $active) {
count($terms) is obviously > 1 so it executes the foreach... but $conf['vids'] is not populated...
Steps to reproduce the issue:
- Have a term in more than one taxonomy (let's say "mydoubletaxonomyterm", different tids but same visible name)
- Add panel page (/admin/build/pages/panel-page/add) with path "test/%term"
- Assign context "Taxonomy term" -> "Term title"(not Term ID)
- It isn't necessary to add any content to the page...
- Try to access page /test/mydoubletaxonomyterm
I tried to force a single vocabulary in the panel by adding a new Context (Contexts->Add Context->Taxonomy vocabulary) and forcing one vocabulary... but it doesn't work as expected (nor it saves the choosen vocabulary in the form... maybe this is another bug...)
| Comment | File | Size | Author |
|---|---|---|---|
| #24 | 467898-3.patch.txt | 1.63 KB | jp.stacey |
| #19 | 467898-2.patch | 1.71 KB | mikeker |
| #18 | 467898.patch | 625 bytes | mikeker |
| #9 | ctools_foreach_error.diff | 539 bytes | dalin |
Comments
Comment #1
jjemmett commentedI agree with the above synopsis Panels needs to provide an interface to specify the vocabulary that the term is to come from in the argument form. That interface needs to populate the $conf['vids'] variable in ctools.
Comment #2
merlinofchaos commentedThe proper way to fix this is probably to split the argument into two separate arguments, since specific config options are unwieldy. We also need more stuff like Views has where you can use taxonomy synonyms as arguments.
Comment #3
tauno commentedMarked #551084: Same term in two taxonomies causes error in term.inc line 50 as a duplicate of this issue. The bug still exists in the 3.0 release of panels and 1.0 release of ctools.
Comment #4
petrelharp commentedIf there is no way to select which taxonomy terms are from, it is unclear what the default behavior should even be. In this case, it might be best to use tid rather than term name.
Comment #5
mactoph commentedFor reference, in my case I have duplicate terms in two different vocabularies and would like to pull content from both of those terms into a vocabulary page- that functionality works fine, but it does throw the error.
Comment #6
petrelharp commentedIs there a workaround to make the error invisible to the end users?
Comment #7
petrelharp commentedMore information about this bug: it's turned out to be quite bad on one of my sites, since if a user adds a term to a free tagging taxonomy that is identical to one in another taxonomy (as they are wont to do), it makes error messages appear on *all* pages, even the administration pages.
Hope this helps.
Comment #8
vood002 commented@petrelharp: Just change your error reporting settings at admin/settings/error-reporting
Or...in other words...subscribing
Comment #9
dalin@petrelharp a safer workaround is to change the if line to
if (count($terms) > 1) {
That way the original handling of when count($terms) == 1 is still retained.
I'm submitting this as a patch for someone who knows what this function does to review. I too find it disconcerting that this function is being called on every page, even the admin section.
Comment #10
dalinComment #11
jjemmett commentedsubscribing
patch did not fix any error for me. Still have problem with the fact that $conf['vids'] is unpopulated.
Comment #12
jjemmett commentedComment #13
pazzypunk commentedIs there no way to avoid this by selecting a vocabulary for a pane so that it only looks for a term in that vocabulary? Seems logical but I can only figure it out for the view, not the panel.
Comment #14
dman commentedStill an issue.
updated (from #9) made it stop throwing warnings. Not sure about the bigger 'by-vocab' feature right now.
Comment #15
jlain commentedsubscribing
Comment #16
naero commentedsubscribing
Comment #17
CinemaSaville commentedSubscribing
Comment #18
mikeker commentedIt seems to me that there are two issues here:
$conf['vid']is unpopulated because the context is derived from the panel's path rather than the panel settings formtaxonomy_get_term_by_name($arg)returns no matching termsI don't think it's related to a term being found in multiple taxonomies. (Note: changing the title to reflect that, please change it back if I'm incorrect about this).
I've attached a patch that solves both of these issues, but I'm afraid that I'm treating the symptom and not the cause. The underlying problem is that
$confis not populated if the context is created outside of the pane settings form. Perhaps that's the way it should be? As such, I'm marking this as active until someone with a better understanding of how contexts are passed around can look at this.Thanks.
- Mike
Comment #19
mikeker commentedSpent a little more time working with this and I think I've come up with a better solution: allow the user to select one or more vocabularies to limit the context to when converting a path argument to a context. This ensures that $conf['vids'] is set and maintains the existing functionality if the user makes no changes.
- Mike
Comment #20
mikeker commentedSorry, just realized all this has been going on in the Panels queue. Moving to ctools queue as that's where the fix belongs.
Also reducing the priority -- I hadn't realized that this was originally entered as critical.
Comment #21
mikeker commentedgrumble, grumble... And changing to the correct component... I think.
Comment #22
greenbeans commentedThis is happening to me when the term in the context has a child term with the same name as another term in a different branch of the same vocabulary. Any ideas how to work around that?
Comment #23
jbrauer commentedupon testing the patch in #19 I get a different error as a result of the patch
warning: array_filter() [function.array-filter]: The first argument should be an array in [...]/sites/all/modules/ctools/plugins/arguments/term.inc on line 47.
Comment #24
jp.stacey commented@mikeker - your patch from #19 works well apart from the bug mentioned in #23 if config hasn't been set for that particular pane.
Solution: a trivial change of line 47 to:
Patch re-rolled and attached.
@jbrauer another solution would be to actually configure the vocabulary for your page. That might involve recreating the Panels page, as I can't see any way of editing existing contexts here :-/
Comment #25
merlinofchaos commentedCommitted, thanks! I slightly adjusted the #default_value test.