Bug 2505 - Add commented use warnings where missing in the misc/ directory
[koha.git] / misc / check_sysprefs.pl
1 #!/usr/bin/perl
2
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 .)
7
8 #use strict;
9 #use warnings; FIXME - Bug 2505
10
11 use File::Find;
12 use C4::Context;
13
14 @ARGV = qw(.) unless @ARGV;
15
16 sub check_sys_pref {
17         my $dbh = C4::Context->dbh();
18         my $query = "SELECT * FROM systempreferences WHERE variable = ?";
19         my $sth = $dbh->prepare($query);        
20         if (! -d _ ){
21                 my $name=$File::Find::name;
22                 if ($name =~ /(\.pl|\.pm)$/){
23                         open (FILE,"$_") || die "cant open $name";
24                         while (my $inp = <FILE>){
25                                 if ($inp =~ /C4::Context->preference\((.*?)\)/){
26                                         my $variable = $1;
27                                         $variable =~s /\'|\"//g;
28                                         $sth->execute($variable);
29                                         if (my $data=$sth->fetchrow_hashref()){
30                                         }
31                                         else {
32                                                 print "$name has a reference to $variable, this does not exist in the database\n";
33                                         }
34                                 }
35                         }
36                         close FILE;
37                 }
38         }
39         $sth->finish();
40 }
41         
42 find(\&check_sys_pref,@ARGV);