Closed (fixed)
Project:
Webform
Version:
7.x-4.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
28 Apr 2014 at 20:11 UTC
Updated:
15 Mar 2015 at 21:01 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
liam morlandFix; also removes error suppression from fclose().
Comment #2
liam morlandComment #3
liam morlandIn this improved version, export functions always return something, making error handling easier.
Comment #4
quicksketchThanks Liam. Do you know exactly what happens when a BatchAPI function returns FALSE? Does that gracefully (relatively) abort the Batch operation?
Comment #5
liam morlandMost of those functions don't return anything right now, so this doesn't complete the project of nice error handling. It should avoid multiple error message for one problem. For example, if the fopen() fails, you get an error message for that. Then you get errors because the FALSE returned from fopen() is being used as if it was a file handle. With the patch, that won't happen.
Comment #6
liam morlandIf you are concerned about what happens when it returns false, it could return nothing. This would have the effect of having each error cause only one message instead of multiple.
Comment #7
danchadwick commentedSeems like this would be a ton easier with an exception handler, no?
Comment #8
liam morlandThat would be more elaborate. The current patch is supposed to just prevent multiple errors for one problem by stopping it from writing to non-existent file handles. It also removes some error suppression so that errors can be seen and fixed.
Comment #9
liam morlandHere is a simpler patch which just avoids the duplicate error messages. Currently if a file can't be opened, you get the error for that plus the error when it tries to write to the non-existent file handle. With this patch, you get the first error then the function returns.
Comment #11
danchadwick commentedI'm fine with this. Clearly we could do better. The error ends up in the Drupal log and the user gets an empty file, which isn't ideal. But better than having a million errors.
Thanks, Liam. Committed to 7.x-4.x and 8.x.
Comment #13
danchadwick commented