From b5a466cc90da7159fe0108df88d7af0dbec8ec9c Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 7 Aug 2012 16:28:33 -0400 Subject: [PATCH] Added is_event check to AppUtils Signed-off-by: Bill Erickson --- Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm index 2529d6b6a8..a3a1b08fdf 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm @@ -138,10 +138,22 @@ sub rollback_db_session { # returns the event code otherwise sub event_code { my( $self, $evt ) = @_; - return $evt->{ilsevent} if( ref($evt) eq 'HASH' and defined($evt->{ilsevent})) ; + return $evt->{ilsevent} if $self->is_event($evt); return undef; } +# some events, in particular auto-generated events, don't have an +# ilsevent key. treat hashes with a 'textcode' key as events. +sub is_event { + my ($self, $evt) = @_; + return ( + ref($evt) eq 'HASH' and ( + defined $evt->{ilsevent} or + defined $evt->{textcode} + ) + ); +} + # --------------------------------------------------------------------------- # Checks to see if a user is logged in. Returns the user record on success, # throws an exception on error. -- 2.11.0