Invalid argument for ... when using a taxonomy term found in multiple vocabularies
| Project: | Panels |
| Version: | 6.x-3.x-dev |
| Component: | Panel pages |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | needs review |
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:
<?php
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...)

#1
I 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.
#2
The 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.
#3
Marked #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.
#4
If 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.
#5
For 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.
#6
Is there a workaround to make the error invisible to the end users?
#7
More 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.
#8
@petrelharp: Just change your error reporting settings at admin/settings/error-reporting
Or...in other words...subscribing
#9
@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.
#10