http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11998 --- Comment #66 from Jacek Ablewicz <abl@biblos.pk.edu.pl> --- (In reply to Robin Sheat from comment #64)
Created attachment 33940 [details] [review] Bug 11998 - fix some compile warnings
This lazy-loads C4::Context and some other modules so that they can be be safely used by C4::Context without introducing problematic circular dependencies.
This approach may be somehow problematic IMO.. Looks like it relies on the unwritten assumption that 'use C4::Context' would be always used somewhere beforehand at least once - because if not, usually there will be no default/already existing context to rely upon. Currently, initial context is most often created & stored as default in the import() function in C4::Context (and typically only there ?). Take this part for example: --- a/Koha/Database.pm +++ a/Koha/Database.pm @@ -34,7 +34,6 @@ Koha::Database use Modern::Perl; use Carp; -use C4::Context; use Koha::Schema; use base qw(Class::Accessor); @@ -46,6 +45,7 @@ __PACKAGE__->mk_accessors(qw( )); # returns it. sub _new_schema { + require C4::Context; my $context = C4::Context->new(); with it applied, some simple code chunks like that: use Koha::Database; my $scnt = Koha::Database->new()->schema()->resultset('Subscription')->count(); would fail ("... Can't call method "config" on unblessed reference at /home/koha/devkohaclone/C4/Context.pm line 780"). It's possible that this particular issue is being addressed in some other patch[es] belonging to this bug report, but it's hard to say for sure, as the whole patch set does not apply on the current master at the moment. -- You are receiving this mail because: You are watching all bug changes.