Script to check if system preferences exist in the code that dont exist in the database

Signed-off-by: Joshua Ferraro <jmf@liblime.com>
This commit is contained in:
Chris Cormack 2007-10-22 21:28:20 -05:00 committed by Joshua Ferraro
parent 53be8065d1
commit a21c4867a0
1 changed files with 39 additions and 0 deletions

39
check_sysprefs.pl Executable file
View File

@ -0,0 +1,39 @@
#!/usr/bin/perl
# script to test for missing systempreferences
# export KOHA_CONF
# export PERL5LIB
# then ./check_sysprefs.pl
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()){
}
else {
print "$name has a reference to $variable, this does not exist in the database\n";
}
}
}
close FILE;
}
}
$sth->finish();
}
find(\&check_sys_pref,@ARGV);