Not an ARRAY reference at /usr/local/share/perl/5.28.1/Catmandu/Fix.pm line 59.
/usr/local/share/perl/5.28.1/Catmandu/Fix.pm around line 59
56 my $fixes_arg = $self->_fixes;
57 my $fixes = [];
58
59 for my $fix (@$fixes_arg) {
60
61 if (is_code_ref($fix)) {
62 push @$fixes, require_package('Catmandu::Fix::code')->new($fix);
When i added use Data::Dumper; print STDERR Dumper($setting); after my $setting = hash_merge($s, \%opts);, I noticed that 'fix' had already been turned into an object:
so it seems like plugin_setting is modified in-place, and then kept when the file is reloaded (when using plackup -R), and I also got the problem with starman, which I don't think reloads file while running, but perhaps something with threads, I have no clue really, since I don't know the inner workings of starman at all.
Possible solutions
It does help to clone the object before making any modifications:
+use Clone 'clone';
sub sru_provider {
my ($path, %opts) = @_;
- my $setting = hash_merge(plugin_setting, \%opts);
+ my $setting = clone hash_merge(plugin_setting, \%opts);
But I'm not sure if this is considered a good approach? (Not sure if there could be risk for recursive references or something). Would it be cleaner to store the Catmandu Fix object in a new variable instead of modifying in-place?
Got this error:
despite
fix
being an array:When i added
use Data::Dumper; print STDERR Dumper($setting);
aftermy $setting = hash_merge($s, \%opts);
, I noticed that 'fix' had already been turned into an object:so it seems like
plugin_setting
is modified in-place, and then kept when the file is reloaded (when usingplackup -R
), and I also got the problem with starman, which I don't think reloads file while running, but perhaps something with threads, I have no clue really, since I don't know the inner workings of starman at all.Possible solutions
It does help to
clone
the object before making any modifications:But I'm not sure if this is considered a good approach? (Not sure if there could be risk for recursive references or something). Would it be cleaner to store the Catmandu Fix object in a new variable instead of modifying in-place?
Let me know what you think.