Bugzilla – Attachment 149267 Details for
Bug 32334
Sync comments in database with schema
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32334: (QA follow-up) Improve finding schema file
Bug-32334-QA-follow-up-Improve-finding-schema-file.patch (text/plain), 3.79 KB, created by
Jonathan Druart
on 2023-04-07 11:49:22 UTC
(
hide
)
Description:
Bug 32334: (QA follow-up) Improve finding schema file
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2023-04-07 11:49:22 UTC
Size:
3.79 KB
patch
obsolete
>From 44e669f55ae2e584e265470194926128d0614fae Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Wed, 15 Feb 2023 15:54:37 +0000 >Subject: [PATCH] Bug 32334: (QA follow-up) Improve finding schema file > >Adds a schema parameter to the cmdline script now too. > >Test plan: >Run sync_db_comments.pl with -schema file where file does not exist. >(On dev install) rename kohastructure.sql, try with[out] referring >to it using -schema. You could also use the standard path >intranet/cgi-bin/installer/data/mysql. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Signed-off-by: David Nind <david@davidnind.com> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > Koha/Database/Commenter.pm | 17 +++++++++++++++-- > misc/maintenance/sync_db_comments.pl | 7 +++++-- > 2 files changed, 20 insertions(+), 4 deletions(-) > >diff --git a/Koha/Database/Commenter.pm b/Koha/Database/Commenter.pm >index 9d4959e0ea6..9ce562ff947 100644 >--- a/Koha/Database/Commenter.pm >+++ b/Koha/Database/Commenter.pm >@@ -20,6 +20,7 @@ package Koha::Database::Commenter; > use Modern::Perl; > use File::Slurp qw(read_file); > >+use C4::Context; > use Koha::Exceptions; > > use constant KOHA_STRUCTURE => 'installer/data/mysql/kohastructure.sql'; >@@ -76,7 +77,7 @@ sub new { > unless ref($self->{dbh}) eq DBI_HANDLE_CLASS; > > $self->{database} //= ( $self->{dbh}->selectrow_array('SELECT DATABASE()') )[0]; >- $self->{schema_file} //= KOHA_STRUCTURE; >+ $self->_find_schema unless $self->{schema_file}; > $self->{schema_info} = {}; > > return $self; >@@ -151,8 +152,20 @@ sub renumber { > > =head1 INTERNAL ROUTINES > >+=head2 _find_schema >+ > =cut > >+sub _find_schema { >+ my $self = shift; >+ my $rootdir = C4::Context->config('intranetdir'); >+ if( -e "$rootdir/". KOHA_STRUCTURE ) { >+ $self->{schema_file} = "$rootdir/". KOHA_STRUCTURE; >+ } elsif( -e "$rootdir/intranet/cgi-bin/". KOHA_STRUCTURE ) { >+ $self->{schema_file} = "$rootdir/intranet/cgi-bin/". KOHA_STRUCTURE; >+ } >+} >+ > =head2 _fetch_schema_comments > > =cut >@@ -161,7 +174,7 @@ sub _fetch_schema_comments { > # Wish we had a DBIC function for this, showing comments too ;) Now using kohastructure as source of truth. > my ( $self ) = @_; > my $file = $self->{schema_file}; >- Koha::Exceptions::FileNotFound->throw( filename => $file ) unless -e $file; >+ Koha::Exceptions::FileNotFound->throw( filename => $file ) unless $file && -e $file; > > return $self->{schema_info} if keys %{$self->{schema_info}}; > >diff --git a/misc/maintenance/sync_db_comments.pl b/misc/maintenance/sync_db_comments.pl >index 5014c4ac680..07ee001cb63 100755 >--- a/misc/maintenance/sync_db_comments.pl >+++ b/misc/maintenance/sync_db_comments.pl >@@ -36,12 +36,15 @@ GetOptions( > 'help|h' => \$cmd_args->{help}, > 'renumber' => \$cmd_args->{renumber}, > 'reset' => \$cmd_args->{reset}, >+ 'schema:s' => \$cmd_args->{schema}, > 'table:s' => \$cmd_args->{table}, > 'verbose|v' => \$cmd_args->{verbose}, > ); > $cmd_args->{dry_run} = !$cmd_args->{commit}; > >-my $commenter = Koha::Database::Commenter->new({ database => delete $cmd_args->{database}, dbh => C4::Context->dbh }); >+my $commenter = Koha::Database::Commenter->new({ >+ database => delete $cmd_args->{database}, dbh => C4::Context->dbh, schema_file => delete $cmd_args->{schema}, >+}); > my $messages = $cmd_args->{verbose} || $cmd_args->{dry_run} ? [] : undef; > if( $cmd_args->{help} ) { > pod2usage( -verbose => 2 ); >@@ -71,7 +74,7 @@ misc/maintenance/sync_db_comments.pl > > =head1 SYNOPSIS > >- perl sync_db_comments.pl [-h] [-v] [-database DB_NAME] [-table TABLE_NAME] [-commit] [-clear|-reset|-renumber] >+ perl sync_db_comments.pl [-h] [-v] [-schema FILE ] [-database DB_NAME] [-table TABLE_NAME] [-commit] [-clear|-reset|-renumber] > > =head1 DESCRIPTION > >-- >2.25.1
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 32334
:
144391
|
144392
|
144393
|
144394
|
146712
|
146713
|
146714
|
146715
|
146716
|
146717
|
146718
|
146719
|
146720
|
148266
|
148299
|
148335
|
148338
|
148339
|
148340
|
148341
|
148342
|
148343
|
148344
|
148345
|
148346
|
148347
|
148348
|
149259
|
149260
|
149261
|
149262
|
149263
|
149264
|
149265
|
149266
| 149267 |
149268
|
149269
|
149270