Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi all!
With this module i got erros
Warning: array_keys() expects parameter 1 to be array, null given в функции similarterms_list() (строка 197 в файле Z:\home\easyflash.ru\www\sites\all\modules\similarterms\similarterms.module).
How fixed this in similar by terms 7.x-1.0-beta3?
Comment | File | Size | Author |
---|---|---|---|
#5 | similarterms-taxonomy_terms_loaded_incorrectly-1454412.patch | 945 bytes | areynolds |
Comments
Comment #1
areynolds CreditAttribution: areynolds commentedFrom a brief glance, it looks like similarterms doesn't support using pathauto aliases. Check out the code around line 167:
$nid will be null if this doesn't evaluate, leading to the error that we're both experiencing.
Comment #2
areynolds CreditAttribution: areynolds commentedThe short hack below that will enable aliases to be used; if there's more demand or if V2 is going to take a while for D7, I can write a patch which puts this option into the admin interface. Insert this code around line 167 (we're appending the elseif statement to the if statement which I mention in my above post).
Something like this should work, although you might want to add in some extra validation for your specific use case to make sure that you aren't running the path retrieval for every page, even if it isn't a node. That's the way I'm going to do it for my site, so let me know if you want an example or something.
Comment #3
areynolds CreditAttribution: areynolds commentedFor right now, I'm just marking this as "closed, works as designed". I took a quick look around the issue queue and didn't see anyone else complaining about this. This issue will ultimately be solved by the 2.0 branch coming to D7, which has views integration (this is already the case on D6).
If you think you're experiencing the error for another reason than path aliasing, please reopen the issue
Comment #4
areynolds CreditAttribution: areynolds commentedOk, should have done some more debugging until I spoke up :)
arg(1) should get the nid from the original system path, whether or not you're using an alias. This means I was totally wrong and the problem lies somewhere else.
Also note that my permutation of the issue has rendered the module inoperable.
Comment #5
areynolds CreditAttribution: areynolds commentedNote the code starting on line 517, dev branch:
$item['taxonomy_term'] doesn't exist; there's just $item['tid']. We can't link up terms with vocabulary ids this way, so if a $vid is given in similarterms_taxonomy_node_get_terms(), we have to load more data. This is one way to make it work:
Of course, this could probably be more performant by matching the $field vocabulary (we can get the vocabulary machine name from $field) with the $vid. My only question is how best to get the vocab machine name from the $vid:
Ideas?
I've attached a patch against the current dev version to get things running, let me know how that works out and if you have any suggestions.
Comment #6
areynolds CreditAttribution: areynolds commentedComment #7
areynolds CreditAttribution: areynolds commentedThis issue is a duplicate of 1277256 and 1260750; I'm marking it as a duplicate, progress is probably best followed in 1277256.
Comment #7.0
areynolds CreditAttribution: areynolds commentedfixed mistake