added sanity checking to prevent id retrievals using objects
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 6 Sep 2006 05:28:04 +0000 (05:28 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 6 Sep 2006 05:28:04 +0000 (05:28 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@5979 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm

index def59ab..2d391a0 100644 (file)
@@ -380,6 +380,17 @@ sub __arg_to_string {
 sub runmethod {
        my( $self, $action, $type, $arg, $options ) = @_;
 
 sub runmethod {
        my( $self, $action, $type, $arg, $options ) = @_;
 
+       if( $action eq 'retrieve' ) {
+               if(! defined($arg) ) {
+                       $self->log(W,"$action $type called with no ID...");
+                       $self->event(_mk_not_found($type, $arg));
+                       return undef;
+               } elsif( ref($arg) =~ /Fieldmapper/ ) {
+                       $self->log(E,"$action $type called with an object.. attempting ID retrieval..");
+                       $arg = $arg->id;
+               }
+       }
+
        my @arg = ( ref($arg) eq 'ARRAY' ) ? @$arg : ($arg);
        my $method = "open-ils.cstore.direct.$type.$action";
 
        my @arg = ( ref($arg) eq 'ARRAY' ) ? @$arg : ($arg);
        my $method = "open-ils.cstore.direct.$type.$action";