Bugzilla – Attachment 111428 Details for
Bug 26555
Add a way for Koha::Object(s) to carry execution information
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26555: Make sure _messages is always initialized
Bug-26555-Make-sure-messages-is-always-initialized.patch (text/plain), 2.02 KB, created by
Tomás Cohen Arazi (tcohen)
on 2020-10-09 17:54:21 UTC
(
hide
)
Description:
Bug 26555: Make sure _messages is always initialized
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2020-10-09 17:54:21 UTC
Size:
2.02 KB
patch
obsolete
>From b47efe894fad0fc3ef1abad1c5e05dcfbe1a3ee4 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 30 Sep 2020 09:42:18 -0300 >Subject: [PATCH] Bug 26555: Make sure _messages is always initialized > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/Object.pm | 4 ++++ > t/db_dependent/Koha/Object.t | 14 ++++++++++++-- > 2 files changed, 16 insertions(+), 2 deletions(-) > >diff --git a/Koha/Object.pm b/Koha/Object.pm >index da9315dcc87..57b1429b890 100644 >--- a/Koha/Object.pm >+++ b/Koha/Object.pm >@@ -345,6 +345,10 @@ Returns the (probably non-fatal) messages that were recorded on the object. > > sub messages { > my ( $self ) = @_; >+ >+ $self->{_messages} = [] >+ unless defined $self->{_messages}; >+ > return $self->{_messages}; > } > >diff --git a/t/db_dependent/Koha/Object.t b/t/db_dependent/Koha/Object.t >index 90315331133..b78283ce250 100755 >--- a/t/db_dependent/Koha/Object.t >+++ b/t/db_dependent/Koha/Object.t >@@ -870,7 +870,9 @@ subtest 'set_or_blank' => sub { > > subtest 'messages() and add_message() tests' => sub { > >- plan tests => 6; >+ plan tests => 7; >+ >+ $schema->storage->txn_begin; > > my $patron = Koha::Patron->new; > >@@ -886,5 +888,13 @@ subtest 'messages() and add_message() tests' => sub { > is( ref($messages[0]), 'Koha::Object::Message', 'Right type returned' ); > is( ref($messages[1]), 'Koha::Object::Message', 'Right type returned' ); > is( $messages[0]->message, 'message_1', 'Right message recorded' ); >- is( $messages[1]->message, 'message_2', 'Right message recorded' ); >+ >+ my $patron_id = $builder->build_object({ class => 'Koha::Patrons' })->id; >+ # get a patron from the DB, ->new is not called, ->messages should initialize _messages as an empty arrayref >+ $patron = Koha::Patrons->find( $patron_id ); >+ >+ isnt( $patron->messages, undef, '->messages initializes the array if required' ); >+ is( scalar @{ $patron->messages }, 0, '->messages returns an empty arrayref' ); >+ >+ $schema->storage->txn_rollback; > }; >-- >2.28.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 26555
:
110854
|
110855
|
110911
|
110912
|
110913
|
110957
|
110958
|
110959
|
110967
|
110968
|
110969
|
110983
|
111426
|
111427
| 111428 |
111723