[Koha-bugs] [Bug 26652] New: Add a way to mark messages as 'seen' in Koha::Object

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Fri Oct 9 20:07:35 CEST 2020


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26652

            Bug ID: 26652
           Summary: Add a way to mark messages as 'seen' in Koha::Object
 Change sponsored?: ---
           Product: Koha
           Version: master
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P5 - low
         Component: Architecture, internals, and plumbing
          Assignee: koha-bugs at lists.koha-community.org
          Reporter: tomascohen at gmail.com
        QA Contact: testopia at bugs.koha-community.org

Bug 26555 adds a way for Koha::Object-derived classes to carry errors messages
between method calls. On bug 26651 there's a proposal for a
Koha::Object->reset_messages method that *could* be used to clean that messages
list, if required.

Another option could be to have Koha::Object::Message carry some flag (seen?)
that tells if the message has already been looked at. So if ->messages is
called twice, the second one returns no results as all messages have been
marked as seen:

=head3 messages

    $object->methods
           ->that
           ->each
           ->adds
           ->messages;
    @messages = $object->messages; # all accumulated messages
    @messages = $object->messages; # @messages is empty
    $object->boo;
    @messages = $object->messages; # @messages contains messages added by ->boo

The implementation could look like:

=cut

sub messages {
    my ($self) = @_;

    my @messages = map { $_->mark_as_seen } @{ grep { $_->unseen } @{
$self->messages } };
    return \@messages;
}


package Koha::Object::Message;

sub mark_as_seen {
    my ($self) = @_;
    $self->{seen} = 1;
    return $self;
}


A method for retrieving all messages in the object lifetime could be added.

I put this here for discussing it, and just in case someone is looking for
something like this and finds this bug, adding their two cents here with their
use cases.

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.


More information about the Koha-bugs mailing list