the last line of patterns_execute_action() returns $result, but $result is never defined, meaning that the function always returns null.

I attempted to trace my way back through the functions called within the method to see if I could generate a way to do this, but realized I would have to hack up _patterns_process_form(), and how it handles the Drupal built-in validation and submission routines, which seemed daunting.

Finally I settled on the proposed patch, but this needs review as I am not sure how it would interact with the batch system.

In any case, the function should be returning something useful, and it would be great if _patterns_process_form() also could return some indicator of success or failure.

Here's my proposed modification:

--- orig	2010-05-03 16:19:26.000000000 -0400
+++ new	2010-05-03 16:19:24.000000000 -0400
@@ -1780,7 +1780,10 @@ function patterns_execute_action($form_i
   patterns_executing(false);
   $batch = $batch_clone;
 
-  return $return;
+  if (form_get_errors()) {
+  	return FALSE;
+  }
+	return TRUE;
 }
 
 function patterns_executing($b = null) {

Comments

vaish’s picture

Status: Active » Fixed

Good catch. This is some leftover code and it doesn't make any sense. Considering that all the errors are caught in the function that's calling patterns_execute_action() I decided to remove return value altogether. It wouldn't have any use because we always want to know much more details about the error then this return value could convey.

You can find current code for checking errors around the line 1679:

      if ($message = patterns_error_get_last('execute', $index, $action_description, $pattern_title, $pattern_file)) {
        $result['error_message'] = $message;
        $result['success'] = FALSE;
        return $result;
      }

Thanks

apotek’s picture

Thanks for the response. I'll grab the latest from CVS (though not HEAD this time :-) ) and grab your changes there.

Status: Fixed » Closed (fixed)

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