hello
when im going to : admin/content/node-settings and push the button "rebuild permissions", i receive this error 2 times :

warning: Invalid argument supplied for foreach() in /home/myname/public_html/mysite/sites/all/modules/views/views.module on line 969.

Comments

danielb’s picture

precisely the same error with 6.x-2.1



    * warning: Invalid argument supplied for foreach() in <snip>../contributions/modules/views/views.module on line 969.
    * warning: Invalid argument supplied for foreach() in <snip>../contributions/modules/views/views.module on line 969.




function views_exposed_form_submit(&$form, &$form_state) {
  foreach (array('field', 'filter') as $type) {
    $handlers = &$form_state['view']->$type;
    foreach ($handlers as $key => $info) {                        <--------- line 969
      $handlers[$key]->exposed_submit($form, $form_state);
    }
  }
  $form_state['view']->exposed_data = $form_state['values'];
  $form_state['view']->exposed_raw_input = array();

  foreach ($form_state['values'] as $key => $value) {
    if (!in_array($key, array('q', 'submit', 'form_build_id', 'form_id', 'form_token', ''))) {
      $form_state['view']->exposed_raw_input[$key] = $value;
    }
  }
}

I am using exposed filters in one of my views.

cdale’s picture

Title: error when rebuild nodes permissions » Error with exposed filter in block and batch API.
Component: Miscellaneous » Code

Danielb put me onto this, the block with the exposed filter can not be in the sidebars, i.e. it has to be in top, bottom, header, etc... as the sidebars (At least for me) are not shown on the batch API progress pages.

I've been able to repeat this using devel modules generate content with more than 50 nodes generated, with an exposed filter in a block in the footer.

The problem seems to come from somewhere in the Batch API. The error also happens when javascript is disabled.

cdale’s picture

Having thought about this a little more, I think there are a few solutions.

  1. Put an 'if' test in views_exposed_form_submit checking for the presence of $form_state['view'].
  2. In views_exposed_form, check if we are running a batch operation, and if so, set $form['#submit'] to be an empty array. (This will keep the form displaying on batch pages, but will disable its operation. This would probably need to be done for #validate also).
  3. At the start of views_exposed_form check for batch operation, and if so, return an empty array. (Form will not show up on batch pages).

Personally, I think #3 is the best approach, as it removes confusion over long batch processes, and the ability to accidentally submit a form that should probably not be submitted.

Thoughts?

cdale’s picture

Status: Active » Needs review
StatusFileSize
new878 bytes

Here is a patch which implements option 3 above.

The form does not get shown when batch operations are running, and works just fine when they are not.

merlinofchaos’s picture

Status: Needs review » Fixed

Wow, what a bizarre error. Good work tracking this down. Patch committed!

Status: Fixed » Closed (fixed)

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