Koha/misc/check_sysprefs.pl
Martin Renvoize d2e189ca1c Bug 22600: Set 'commandline' interface appropriately
This patch change Koha::Cron to be a more generic Koha::Script class and
update all commanline driven scripts to use it.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2019-04-10 19:43:11 +00:00

46 lines
1.3 KiB
Perl
Executable file

#!/usr/bin/perl
# script to test for missing systempreferences
# export KOHA_CONF
# export PERL5LIB
# then ./check_sysprefs.pl path (if path is blank it will use .)
use strict;
use warnings;
use File::Find;
use Koha::Script;
use C4::Context;
@ARGV = qw(.) unless @ARGV;
sub check_sys_pref {
my $dbh = C4::Context->dbh();
my $query = "SELECT * FROM systempreferences WHERE variable = ?";
my $sth = $dbh->prepare($query);
if ( !-d _ ) {
my $name = $File::Find::name;
if ( $name =~ /(\.pl|\.pm)$/ ) {
open( FILE, "$_" ) || die "can't open $name";
while ( my $inp = <FILE> ) {
if ( $inp =~ /C4::Context->preference\((.*?)\)/ ) {
my $variable = $1;
$variable =~ s /\'|\"//g;
$sth->execute($variable);
if ( my $data = $sth->fetchrow_hashref() ) {
if ( $data->{variable} eq $variable ) {
next;
}
}
print
"$name has a reference to $variable, this does not exist in the database\n";
}
}
close FILE;
}
}
$sth->finish();
}
find( \&check_sys_pref, @ARGV );