Hi, I get those errors after viewing a node that doesn't have any referrer yet:

warning: array_filter() [function.array-filter]: The first argument should be an array in /var/www/maw/sites/all/modules/nodereferrer/nodereferrer.module on line 162.
warning: array_values() [function.array-values]: The argument should be an array in /var/www/maw/sites/all/modules/nodereferrer/nodereferrer.module on line 162.
warning: array_filter() [function.array-filter]: The first argument should be an array in /var/www/maw/sites/all/modules/nodereferrer/nodereferrer.module on line 163.
warning: array_values() [function.array-values]: The argument should be an array in /var/www/maw/sites/all/modules/nodereferrer/nodereferrer.module on line 163.

using last 1.x dev.

Comments

mesr01’s picture

Title: Strange error when » Invalid argument type for functions in nodereferrer.module

I also experience this bug. It's worth mentioning that I get this message for lines 135-136 as well as 162-163. My version is 6.x-1.0-rc2 (with a PostgreSQL database backend).

# warning: array_filter() [function.array-filter]: The first argument should be an array in /var/www/drupal/sites/all/modules/nodereferrer/nodereferrer.module on line 135.
# warning: array_values() [function.array-values]: The argument should be an array in /var/www/drupal/sites/all/modules/nodereferrer/nodereferrer.module on line 135.
# warning: array_filter() [function.array-filter]: The first argument should be an array in /var/www/drupal/sites/all/modules/nodereferrer/nodereferrer.module on line 136.
# warning: array_values() [function.array-values]: The argument should be an array in /var/www/drupal/sites/all/modules/nodereferrer/nodereferrer.module on line 136.
# warning: array_filter() [function.array-filter]: The first argument should be an array in /var/www/drupal/sites/all/modules/nodereferrer/nodereferrer.module on line 162.
# warning: array_values() [function.array-values]: The argument should be an array in /var/www/drupal/sites/all/modules/nodereferrer/nodereferrer.module on line 162.
# warning: array_filter() [function.array-filter]: The first argument should be an array in /var/www/drupal/sites/all/modules/nodereferrer/nodereferrer.module on line 163.
# warning: array_values() [function.array-values]: The argument should be an array in /var/www/drupal/sites/all/modules/nodereferrer/nodereferrer.module on line 163.
fourmi4x’s picture

I have the same issue.

thadwheeler’s picture

I am seeing same issue with 6.x-1.0-rc2. It appears only on nodes without a referrer it seems

alexgreyhead’s picture

Same here, 6.x-1.0-rc2:

warning: array_filter() [function.array-filter]: The first argument should be an array in
/sites/all/modules/nodereferrer/nodereferrer.module on line 135.
warning: array_values() [function.array-values]: The argument should be an array in
/sites/all/modules/nodereferrer/nodereferrer.module on line 135.
warning: array_filter() [function.array-filter]: The first argument should be an array in
/sites/all/modules/nodereferrer/nodereferrer.module on line 136.
warning: array_values() [function.array-values]: The argument should be an array in
/sites/all/modules/nodereferrer/nodereferrer.module on line 136.

andypost’s picture

Please explain a steps to reproduce this bug

Anonymous’s picture

Version: 6.x-1.x-dev » 6.x-1.0-rc2

Same issue in 6.x-1.0-rc2 here too.

In my setup, we have two content types, "Project" and "Portfolio Item" which refer to another content type "Client". Client has a nodereferrer field.

Maybe it's something to do with the fact that two content types are referring one.

After setting up the second node reference I forgot to check the box for that content type under "Referring Node Types:" as well as "Referring fields", but I have corrected that now and it doesn't seem to be related to this issue.

andypost’s picture

Version: 6.x-1.0-rc2 » 6.x-1.x-dev

Is this still an issue? Please test against current 6-dev

pareen’s picture

Its still an issue with rc2. Havent tried it with dev.

But I think it is because I am using node reference url widget. Error disappears if I select the autocomplete widget (or any other default ones).

Anyone else using this module?

bramface’s picture

I'm having the issue, but not using reference URL widget.

Anonymous’s picture

Same issue with RC2.

Anonymous’s picture

I have tested this against the current dev version dated 2011-Feb-25 and I can confirm that this is still an issue.

PHP version 5.3.6

Error message:

warning: array_values() expects parameter 1 to be array, null given in /home/bjncom/public_html/sites/all/modules/nodereferrer/nodereferrer.module on line 134.
warning: array_filter() expects parameter 1 to be array, string given in /home/bjncom/public_html/sites/all/modules/nodereferrer/nodereferrer.module on line 135.

jvieille’s picture

Same issue, lines 135, 136 with nodereferrer-6.x-1.0-rc2

- on nodes without refering nodes

jvieille’s picture

Status: Active » Needs review

This seems to come with latest php versions that are more strict about data type.

I solved the issue by modifying lines 135-136 as follow
Current code

   case 'load':
      $types = isset($field['referrer_types']) ? array_values(array_filter($field['referrer_types'])) : array();
      $fields = isset($field['referrer_fields']) ? array_values(array_filter($field['referrer_fields'])) : array();

Modified code

   case 'load':
+    if (($field['referrer_types'])){
      $types = isset($field['referrer_types']) ? array_values(array_filter($field['referrer_types'])) : array();
+   }
+   if (($field['referrer_fields'])){
      $fields = isset($field['referrer_fields']) ? array_values(array_filter($field['referrer_fields'])) : array();
+   }

Idem for lines 162-163
Current code

      $types = array_values(array_filter($field['referrer_types']));
      $fields = array_values(array_filter($field['referrer_fields']));

Modified code

      if (($field['referrer_fields'])){
      $types = array_values(array_filter($field['referrer_types']));
      }
      if (($field['referrer_fields'])){  
      $fields = array_values(array_filter($field['referrer_fields']));
      }
andypost’s picture

Status: Needs review » Needs work

can you provide a patch? also suppose we just need to change isset() to !empty() in both cases

jvieille’s picture

I don't know how to create a patch. (I installed Tortoie svn/cvs on my windows pc, but it looks like a piece of crap, or I did not spent enough time to gets the logic.)
I haven(t tried to change isset only, but the code breaks before, while evaluating the arguments, so I don't think your proposal would make it.

jvieille’s picture

Is it possible to fix this?
Thanks

spydmobile’s picture

bump?

esolano’s picture

Version: 6.x-1.x-dev » 6.x-1.0-rc2
Status: Needs work » Needs review
StatusFileSize
new1.12 KB

Hi! Here's a patch that might work for comment #14

andypost’s picture

Issue summary: View changes

any reviews?