LOCATION	https://mysite.com/views/ajax

Warning: array_values() [function.array-values]: The argument should be an array in views_handler_filter_in_operator->op_simple() (line 369 of /www/htdocs/sites/all/modules/contrib/views/handlers/views_handler_filter_in_operator.inc).

Warning: Invalid argument supplied for foreach() in DatabaseCondition->compile() (line 1853 of /www/htdocs/includes/database/query.inc).


  function op_simple() {
    if (empty($this->value)) {
      return;
    }

shouldnt this be:

  function op_simple() {
    if (!is_array($this->value)) {
      return;
    }

Comments

stephenrobinson’s picture

on second thoughts first argument is $this->options['group'], perhaps this is where the error comes from?

stephenrobinson’s picture

$this->options['group'] isnt an array???

stephenrobinson’s picture

$this->value is the only array in this method so I guess this is the issue?

agileadam’s picture

I'm seeing the same two errors on a site I just started maintaining.

Warning: array_values() expects parameter 1 to be array, string given in views_handler_filter_in_operator->op_simple() (line 369 of /home/redacted/webapps/redacted/sites/all/modules/views/handlers/views_handler_filter_in_operator.inc).

Warning: Invalid argument supplied for foreach() in DatabaseCondition->compile() (line 1853 of /home/redacted/webapps/redacted/includes/database/query.inc).

chewie’s picture

Please check this patch

chewie’s picture

Status: Active » Needs review
rupesh_jagtap’s picture

Status: Needs review » Needs work

It didn't work for me. Still same warning message is popping up.

rupesh_jagtap’s picture

I have been getting below error for some pages -

Warning: Invalid argument supplied for foreach() in DatabaseCondition->compile() (line 1853 of /home/redacted/webapps/redacted/includes/database/query.inc).

I have resolved the bug, but it was not related 'Views' module, rather is was caused by my custom code.

Just sharing here, in case anybody might be benefited - I have used 'hook_views_query_alter' to alter the query of views block and passed array value to altered filter field value. But since that array value was empty for certain pages where block is displayed it showed the warning message.

To resolve the issue, I have checked if array has value with (!empty($variable)).

jofitz’s picture

Status: Needs work » Needs review

It appears that @rupesh_jagtap had an unrelated problem so this should be returned to "Needs review"

jofitz’s picture

StatusFileSize
new409 bytes
new508 bytes

I agree with @chewie that we should check whether $this->value is an array, but suggest we should do that as well as (rather than instead of) checking that the array is not empty.

geek-merlin’s picture

Version: 7.x-3.8 » 8.x-3.x-dev

Note: While this patch fixes the warning, it's more probable than not that the real cause of this problem lies somewhere else.

You may want to get a backtrace with Printable Backtrace and post it here or even better debug why that illegal value got here in the first place.

lendude’s picture

Version: 8.x-3.x-dev » 7.x-3.x-dev
Status: Needs review » Needs work

I agree with @axel.rutz that this is just repressing an error that is caused by something else. We should find the real cause of the problem and fix that.

Lets keep this in the 7.x branch for now, since the most likely cause is a D7 handler doing something wrong. Unless we can trace this to something that is still around in D8, then lets move it up to D8 core queue.

mustanggb’s picture

If we want to fix the source(s) of the error I have found one when using an exposed "User: Name" filter and entering a filter value of a non-existent user.

This is the fix I used if anyone cares to roll a patch.

modules/user/views_handler_filter_user_name.inc

  function exposed_validate(&$form, &$form_state) {
    ...
+   $this->validated_exposed_input = array();
    if ($uids) {
      $this->validated_exposed_input = $uids;
    }
  }
steven jones’s picture

StatusFileSize
new535 bytes

Here's a trivial re-roll of the patch in #10 for 7.x-3.21.

mustanggb’s picture

StatusFileSize
new499 bytes
damienmckenna’s picture

Status: Needs work » Needs review
renatog’s picture

Status: Needs review » Reviewed & tested by the community

Tested it here and MustangGB's patch on #15 really works well. I agree with #13 fixing the root cause. Good catch. So moving to RTBC. Thank you so much, everyone

  • RenatoG committed 7ec08a8 on 7.x-3.x authored by MustangGB
    Issue #2274839 by jofitz, Chewie, MustangGB, Steven Jones,...
renatog’s picture

Status: Reviewed & tested by the community » Fixed
Parent issue: » #3118500: Plan for Views 7.x-3.25

Moved to the dev branch. Thank you so much, everyone. Have a great week

Status: Fixed » Closed (fixed)

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