[Koha-cvs] koha/C4 Context.pm [rel_3_0]

Henri-Damien LAURENT laurenthdl at alinto.com
Fri Feb 9 18:17:56 CET 2007


CVSROOT:	/cvsroot/koha
Module name:	koha
Branch:		rel_3_0
Changes by:	Henri-Damien LAURENT <hdl>	07/02/09 17:17:56

Modified files:
	C4             : Context.pm 

Log message:
	Managing a little better database absence.
	(preventing from BIG 550)

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Context.pm?cvsroot=koha&only_with_tag=rel_3_0&r1=1.43.2.9&r2=1.43.2.10

Patches:
Index: Context.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Context.pm,v
retrieving revision 1.43.2.9
retrieving revision 1.43.2.10
diff -u -b -r1.43.2.9 -r1.43.2.10
--- Context.pm	20 Dec 2006 16:50:48 -0000	1.43.2.9
+++ Context.pm	9 Feb 2007 17:17:56 -0000	1.43.2.10
@@ -16,7 +16,7 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-# $Id: Context.pm,v 1.43.2.9 2006/12/20 16:50:48 tipaul Exp $
+# $Id: Context.pm,v 1.43.2.10 2007/02/09 17:17:56 hdl Exp $
 use strict;
 use DBI;
 use ZOOM;
@@ -28,7 +28,7 @@
     qw($context),
     qw(@context_stack);
 
-$VERSION = do { my @v = '$Revision: 1.43.2.9 $' =~ /\d+/g;
+$VERSION = do { my @v = '$Revision: 1.43.2.10 $' =~ /\d+/g;
         shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); };
 
 =head1 NAME
@@ -372,6 +372,7 @@
     my $var = shift;        # The system preference to return
     my $retval;            # Return value
     my $dbh = C4::Context->dbh;    # Database handle
+    if ($dbh){
     my $sth;            # Database query handle
 
     # Look up systempreferences.variable==$var
@@ -382,6 +383,9 @@
         LIMIT    1
 EOT
     return $retval;
+    } else {
+      return 0
+    }
 }
 
 sub boolean_preference ($) {
@@ -439,7 +443,7 @@
         return $context->{"Zconn"}->{$server};
 
     # No connection object or it died. Create one.
-    } else { 
+    }else {
         $context->{"Zconn"}->{$server} = &_new_Zconn($server,$async,$auth,$piggyback,$syntax);
         return $context->{"Zconn"}->{$server};
     }
@@ -471,6 +475,7 @@
     my $user = $context->{"serverinfo"}->{$server}->{"user"};
     my $servername = $context->{"config"}->{$server};
     my $password = $context->{"serverinfo"}->{$server}->{"password"};
+    warn "server:$server servername :$servername host:$host";
     retry:
     eval {
         # set options
@@ -497,23 +502,23 @@
         }
 
     };
-    if ($@) {
-        # Koha manages the Zebra server -- this doesn't work currently for me because of permissions issues
-        # Also, I'm skeptical about whether it's the best approach
-        warn "problem with Zebra";
-        if ( C4::Context->preference("ManageZebra") ) {
-            if ($@->code==10000 && $tried==0) { ##No connection try restarting Zebra
-                $tried=1;
-                warn "trying to restart Zebra";
-                my $res=system("zebrasrv -f $ENV{'KOHA_CONF'} >/koha/log/zebra-error.log");
-                goto "retry";
-            } else {
-                warn "Error ", $@->code(), ": ", $@->message(), "\n";
-                $Zconn="error";
-                return $Zconn;
-            }
-        }
-    }
+#     if ($@) {
+#         # Koha manages the Zebra server -- this doesn't work currently for me because of permissions issues
+#         # Also, I'm skeptical about whether it's the best approach
+#         warn "problem with Zebra";
+#         if ( C4::Context->preference("ManageZebra") ) {
+#             if ($@->code==10000 && $tried==0) { ##No connection try restarting Zebra
+#                 $tried=1;
+#                 warn "trying to restart Zebra";
+#                 my $res=system("zebrasrv -f $ENV{'KOHA_CONF'} >/koha/log/zebra-error.log");
+#                 goto "retry";
+#             } else {
+#                 warn "Error ", $@->code(), ": ", $@->message(), "\n";
+#                 $Zconn="error";
+#                 return $Zconn;
+#             }
+#         }
+#     }
     return $Zconn;
 }
 
@@ -539,7 +544,7 @@
                 $db_user, $db_passwd);
     # Koha 3.0 is utf-8, so force utf8 communication between mySQL and koha, whatever the mysql default config.
     # this is better than modifying my.cnf (and forcing all communications to be in utf8)
-     $dbh->do("set NAMES 'utf8'");
+     $dbh->do("set NAMES 'utf8'") if ($dbh);
     return $dbh;
 }
 
@@ -756,7 +761,7 @@
     my $var = $context->{"activeuser"};
     return $context->{"userenv"}->{$var} if (defined $context->{"userenv"}->{$var});
     # insecure=1 management
-    if ($context->preference('insecure')) {
+    if ($context->{"dbh"} && $context->preference('insecure')) {
         my %insecure;
         $insecure{flags} = '16382';
         $insecure{branchname} ='Insecure',
@@ -792,8 +797,8 @@
         "number"     => $usernum,
         "id"         => $userid,
         "cardnumber" => $usercnum,
-#        "firstname"  => $userfirstname,
-#        "surname"    => $usersurname,
+        "firstname"  => $userfirstname,
+        "surname"    => $usersurname,
 #possibly a law problem
         "branch"     => $userbranch,
         "branchname" => $branchname,
@@ -869,6 +874,10 @@
 =cut
 
 # $Log: Context.pm,v $
+# Revision 1.43.2.10  2007/02/09 17:17:56  hdl
+# Managing a little better database absence.
+# (preventing from BIG 550)
+#
 # Revision 1.43.2.9  2006/12/20 16:50:48  tipaul
 # improving "insecure" management
 #





More information about the Koha-cvs mailing list