When I add an action to clear a specific view's cache or to clear specific cache bins, I am receiving the following errors:

  • warning: strpos() expects parameter 1 to be string, array given in /var/www/html/drupal-6.20/sites/all/modules/rules/rules/modules/php.rules.inc on line 38.
  • warning: strpos() expects parameter 1 to be string, array given in /var/www/html/drupal-6.20/sites/all/modules/rules/rules/modules/php.rules.inc on line 41.
  • warning: strpos() expects parameter 1 to be string, array given in /var/www/html/drupal-6.20/sites/all/modules/rules/rules/modules/php.rules.inc on line 41.
  • warning: strpos() expects parameter 1 to be string, array given in /var/www/html/drupal-6.20/sites/all/modules/rules/rules/modules/php.rules.inc on line 41.

Comments

fabsor’s picture

Hi!

I can't seem to reproduce this with a basic rule.

Are you using the PHP to evaluate your rules? It seems like that's where the error occurs. Could you provide more detailed information about how you set up your rule?

rdonelson’s picture

I'm having this same problem and narrowed it down to PHP 5.3. Our development server is 5.2 and it works, but the QA environment is 5.3. I have a rule where the event is derived from friendlist, "User1 deletes a relation to user2" and the action is "Clear the cache for views displays". When I save the action, I get:

Warning: strpos() expects parameter 1 to be string, array given in token_rules_input_evaluator_prepare() (line 37 of .../sites/all/modules/token/token.rules.inc).
Warning: strpos() expects parameter 1 to be string, array given in rules_input_evaluator_php_prepare() (line 38 of .../sites/all/modules/rules/rules/modules/php.rules.inc).
Warning: strpos() expects parameter 1 to be string, array given in rules_input_evaluator_php_prepare() (line 41 of .../sites/all/modules/rules/rules/modules/php.rules.inc).

Each of the above warnings happens multiple times. The rule is not triggered correctly, I assume as a result of these warnings.

fabsor’s picture

Alright, it's PHP 5.3, that gives me a better idea on where to start. I will have a look at this as soon as possible. Thanks for the report!

rdonelson’s picture

Another nugget of useful information from the debugging I've done thus far. There must be an array to string conversion happening somewhere because on line 684 of cache_actions.rules.inc, I var_dumped the $views variable and the value is string(5) "Array" as opposed to array(1) { ["friends:block_1"]=> string(15) "friends:block_1" }. Hope that helps!

chrisdarke’s picture

Yeah Im getting exactly the same issue.. PHP 5.3, getting the value 'Array' showing up.. its not even an empty array (Array()) but the actual string 'Array' from what I can see.

Hope you can sort it out, as doing the rules for each view as per the old process is a lot slower.. keep up the great work! :)

fabsor’s picture

Status: Active » Fixed

Hi!

I think I located the problem and fixed it. The problem was that when you have the php filter on, everything that rules thinks is a string gets passed through it. I have changed the value type on all actions to be "values" instead of strings which made the error go away.

You might need to resave your rules in order for this to work, it seems that rules holds on to the old settings if you don't. I have pushed the fix to head, so if you use the dev version you will get it.

Status: Fixed » Closed (fixed)

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

hassan2’s picture

Was having the same error above. I found out it was caused by the FeedAPI Node Views. After disabling it the error has gone. Hope this helps