Bugzilla – Attachment 104537 Details for
Bug 23185
Koha::Objects supports passing through 'update' which means we can side step 'set' + 'store'
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23185: ->update can only be called on instantiated classes
Bug-23185--update-can-only-be-called-on-instantiat.patch (text/plain), 2.47 KB, created by
Tomás Cohen Arazi (tcohen)
on 2020-05-07 21:30:16 UTC
(
hide
)
Description:
Bug 23185: ->update can only be called on instantiated classes
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2020-05-07 21:30:16 UTC
Size:
2.47 KB
patch
obsolete
>From fdea245e991aca4ca3ddad9d1a15d511e427fc0a Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 7 May 2020 18:05:29 -0300 >Subject: [PATCH] Bug 23185: ->update can only be called on instantiated > classes > >Since our use ok Koha::Objects, there's been an implicit instantiation >happening in ->search that has somehow hidden the fact that classes need >instantiation... > >This change in ->delete and ->update made it clear because of the >failures/hangs on the tests. > >This patch instantiates Koha::Patron::Categories before attempting to >call ->update. > >The original patches for this bug are correct and the only issue here is >that we need to document better than for some methods, instantiation is >not implicit and is required first. This is awkward and I would prefer >to force everyone to call ->new first. But I understand it would be >inconvenient. > >To test: >1. Run: > $ kshell > k$ prove t/db_dependent/Template/Plugin/Categories.t >=> FAIL: Notice it hangs, Ctrl+c to abort >2. Apply this patch >3. Repeat 1 >=> SUCCESS: Tests dong hang, and in fact pass >4. Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/Objects.pm | 3 ++- > t/db_dependent/Template/Plugin/Categories.t | 2 +- > 2 files changed, 3 insertions(+), 2 deletions(-) > >diff --git a/Koha/Objects.pm b/Koha/Objects.pm >index 6a272cf6a4..c19ced53c1 100644 >--- a/Koha/Objects.pm >+++ b/Koha/Objects.pm >@@ -196,7 +196,8 @@ sub delete { > > =head3 update > >- $object->update( $fields, [ { no_triggers => 0/1 } ] ); >+ my $objects = Koha::Objects->new; # or Koha::Objects->search >+ $objects->update( $fields, [ { no_triggers => 0/1 } ] ); > > This method overloads the DBIC inherited one so if code-level triggers exist > (through the use of an overloaded I<update> or I<store> method in the Koha::Object >diff --git a/t/db_dependent/Template/Plugin/Categories.t b/t/db_dependent/Template/Plugin/Categories.t >index 93384deda4..b6080c7519 100644 >--- a/t/db_dependent/Template/Plugin/Categories.t >+++ b/t/db_dependent/Template/Plugin/Categories.t >@@ -65,7 +65,7 @@ subtest 'can_any_reset_password() tests' => sub { > $schema->storage->txn_begin; > > # Make sure all existing categories have reset_password set to 0 >- Koha::Patron::Categories->update({ reset_password => 0 }); >+ Koha::Patron::Categories->search->update({ reset_password => 0 }); > > ok( !Koha::Template::Plugin::Categories->new->can_any_reset_password, 'No category is allowed to reset password' ); > >-- >2.26.2
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 23185
:
103867
|
103868
|
103946
|
103947
|
104087
|
104088
|
104089
|
104232
|
104233
|
104234
|
104271
|
104272
|
104273
|
104276
| 104537 |
104538
|
104541