Koha/misc/check_sysprefs.pl
Henri-Damien LAURENT 641616ef7f MT3289 : check_sysprefs.pl case sensitive variable names
Variable names for systempreferences are now case sensitive.
Changing check_sysprefs in relation with this change

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
2011-03-31 15:23:24 +13:00

45 lines
1.2 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 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 "cant 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 );