Commit graph

14 commits

Author SHA1 Message Date
Juerd Waalboer
6b04ecc256 undo: deal with checkout exception
The ancient decision to let undo perform the checkout by itself still
makes sense from a UX perspective, but keeps requiring specific handling
of edge cases.

In this case, the easiest way to deal with trailing input is to just
abort entirely.

Also: updated lib/RevBank/Plugins.pm to import 'isa' and get up to 5.32
level.
2023-12-26 02:08:24 +01:00
Juerd Waalboer
3470ebeb1c Explicitly use Perl 5.32
Was already implicitly required (since 59387ddb) because RevBank::Amount
uses the "isa" feature, which was introduced in Perl 5.32 (but no longer
experimental since 5.36, not 5.32 as the old comment said).

Perl 5.32 was released in June 2020, and ships with Debian bullseye
("oldstable") which was released in August 2021.
2023-12-12 00:28:17 +01:00
Juerd Waalboer
52749df5f3 Ignore all hook exceptions except in hook_checkout_prepare
A space had a custom plugin that died during hook_checkout, which caused
the CHECKOUT lines to be logged without the corresponding BALANCE, and
indeed no account balances were updated. While the plugin had a bug, it
should not cause a half transaction in RevBank.

After some hesitation, I went with ON ERROR RESUME NEXT because if a
hook throws an exception, that should not interfere with other plugins
(the hook can return ABORT if this it was intentional), including the
calling plugin. An error message is printed (but not logged... TODO: add
hook_plugin_fail to plugins/log) but the show must go on.

During hook_checkout_prepare, however, nothing is set in stone yet, so
this could be used for something that might die, and this instance of
call_hooks() is now the one place where a failing hook should result in
the transaction getting aborted. For this, call_hooks() now returns a
success status boolean. Maybe it would make sense in more places, but I
didn't identify any such calls yet.

RevBank::Cart->checkout used to return a success status boolean, but it
could just as well just die (indirectly, to abort the transaction) since
it can't be called a second time within the same transaction anyway
(because ->set_user must be called exactly once), so continuing with the
same transaction can't result in anything useful anyway.

In some places, error messages were slightly improved to contain a bit
more information.
2023-11-24 05:15:22 +01:00
Juerd Waalboer
59387ddba4 Use formerly experimental Perl features with "use experimental"
This is semantically equivalent to use feature + no warnings, but less
noisy. I've also added comments to indicate when the line can be
removed.
2023-09-10 02:13:33 +02:00
Juerd Waalboer
16d530ae16 Allow hook_prompt to mutate the prompt, like before, and use that
This functionality was accidentally broken by eed0db78

Also: ignore readline terminal sequence (\x01...\x02) in detection of ">"
2023-01-19 03:04:35 +01:00
Juerd Waalboer
5b0c85d770 Refactor read_products and its callers
- Promote to public function since it's used in other plugins anyway
- Move resolving of addons to read_products (print errors immediately)
- Cache product list based on mtime; mostly to reduce the amount of spam
  from errors as performance was never an issue.
- Cache product object in cart entry, so statiegeld_tokens plugin
  doesn't have to do the lookup all over again.
2023-01-17 20:28:35 +01:00
Juerd Waalboer
094fbcb1db Fix bug/warning
Apparently nobody uses "return ABORT;" in a hook, because it emitted an
ugly warning. main::abort() takes a list, so destructuring the message
to a scalar was wrong.
2023-01-16 00:51:42 +01:00
Juerd Waalboer
a444512bf1 Enable Perl warnings for plugins 2022-12-25 05:39:15 +01:00
Juerd Waalboer
f262bce57c Split "help" into "help" and "help2"; ditch pager 2022-06-11 16:31:44 +02:00
Juerd Waalboer
eed0db7897 Cleanup: use subroutine signatures, remove deprecated methods.
The signatures feature has been "experimental" since Perl 5.20 (May 2014), but
expected to stay. After 8 years I'm ready to take the risk :)

Have added Perl v5.28 (June 2018) as the minimum requirement, even though the
current revbank should work with 5.20, to see if this bothers any users. Perl
v5.28 is in Debian "buster", which is now oldstable.
2021-12-03 18:00:34 +01:00
Juerd Waalboer
c5c48dcd2c Split POD 2018-03-04 16:36:20 +01:00
Juerd Waalboer
4ad7129805 New hook: checkout_done 2017-05-10 22:08:33 +02:00
Juerd Waalboer
add3100401 New plugin: repeat (undocumented), new hook: "added" 2017-02-19 00:41:20 +01:00
Juerd Waalboer
b0ee7e88bf cwd is no longer in @INC in new perl versions 2017-02-18 22:31:19 +01:00
Renamed from RevBank/Plugins.pm (Browse further)