I have this code:
my $variable = $c->forward(qw/Curate::Controller::Utils _get_timestamp/);
$c->log->debug("variable is now $variable");
And the _get_timestamp
looks like this:
sub _get_timestamp :Private {
my ( $self, $c, $arg ) = @_;
my $current_timestamp = "0000-00-00 00:00:00";
my $coderef = sub {
my $sth = $c->model('DB')->storage->dbh->prepare('SELECT CURRENT_TIMESTAMP')
|| die "Couldn't prepare statement: " . $c->model('DB')->storage->dbh->errstr;
$sth->execute || die "Couldn't execute statement: " . $sth->errstr;
$current_timestamp = $sth->fetchrow_array;
};
try {
$c->model('DB')->schema->txn_do($coderef);
} catch {
$c->stash->{error} = "$_";
};
$c->log->debug("returning $current_timestamp");
return $current_timestamp;
}
When I run this code in the logs I can see:
returning 2017-06-29 12:34:23
variable is now
I don't understand why the variable did not get assigned to the value returned by the forwarded function. This code works correctly with the old version of Catalyst. I am having this issued with the latest one downloaded from CPAN. Are you aware about any changes in forwarding protocol?
BTW: I know I can stash the result but a direct assignment seems more natural in this case.