In Koha::EDI::transfer_items we do a branchcode comparison. Unfortunately, the comparison is called against a DBIx::Class relationship accessor instead of explicitly calling get_column to get the corresponding field value instead of a full fledged DBIx::Class::Result object. This can cause issues in proceedings.
Created attachment 124572 [details] [review] Bug 28960: Explicitly call get_column This patch adds get_column to ensure we are returning a string value of a field rather than accidentally triggering a relationship accessor.
Created attachment 124578 [details] [review] Bug 28960: Explicitly call get_column This patch adds get_column to ensure we are returning a string value of a field rather than accidentally triggering a relationship accessor. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Isn't the correct fix to call $item->home_branch->branchcode? From Koha::Item sub home_branch { my ($self) = @_; $self->{_home_branch} ||= Koha::Libraries->find( $self->homebranch() ); return $self->{_home_branch}; }
(In reply to Jonathan Druart from comment #3) > Isn't the correct fix to call $item->home_branch->branchcode? > > From Koha::Item > > sub home_branch { > my ($self) = @_; > > $self->{_home_branch} ||= Koha::Libraries->find( $self->homebranch() ); > > return $self->{_home_branch}; > } There are two things with that. 1) $item is a DBIx::Class::Result and not a Koha::Item in EDI (Yes, we should certainly convert to Koha Objects here at some point) 2) if all we need is the code, why call through another DB hitting accessor rather than use the field in the first set directly?
I hadn't realized we weren't manipulating a Koha::Object. And my remark was silly anyway as $item->branchcode is working if $item is a Koha::Item. Sorry for the noise.
:).. it's certainly on my list to switch over to objects.. but before that I need to blitz some tests.. why is EDI so darn hard!
Pushed to master for 21.11, thanks to everybody involved!
Pushed to 21.05.x for 21.05.x
Pushed to 20.11.x for 20.11.11
Backported: Pushed to 20.05.x branch for 20.05.17
Backported to 19.11.x for 19.11.23