Bugzilla – Attachment 103937 Details for
Bug 25296
Add a way to force an empty Koha::Objects resultset
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25296: Make ->empty work for uninstantiated calls
Bug-25296-Make--empty-work-for-uninstantiated-call.patch (text/plain), 1.34 KB, created by
Jonathan Druart
on 2020-04-29 13:09:43 UTC
(
hide
)
Description:
Bug 25296: Make ->empty work for uninstantiated calls
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-04-29 13:09:43 UTC
Size:
1.34 KB
patch
obsolete
>From f4686759071cf8f6ccbfc3e02a4b76ba379c6556 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 29 Apr 2020 09:28:04 -0300 >Subject: [PATCH] Bug 25296: Make ->empty work for uninstantiated calls > >In OO we would usually instantiate the class and then interact with it >like in: > my $rs = Koha::Patrons->new; > $rs->empty; > >Koha's practice is to call things like Koha::Patrons->search without >instantiating the Koha::Patrons class. To keep consistency, this patch >instantiates the resultset object on behalf of the caller if required. > >To test: >1. Apply the tests patch >2. Run: > $ kshell > $k prove t/db_dependent/Koha/Objects.t >=> FAIL: Tests fail because it is expected to have the class >instantiated >3. Apply this patch >4. Repeat 2. >=> SUCCESS: Tests pass, instantiation happens implicitly. >5. Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > Koha/Objects.pm | 4 ++++ > 1 file changed, 4 insertions(+) > >diff --git a/Koha/Objects.pm b/Koha/Objects.pm >index bc82ee4e15..91869ec9a3 100644 >--- a/Koha/Objects.pm >+++ b/Koha/Objects.pm >@@ -250,6 +250,10 @@ an iterator). > sub empty { > my ($self) = @_; > >+ unless (ref($self)) { >+ $self = $self->new; >+ } >+ > $self->_resultset()->set_cache([]); > > return $self; >-- >2.20.1
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 25296
:
103811
|
103812
|
103860
|
103861
|
103928
|
103929
|
103934
|
103935
|
103936
| 103937