Warning: array_merge() [function.array-merge]: Argument #2 is not an array in user_relationship_locator_matches() (line 93 of C:\Zend\Apache2\htdocs\sites\all\modules\user_relationship_locator\user_relationship_locator.api.inc).

Comments

danreb’s picture

Title: I'm having this warning message on every page after installation » Warning: array_merge() [function.array-merge]: Argument #2 is not an array in user_relationship_locator_matches()

change issue title to easily track..

danreb’s picture

Status: Active » Closed (fixed)

This problem is not present in the dev version, thought it's already fixed... closing this one, my bad I didn't test the dev first. :)

olivier999’s picture

Version: 7.x-1.0-alpha1 » 7.x-1.x-dev
Status: Closed (fixed) » Active

Great module.
However, this message is still present, even in the dev version.
Any idea would be welcome ;)

mrf’s picture

I think this error comes up when you don't have any relationship information to pass in, should be easy for me to include check for that, but just creating some dummy relationships between a couple of users should make it go away.

olivier999’s picture

your solution works but user can see himself and his relations in choice even if he has 3 actives relations.
Would it be possible not to show any results while there are not relevant ?

mrf’s picture

I just published an alpha2 that includes the single change for the issue you describe, its possible you were running off of an earlier dev, and the module was pretty useless without that fix.

olivier999’s picture

Thank you for the update : everything is working perfectly now.

mattsteven’s picture

Disregard my previous comment- I would report that this is regressed on my installation with 7.x-1.0-alpha2 and so it's not really fixed.

Warning: array_merge(): Argument #2 is not an array in user_relationship_locator_matches() (line 95 of sites/all/modules/user_relationship_locator/user_relationship_locator.api.inc).

I can suppress it with changing to

$matches = (count($filler)) ? array_merge($matches,$filler) : $matches;

But I think the root of the problem is that it doesn't work for very small sets. I have three users in my DB including admin, and verified they are stored in the user_relationship_locator table ( a:2:{i:6;s:1:"6";i:1;s:1:"1";} ) Not sure of the structure of this, but it looks like there are two elements in this array which should be enough to force a suggestion of the other user right?

Thanks for your work on this very useful module!

mattsteven’s picture

StatusFileSize
new1.16 KB

Here's a patch, but I don't want to suggest anyone use it just yet. It seems to get it working right for me, but look at the line 95 test condition because it seems backward to me at the moment even if it works.

I think the problem was that php's array_rand function returns a string not an Array when there's less than two values. Bad design on their part, but you have to make room for the exception.

--- sites/all/modules/user_relationship_locator/user_relationship_locator.api.inc	2011-12-20 11:34:51.000000000 -0600
+++ sites/all/modules/user_relationship_locator/user_relationship_locator.api.inc.patched	2012-02-02 12:08:19.604587758 -0600
@@ -84,15 +84,19 @@
   
   //Fill an array with randoms UIDS to fill our block if we don't have enough matches
   //TODO: instead of random this could be pseudo random where it starts only filling random people from in-network then branches out
-  $result = db_query('SELECT uid from {users} WHERE uid > 1');
+  $result = db_query('SELECT uid from {users} WHERE uid > 1 AND uid != '.$uid);
   $allusers = array();
   foreach($result as $value) {
     $allusers[$value->uid] = $value->uid;
   }
   if(count($matches) < $min) {
     if($min <= count($allusers)) {
-      $filler = array_rand($allusers,($min - count($matches)));
-      $matches = array_merge($matches,$filler);
+    	
+      $filler = (count($allusers) <= $min) ?
+      	array_rand($allusers,($min - count($matches))) : $allusers;
+      	
+	  foreach($filler as $ky)
+	  	$matches[] = $allusers[$ky];
     } else {
       $matches = array_merge($matches,$allusers);
     }
mrf’s picture

Status: Active » Postponed (maintainer needs more info)

Can you let me know what version of PHP you are using? I'm not able to recreate this error and I have a suspicion the behavior of array_rand might have been fixed in my version.

I committed a fix for the db_query you caught, I'd recommend in the future you use drupal's api rather than string concatenation, it protects you from all sorts of security vulnerabilities. http://api.drupal.org/api/drupal/includes--database--database.inc/functi...

mattsteven’s picture

Thanks for the quick reply, and advice on queries. I forgot I included that quick fix when posting. =)
Here's my version, it's the standard php included in ubuntu 11.10, so if you grab a VM of that you can probably get pretty close to what I'm doing.

PHP 5.3.6-13ubuntu3.3 with Suhosin-Patch (cli) (built: Dec 13 2011 18:18:37)

mrf’s picture

Ok, I'm running the same version of PHP, so no help there.

Maybe you could get me the exact combination of users and releationships you are experiencing this with? I didn't see this with only one active relationship between the two users on the site.

mrf’s picture

Status: Postponed (maintainer needs more info) » Active

Closed #1469118: User relationship locator configuration as a duplicate, but I now have a new test case from there to run with.

mrf’s picture

Fixed in http://drupalcode.org/project/user_relationship_locator.git/commitdiff/0....

Please try out the latest dev and let me know if this is working for you.

Thanks mattsteven for the patch, realized after I worked on this for a while you were handing me the answer but I was too dense to see it. :)

mrf’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

jibran’s picture

Status: Closed (fixed) » Active

When the user have no friend I am getting this error.
Warning: array_merge() [function.array-merge]: Argument #2 is not an array in user_relationship_locator_matches() (line 116 of sites/all/modules/user_relationship_locator/user_relationship_locator.api.inc).
Minimum number of matches to return is 3.
Maximum number of matches to return is 5.
Depth to search for relationship matches 1.
I have updated it with latest dev version but error is still occurring.

jibran’s picture

Can someone respond to this?

mrf’s picture

Just pushed another change to dev that should cover your example, please let me know if it resolves your issue.

mrf’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.