Bugzilla – Attachment 140187 Details for
Bug 31517
C4::Tags should use Koha::Tags objects instead of raw SQL
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31517: Replace raw SQL queries in C4::Tags with Koha object accesses
Bug-31517-Replace-raw-SQL-queries-in-C4Tags-with-K.patch (text/plain), 2.77 KB, created by
Joonas Kylmälä
on 2022-09-02 20:48:14 UTC
(
hide
)
Description:
Bug 31517: Replace raw SQL queries in C4::Tags with Koha object accesses
Filename:
MIME Type:
Creator:
Joonas Kylmälä
Created:
2022-09-02 20:48:14 UTC
Size:
2.77 KB
patch
obsolete
>From e9d4f516a9e15569258adbec79c63613bbea27e5 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Joonas=20Kylm=C3=A4l=C3=A4?= <joonas.kylmala@iki.fi> >Date: Fri, 2 Sep 2022 22:56:12 +0300 >Subject: [PATCH] Bug 31517: Replace raw SQL queries in C4::Tags with Koha > object accesses > >To test: > 1) Create a few new tags to any biblio by visiting the biblio's detail > page on OPAC > 2) The visit http://localhost:8080/cgi-bin/koha/opac-tags.pl and try > deleting those tags. >--- > C4/Tags.pm | 40 ++++++---------------------------------- > 1 file changed, 6 insertions(+), 34 deletions(-) > >diff --git a/C4/Tags.pm b/C4/Tags.pm >index e01244f927..1df1a5524e 100644 >--- a/C4/Tags.pm >+++ b/C4/Tags.pm >@@ -25,6 +25,9 @@ use Exporter; > > use C4::Context; > use Module::Load::Conditional qw( check_install ); >+use Koha::Tags; >+use Koha::Tags::Approvals; >+use Koha::Tags::Indexes; > #use Data::Dumper; > use constant TAG_FIELDS => qw(tag_id borrowernumber biblionumber term language date_created); > use constant TAG_SELECT => "SELECT " . join(',', TAG_FIELDS) . "\n FROM tags_all\n"; >@@ -38,9 +41,7 @@ BEGIN { > add_tag > add_tag_approval > add_tag_index >- delete_tag_row_by_id > remove_tag >- delete_tag_rows_by_ids > get_approval_rows > blacklist > whitelist >@@ -126,45 +127,16 @@ sub remove_tag { > my $tags = get_tags({term=>$row->{term}, biblionumber=>$row->{biblionumber}}); > my $index = shift(@$tags); > if ($index->{weight} <= 1) { >- delete_tag_index($row->{term},$row->{biblionumber}); >+ Koha::Tags::Indexes->search({ term => $row->{term}, biblionumber => $row->{biblionumber} })->delete; > } else { > decrement_weight($row->{term},$row->{biblionumber}); > } > if ($index->{weight_total} <= 1) { >- delete_tag_approval($row->{term}); >+ Koha::Tags::Approvals->search({ term => $row->{term} })->delete; > } else { > decrement_weight_total($row->{term}); > } >- delete_tag_row_by_id($tag_id); >-} >- >-sub delete_tag_index { >- (@_) or return; >- my $sth = C4::Context->dbh->prepare("DELETE FROM tags_index WHERE term = ? AND biblionumber = ? LIMIT 1"); >- $sth->execute(@_); >- return $sth->rows || 0; >-} >-sub delete_tag_approval { >- (@_) or return; >- my $sth = C4::Context->dbh->prepare("DELETE FROM tags_approval WHERE term = ? LIMIT 1"); >- $sth->execute(shift); >- return $sth->rows || 0; >-} >-sub delete_tag_row_by_id { >- (@_) or return; >- my $sth = C4::Context->dbh->prepare("DELETE FROM tags_all WHERE tag_id = ? LIMIT 1"); >- $sth->execute(shift); >- return $sth->rows || 0; >-} >-sub delete_tag_rows_by_ids { >- (@_) or return; >- my $i=0; >- foreach(@_) { >- $i += delete_tag_row_by_id($_); >- } >- ($i == scalar(@_)) or >- warn sprintf "delete_tag_rows_by_ids tried %s tag_ids, only succeeded on $i", scalar(@_); >- return $i; >+ Koha::Tags->search({ tag_id => $tag_id })->delete; > } > > sub get_tag_rows { >-- >2.30.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 31517
:
140187
|
140188
|
142847
|
142848
|
143046
|
143047
|
143048