I don't really know if it's a FAQ Ask issue, but it only happens when I save a new "ask a question" :

warning: function_exists() expects parameter 1 to be string, array given in
includes\form.inc on line 769.

This message is on the screen after I save the new question, and the question is saved. Running PHP 5.3.0, Drupal 6.19 and FAQ_Ask 6.x-2.x-dev and FAQ 6.x-1.x-dev.

Would appreciate any ideas on tracking it down.

Comments

verta’s picture

Status: Active » Needs review

Well, I took a shot at the code, even though I am not at all a PHP coder. Seemed to me that the form validation (form.inc) was somehow annoyed at some null value in an array.

from form.inc, lines 756 to 762 (the error line)

function form_execute_handlers($type, &$form, &$form_state) {
  $return = FALSE;
  if (isset($form_state[$type .'_handlers'])) {
    $handlers = $form_state[$type .'_handlers'];
  }
  elseif (isset($form['#'. $type])) {
    $handlers = $form['#'. $type];
  }
  else {
    $handlers = array();
  }

  foreach ($handlers as $function) {
    if (function_exists($function))  {

So I commented out line 217 in faq_ask.module, the area that was commented as being concerned with validating the email field.

And whadda-ya-know, that got rid of the error. It works fine with and without the "Notify by E-mail (optional)" check box checked.

Here is the code block before I commented out that line:


  // Add validation of the e-mail field
  if (isset($form['#validate'])) {
    $temp_val = $form['#validate'];
   $form['#validate'] = array($temp_val);
 }
  else {
    $form['#validate'] = array();
  }
  $form['#validate'][] = 'faq_ask_form_validate';

after


217:  //   $form['#validate'] = array($temp_val);

Edit: We do not allow anonymous question submission, so this is only for authenticated users, so the email address field is hidden on our site.

Comments welcomed.

verta’s picture

Alternate solution, after reading http://drupal.org/node/768260 it seemed better to do it this way, so it would work if/when we enable anonymous submissions.

On line 222 of faq_ask.module:

before

222: $form['#validate'][] = 'faq_ask_form_validate';

after

222: $form['#validate'] = array('faq_ask_form_validate');

proindustries’s picture

Just ran into this as well, and the fix in #2 worked great...

jlea9378’s picture

The fix in #2 above worked for half of my problem (I was getting two errors, now only get one).

I still get this when asking a question while Better Select is enabled:

warning: Invalid argument supplied for foreach() in /var/www/html/drupal_test/sites/all/modules/betterselect/betterselect.module on line 227.

stenjo’s picture

Assigned: Unassigned » stenjo

Implemented the fix in #2 into the 6.x-2.x-dev version. Please verify that this fixes the problem

jlea9378’s picture

Looks good in the dev version so long as the Better Select module isn't enabled. Otherwise I get this:

warning: Invalid argument supplied for foreach() in /var/www/html/drupal_test/sites/all/modules/betterselect/betterselect.module on line 227.

summit’s picture

Subscribing, greetings, Martijn

jlea9378’s picture

I installed the latest dev release (6.x-2.x-dev (2011-Jul-20)) and the problem has now returned.

warning: function_exists() expects parameter 1 to be string, array given in /var/www/html/drupal_test/includes/form.inc on line 770.

stenjo’s picture

Is this still a problem with the dev version? When I check the code, line 222 says $form['#validate'][] = 'faq_ask_form_validate';

stenjo’s picture

Status: Needs review » Fixed

My bad! Found out that I had messed with the verisoning, Should be fixed in the 6.x-2.x version now.

Status: Fixed » Closed (fixed)
Issue tags: -PHP 5.3

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