Bugzilla – Attachment 185995 Details for
Bug 39190
Rework new (S)FTP classes to be polymorphic classes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39190: Fix polymorphic object creation in Koha::Objects
Bug-39190-Fix-polymorphic-object-creation-in-KohaO.patch (text/plain), 2.27 KB, created by
Tomás Cohen Arazi (tcohen)
on 2025-08-30 15:35:49 UTC
(
hide
)
Description:
Bug 39190: Fix polymorphic object creation in Koha::Objects
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2025-08-30 15:35:49 UTC
Size:
2.27 KB
patch
obsolete
>From 8f3c6f83bc97dd29287c55263c5a7aa7172b61dd Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Sat, 30 Aug 2025 11:49:28 -0300 >Subject: [PATCH] Bug 39190: Fix polymorphic object creation in Koha::Objects > >This patch fixes polymorphic object creation by ensuring all methods >in Koha::Objects that instantiate objects pass the DBIC result to >the object_class() method for proper polymorphic resolution. > >Fixed methods: >- find(): Now passes $result to object_class($result) >- next(): Now passes $result to object_class($result) >- _wrap(): Now passes $_ to object_class($_) in map > >This enables polymorphic classes like Koha::File::Transports to return >the correct subclass (Koha::File::Transport::SFTP, Koha::File::Transport::FTP) >based on the transport field value, instead of always returning the >base Koha::File::Transport class. > >To test: >1. Apply the regression tests patch >2. Run: > $ ktd --shell > k$ prove t/db_dependent/Koha/File/Transports.t \ > t/db_dependent/Koha/File/Transport/SFTP.t >=> FAIL: Tests fail! >3. Apply this patch >4. Repeat 2 >=> SUCCESS: Tests pass! >5. Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/Objects.pm | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > >diff --git a/Koha/Objects.pm b/Koha/Objects.pm >index 405e6a76679..8bb9c856eb2 100644 >--- a/Koha/Objects.pm >+++ b/Koha/Objects.pm >@@ -94,7 +94,7 @@ sub find { > unless ( !@pars || none { defined($_) } @pars ) { > my $result = $self->_resultset()->find(@pars); > if ($result) { >- $object = $self->object_class()->_new_from_dbic($result); >+ $object = $self->object_class($result)->_new_from_dbic($result); > } > } > >@@ -319,7 +319,7 @@ sub next { > my $result = $self->_resultset()->next(); > return unless $result; > >- my $object = $self->object_class()->_new_from_dbic($result); >+ my $object = $self->object_class($result)->_new_from_dbic($result); > > return $object; > } >@@ -507,7 +507,7 @@ wraps the DBIC object in a corresponding Koha object > sub _wrap { > my ( $self, @dbic_rows ) = @_; > >- my @objects = map { $self->object_class->_new_from_dbic($_) } @dbic_rows; >+ my @objects = map { $self->object_class($_)->_new_from_dbic($_) } @dbic_rows; > > return @objects; > } >-- >2.51.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 39190
:
178555
|
178556
|
178557
|
178558
|
178559
|
178560
|
178561
|
178562
|
178563
|
178564
|
178565
|
178566
|
178567
|
178568
|
178569
|
178570
|
178571
|
179252
|
179253
|
179254
|
179255
|
179256
|
179257
|
179258
|
179259
|
179260
|
179261
|
179262
|
179263
|
179264
|
179265
|
179266
|
179267
|
179268
|
179396
|
179397
|
179398
|
179399
|
179400
|
179401
|
179402
|
179403
|
179404
|
179405
|
179406
|
179407
|
179408
|
179409
|
179410
|
179411
|
179412
|
179413
|
179589
|
179590
|
179591
|
179592
|
179593
|
179594
|
179595
|
179596
|
179597
|
179598
|
179599
|
179600
|
179601
|
179602
|
179603
|
179604
|
179605
|
179606
|
179646
|
179647
|
179648
|
179649
|
179650
|
179651
|
179652
|
179653
|
179654
|
179655
|
179656
|
179657
|
179658
|
179659
|
179660
|
179661
|
179662
|
179663
|
179992
|
179993
|
179994
|
179995
|
179996
|
179997
|
179998
|
179999
|
180000
|
180001
|
180002
|
180003
|
180004
|
180005
|
180006
|
180010
|
180011
|
180012
|
180013
|
180014
|
180015
|
180016
|
180017
|
180018
|
180019
|
180020
|
180021
|
180022
|
180023
|
180024
|
180025
|
185014
|
185015
|
185016
|
185017
|
185018
|
185019
|
185020
|
185021
|
185022
|
185023
|
185024
|
185025
|
185026
|
185027
|
185028
|
185029
|
185972
|
185973
|
185974
|
185975
|
185976
|
185977
|
185978
|
185979
|
185980
|
185981
|
185982
|
185983
|
185984
|
185985
|
185986
|
185987
|
185988
|
185989
|
185990
|
185994
| 185995 |
185996
|
185997
|
185998