From a21c4867a04ab8ecefffc053826aa2e097ea7bb0 Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Mon, 22 Oct 2007 21:28:20 -0500 Subject: [PATCH] Script to check if system preferences exist in the code that dont exist in the database Signed-off-by: Joshua Ferraro --- check_sysprefs.pl | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 check_sysprefs.pl diff --git a/check_sysprefs.pl b/check_sysprefs.pl new file mode 100755 index 0000000000..15c2c48f81 --- /dev/null +++ b/check_sysprefs.pl @@ -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 = ){ + 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); -- 2.39.5