Skip to content

Commit

Permalink
Restrict Name checks to objects with Name and only when id is not num…
Browse files Browse the repository at this point in the history
…eric

92dc904 updated the id check in Shredder to handle the case where $id is actually a Name.
However, it breaks the case where $id is not a Name, which could produce errors like:

error: RT::Ticket::Name Unimplemented in RT::Shredder

This commit fixes it to:

* Not check Name if $id is numeric.
* Not check Name if object doesn't have it.
  • Loading branch information
craigkai authored and sunnavy committed Jun 18, 2018
1 parent bad1460 commit 3f3dc51
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/RT/Shredder.pm
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,15 @@ sub CastObjectsToRecords
RT::Shredder::Exception::Info->throw( 'CouldntLoadObject' );
}

if ( $id =~ /^\d+$/ && $id ne $obj->Id ){
die 'Loaded object id ' . $obj->Id . " is different from passed id $id";
if ( $id =~ /^\d+$/ ) {
if ( $id ne $obj->Id ) {
die 'Loaded object id ' . $obj->Id . " is different from passed id $id";
}
}
elsif ( $id ne $obj->Name ){
die 'Loaded object name ' . $obj->Name . " is different from passed name $id";
else {
if ( $obj->_Accessible( 'Name', 'read' ) && $id ne $obj->Name ) {
die 'Loaded object name ' . $obj->Name . " is different from passed name $id";
}
}
push @res, $obj;
} else {
Expand Down

0 comments on commit 3f3dc51

Please sign in to comment.