Closed (fixed)
Project:
Yahoo Terms
Version:
5.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
13 Aug 2007 at 15:53 UTC
Updated:
30 Sep 2010 at 02:10 UTC
I'm receiving the following error when making a post to my forum:
warning: array_keys() [function.array-keys]: The first argument should be an array in /var/www/html/sites/all/modules/yahoo_terms/yahoo_terms.module on line 120.
This does not make any sense to me. I have not applied the the Yahoo Terms taxonomy vocabulary to forum post. Also, I have set "Maximal number of terms" to zero for this content type.
Comments
Comment #1
jimsmith commentedI was able to work around the array_keys() problem by applying the patch at http://drupal.org/node/171620.
But then I upgraded a few things and moved the parsing of my feed to FeedAPI. Now I get the same error when I run the feed parsing.
warning: array_keys() [function.array-keys]: The first argument should be an array in /var/www/html/sites/all/modules/yahoo_terms/yahoo_terms.module on line 119.Comment #2
jimsmith commentedMy httpd error log shows the following error:
Unsupported operand types in /var/www/html/sites/all/modules/yahoo_terms/yahoo_terms.module on line 122This is similar to the error reported here
Comment #3
jimsmith commentedI think I fixed this problem, but because I only know survival PHP I can't declare that I fixed it correctly. All I know is that I eliminated the error message on my site. The Yahoo terms now apply correctly without generating any errors.
Here's what I did:
1. I applied the patches found here and here. The patches didn't completely apply correctly using standard command line instructions, so I had to manually edit the updated code into yahoo_terms.module. I believe the patches would not apply correctly because they were written for a previous version of the module.
2. The patches eliminated the "Unsupported operand types" error message in my httpd/error_log file, and though the other error was still there, the wording of the PHP error message was now slightly different. Now it said:
warning: array_merge() [function.array-merge]: Argument #1 is not an array in /var/www/html/sites/all/modules/yahoo_terms/yahoo_terms.module on line 114.3. Taking a look at the PHP error message more closely and using my very rudimentary PHP coding skills, I figured out I needed to determine what was happening to this line in yahoo_terms.module:
$node->taxonomy = array_merge($node->taxonomy, $tids);Well, my skills couldn't take me far enough to actually figure out why this wasn't working, but I at least knew enough to try something.4. I guessed that the first argument, $node->taxonomy, was empty because I was not applying other terms to my nodes, except those created by the Yahoo Terms module.
5. Acting on this guess, I changed
$node->taxonomy = array_merge($node->taxonomy, $tids);to this:$node->taxonomy = array($tids);This change stopped the error messages.
As I said, I won't claim that this is a proper way to fix this problem. In fact, I believe if other taxonomy terms were being applied besides those created by Yahoo Terms, they would not show up because of my change. Again, I'm only guessing at this. Someone with stronger PHP skills would need to verify that and perhaps write a patch that allows the module to work in either situation.
Comment #4
marcp commentedSee this: http://us2.php.net/manual/en/function.array-merge.php
You have fixed the problem for yourself, but not in the general case, because $node->taxonomy may contain some data that you'll lose with your fix.
array_merge() behaves slightly differently in different PHP versions, so the fix is to make sure that all the arguments passed in are arrays.
I don't have time to code up the fix now, so maybe you can find someone else to read this and write the code.
Comment #5
Shiny commentedthis bug was fixed a while back