Bug 4461: Checks on library email before enqueuing letter
[koha.git] / misc / check_sysprefs.pl
blobce2e19e455bf91bbdc5908a1f2e4ba2c0e286119
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 Koha::Script;
14 use C4::Context;
16 @ARGV = qw(.) unless @ARGV;
18 sub check_sys_pref {
19 my $dbh = C4::Context->dbh();
20 my $query = "SELECT * FROM systempreferences WHERE variable = ?";
21 my $sth = $dbh->prepare($query);
22 if ( !-d _ ) {
23 my $name = $File::Find::name;
24 if ( $name =~ /(\.pl|\.pm)$/ ) {
25 open( FILE, "$_" ) || die "can't open $name";
26 while ( my $inp = <FILE> ) {
27 if ( $inp =~ /C4::Context->preference\((.*?)\)/ ) {
28 my $variable = $1;
29 $variable =~ s /\'|\"//g;
30 $sth->execute($variable);
31 if ( my $data = $sth->fetchrow_hashref() ) {
32 if ( $data->{variable} eq $variable ) {
33 next;
36 print
37 "$name has a reference to $variable, this does not exist in the database\n";
40 close FILE;
43 $sth->finish();
46 find( \&check_sys_pref, @ARGV );