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.
I am seeing this message randomly on my pages. When I hit 'Refresh' it goes away.
Invalid argument supplied for foreach() in similarterms_taxonomy_node_get_terms()
Comment | File | Size | Author |
---|---|---|---|
#19 | similarterms-1277256-19.patch | 1.59 KB | lelizondo |
#14 | similarterms-taxonomy_terms_loaded_incorrectly-1454412.patch | 945 bytes | areynolds |
#7 | invalid-argument-1277256.7.patch | 1.29 KB | Xen |
Comments
Comment #1
efarseer CreditAttribution: efarseer commentedI encoutered this bug also.
Comment #2
lelizondo CreditAttribution: lelizondo commentedsubscribing
Comment #3
migmedia CreditAttribution: migmedia commentedIs this a dup of #1260750: annoying bug The first argument should be an array?
If not please add the full error-message (with line-number etc.)
Comment #4
efarseer CreditAttribution: efarseer commentedWarning: Invalid argument supplied for foreach() in similarterms_taxonomy_node_get_terms() (line 517 in sites/all/modules/similarterms/similarterms.module).
Comment #5
funkeyrandy CreditAttribution: funkeyrandy commentedno solutios here fix issue
Comment #6
nICEsCREAM CreditAttribution: nICEsCREAM commentedsubscribing
Comment #7
Xen CreditAttribution: Xen commentedPatch fixes this warning and the one in #1260750: annoying bug The first argument should be an array.
Comment #8
funkeyrandy CreditAttribution: funkeyrandy commentedAWESOME thanks!
Comment #9
pcambraThe patch fixes the warning, thanks!
Comment #10
cjs_ CreditAttribution: cjs_ commentedI applied this patch to 7.x-1.x-dev and am still getting the same error. Any thoughts? The module doesn't seem to be functioning as a result.
Comment #11
Evgenij CreditAttribution: Evgenij commented* Warning: Invalid argument supplied for foreach() in similarterms_taxonomy_node_get_terms_by_vocabulary() (line 536 of similarterms.module).
* Warning: array_keys() expects parameter 1 to be array, null given in similarterms_list() (line 196 of similarterms.module).
Comment #12
djmy CreditAttribution: djmy commentedwith patch getting it when i click on 'Similar entries from the Tags vocabulary.' block configuration
Warning: Invalid argument supplied for foreach() in similarterms_block_configure() (line 112 of /path/sites/all/modules/similarterms/similarterms.module).
Comment #13
areynolds CreditAttribution: areynolds commentedI inadvertently contributed to what is probably a duplicate of this issue:#1454412
I submitted a patch there against dev branch.
Comment #14
areynolds CreditAttribution: areynolds commentedThe code seems to expect $item['taxonomy_term'] to be a fully populated term object of some sort. This doesn't seem to be the case; my debugging only showed $item['tid'].
Here's a fix against dev that resolves my issues. It could probably be more performant by matching the vocabulary machine name provided by $field with the vocabulary identified by $vid (right now it loads taxonomy terms). I'm wondering if I should...
Guessing a quick db_query is most performant, but maybe not as kosher, seeing as taxonomy_vocabulary_load() is an interface I can probably count on being around for a while.
Comment #15
tormu CreditAttribution: tormu commentedI tested this patch against the dev version and seems to work.
Comment #16
John Pitcairn CreditAttribution: John Pitcairn commentedI'm slightly confused what the status of this issue is now. Needs review?
Comment #17
aendra CreditAttribution: aendra commentedAugh. I cannot get these warnings to disappear.
The patch in #7 fails with beta3.
The patch in #14 succeeds with 7.x.-1.x-dev but doesn't resolve the issue.
What am I doing wrong?
Currently using Drupal 7.14 and dev version of Similar By Terms.
Comment #18
mgiffordThe patch above doesn't seem to be adding any checking in the foreach in similarterms_taxonomy_node_get_terms() to see if it is actually an array or not. I didn't look at it in any detail, but would be good to get this resolved.
Comment #19
lelizondo CreditAttribution: lelizondo commentedLast patch didn't solve the problem for me.
Attaching a very simple patch that just adds a couple of "if".
The problem is only showing to me when there are no items to show on a block, so adding an if to only show if the module find terms solves it.
Please test against 7.x-1.x and report back
Comment #20
sourcesoft CreditAttribution: sourcesoft commentedAll patches failed when #19 fixed the issue finally. Thank you!
Comment #21
mgiffordWhen applying this against the master branch in the git repo I get:
Comment #22
lelizondo CreditAttribution: lelizondo commenteduse patch -p0 (or p1)
Comment #23
mgiffordIt really depends on how the maintainer wants to deal with it. A patch applied with git is often easier to bring in.
This issue should really get brought into the repo and set up for the next release before it's a year old. It's a simple enough check and an annoying enough error.
Comment #24
takim CreditAttribution: takim commented7.x-1.x is not anymore supported and maintained. Please use 7.x-2.x version for your websites.