Greek and NZ updates
[koha.git] / misc / check_sysprefs.pl
blob0d06fde9019196bf5d7555820c434902b02a7d7c
1 #!/usr/bin/perl
3 # script to test for missing systempreferences
4 # export KOHA_CONF
5 # export PERL5LIB
6 # then ./check_sysprefs.pl path (if path is blank it will use .)
8 use strict;
9 use warnings;
11 use File::Find;
13 use C4::Context;
15 @ARGV = qw(.) unless @ARGV;
17 sub check_sys_pref {
18 my $dbh = C4::Context->dbh();
19 my $query = "SELECT * FROM systempreferences WHERE variable = ?";
20 my $sth = $dbh->prepare($query);
21 if (! -d _ ){
22 my $name=$File::Find::name;
23 if ($name =~ /(\.pl|\.pm)$/){
24 open (FILE,"$_") || die "cant open $name";
25 while (my $inp = <FILE>){
26 if ($inp =~ /C4::Context->preference\((.*?)\)/){
27 my $variable = $1;
28 $variable =~s /\'|\"//g;
29 $sth->execute($variable);
30 if (my $data=$sth->fetchrow_hashref()){
32 else {
33 print "$name has a reference to $variable, this does not exist in the database\n";
37 close FILE;
40 $sth->finish();
43 find(\&check_sys_pref,@ARGV);