Ticket #3451 (closed defect: fixed)
Caching subjects ($session->cache_subjects) then calling $subject->get_children causes error
| Reported by: | tmb | Owned by: | |
|---|---|---|---|
| Priority: | Intend to | Milestone: | EPrints 3.1.x |
| Component: | - | Version: | 3.1 |
| Severity: | normal | Keywords: | |
| Cc: |
Description
If subjects are cached ($session->cache_subjects), $subject->get_children will use the cache to return an array of child subjects. But the subject_child_map only contains subjects which actually have children, so calling get_children on a subject with no children causes an error.
Fix:
sub get_children
{
my( $self ) = @_;
if( $self->{session}->{subjects_cached} )
{
my $subjectid = $self->get_value( "subjectid" );
return () unless defined $self->{session}->{subject_child_map}->{$subjectid}; # FIX
return @{$self->{session}->{subject_child_map}->{$subjectid}};
}
Maybe subject_child_map should also include subjects with no children (mapped to an empty list)?
Change History
Note: See
TracTickets for help on using
tickets.
