I've just found a problem using Taxonomy Filter with Drupal 7.22 (and 7.21), using the "Taxonomy filter - search results" block.
If i access to url like /taxonomy/term/111 - and "111" is not an existing term, i receive lot of errors, like these:
Notice: Trying to get property of non-object in taxonomy_filter_block_current_content() (linea 312 di D:\Apache22\htdocs\unijuris2reloaded\sites\all\modules\taxonomy_filter\taxonomy_filter.module).
Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (linea 178 di D:\Apache22\htdocs\unijuris2reloaded\includes\entity.inc).
[..omissis.. - watch attachment for further info]
But it works perfectly if the given term is defined.
Any idea about how to fix it?
| Comment | File | Size | Author |
|---|---|---|---|
| snap-filter.jpg | 675.79 KB | francoud |
Comments
Comment #1
francoud commentedNobody can answer...? It's a serious bug...
Comment #2
francoud commentedOK i found by myself a reasonable solution, I think.
In taxonom_filter.module, the function _taxonomy_filter_validate_tids should be modified to validate $tid only if it's an existent "tid". I propose this little modification:
remove line 784:
- $tids[] = (int) $tid;
add these two new lines:
+ if (taxonomy_term_load($tid)) {
+ $tids[] = (int) $tid;}
This should be the result:
/**
* Validates and converts the term ids in the url to an array.
*/
function _taxonomy_filter_validate_tids($raw_tids) {
$tids = array();
foreach (preg_split('/[+ ,]/', $raw_tids) as $tid) {
if (is_numeric($tid) && (int) $tid > 0) {
if (taxonomy_term_load($tid)) {
$tids[] = (int) $tid;}
}
}
return $tids;
}
It worked for me. Can anybody confirm?
Thanks
Comment #3
francoud commentedMy patch not working so good, any other idea...?