systopia / de.systopia.moregreetings

CiviCRM Extension for additional greetings
GNU Affero General Public License v3.0
4 stars 10 forks source link

Allow Smarty logic without generic fallback, error "Please enter valid smarty code." #9

Closed jensschuppe closed 2 years ago

jensschuppe commented 5 years ago

When a smarty logic returns an empty string, saving the moregreetings form is not allowed due to a "Please enter valid smarty code." error on the field.

An empty string should not be treated as an error.

jensschuppe commented 5 years ago

This is tricky, since Smarty 2 uses trigger_error() instead of throwing exceptions.

d36df5c101a3ce3c21ea016fd10e1be3294bfcc4 introduces a custom error handler which throws an exception to identify the Smarty error by inspecting the error message. The original error handler is then being called manually and restored from the error handler stack.

@systopia I'd like some thoughts on that approach.

jensschuppe commented 3 years ago

Will be released with 1.0