Bug 35536 introduced some better error handling, but made the return value more erratic. We you previously had code like this: ```perl my @plugins = Koha::Plugins->new()->GetPlugins( { method => 'ill_backend', metadata => { name => $backend_id }, all => 1, errors => 1 } ); foreach my $plugin (@plugins) { ... } ``` And now the new return value for GetPlugins is: ```perl return $errors ? ( \@plugins, \@failing ) : @plugins; ``` This means the caller will need to check the return value, and if the arity is two (?), check that the second element has some specific structure so we determine... it is not actually a plugin! I propose we return a hashref with the plugins and (possibly) the errors.
I have now noticed that the `errors => 1` from the original code was the one preventing it to work. So I'll lower the importance to enhancement, but want to propose a signature change here. For discussion.
Created attachment 163850 [details] [review] [POC] Bug 36419: Use wantarray to control return value Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Created attachment 163895 [details] [review] Bug 36419: Use wantarray to control return value Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Looks good to me!
Idea is fine with me, current implementation would fail. Should we only return this good, bad (and ugly) if the errors param was passed? Otherwise we will need to examine all calls of GetPlugins without errors => 1 too. Plugins.t fails on a call now with errors, expecting the old returns.
(In reply to Marcel de Rooy from comment #5) > Idea is fine with me, current implementation would fail. > Should we only return this good, bad (and ugly) if the errors param was > passed? > Otherwise we will need to examine all calls of GetPlugins without errors => > 1 too. > > Plugins.t fails on a call now with errors, expecting the old returns. Correct! I believe this patch is just a POC and not expected to fully function.