Bug 18066: Fix map positioning in admin/usage_statistics.pl
[koha.git] / misc / check_sysprefs.pl
blob91d007511eb47acaf4509feab431576100fa5473
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() ) {
31 if ( $data->{variable} eq $variable ) {
32 next;
35 print
36 "$name has a reference to $variable, this does not exist in the database\n";
39 close FILE;
42 $sth->finish();
45 find( \&check_sys_pref, @ARGV );