Koha-clms/Koha/Library
Jonathan Druart a06def460f Bug 32894: Remove wrong caching from Koha:: methods - simple
In some of our Koha:: objects we have methods that cache their result and return it in subsequent calls. However there is no invalidation of the cache if the object is modified.

For instance, in Koha/ArticleRequest.pm

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

    $self->{_biblio} ||= Koha::Biblios->find( $self->biblionumber() );

    return $self->{_biblio};
}

This pattern exists in several places.

It can lead to confusion and incorrect results, such as:

use Koha::ArticleRequests;
my $ar = Koha::ArticleRequest->new({
    borrowernumber => 42,
    biblionumber => 42,
})->store;
say $ar->biblio->biblionumber;               # Display 42, correct
$ar->set({ biblionumber => 24 })->store;
say $ar->biblio->biblionumber;               # Display 42, wrong
$ar->discard_changes;
say $ar->biblio->biblionumber;               # Display 42, wrong
$ar->delete;

We should remove those caching and rely on DBIC/DBMS caching mechanism instead.

This patch is adjusting the trivial occurrences

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
(cherry picked from commit 68216c541b)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
(cherry picked from commit 3347e66824)
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
2023-07-12 09:10:16 +00:00
..
Group.pm Bug 32894: Remove wrong caching from Koha:: methods - simple 2023-07-12 09:10:16 +00:00
Groups.pm Bug 29922: Make get_search_groups return results sorted by title 2022-07-18 15:11:35 -03:00
OverDriveInfo.pm Bug 17600: Standardize our EXPORT_OK 2021-07-16 08:58:47 +02:00
OverDriveInfos.pm Bug 17600: Standardize our EXPORT_OK 2021-07-16 08:58:47 +02:00