Skip to content

Commit

Permalink
Add LookupType method to fix custom roles upgrade bug
Browse files Browse the repository at this point in the history
If upgrading from 4.4.1 or previous and database has a custom role the
4.4.2 upgrade step fails as the 5.0.4 code expects the LookupType column
to exist in the database.

Add a LookupType method that attempts to call LookupType on its parent
class and if there is no result default to the only possible value for
older databases.
  • Loading branch information
bkembreeBPS committed Aug 24, 2023
1 parent 0072407 commit e95bb60
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/RT/CustomRole.pm
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,27 @@ Returns table name for records of this class

sub Table {'CustomRoles'}

=head2 LookupType
Returns the lookup type for records of this class
=cut

sub LookupType {
my $self = shift;

# LookupType column might not exist in older databases
my $type = '';
eval {
$type = $self->SUPER::LookupType(@_);
};
# if no type found default to the only possibility for older databases
$type = 'RT::Queue-RT::Ticket'
unless $type;

return $type;
}

=head2 Create PARAMHASH
Create takes a hash of values and creates a row in the database:
Expand Down

0 comments on commit e95bb60

Please sign in to comment.