Ticket #3451 (closed defect: fixed)

Opened 6 years ago

Last modified 4 years ago

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

Changed 4 years ago by tdb01r

  • status changed from new to closed
  • resolution set to fixed

Resolved in r4573,r4574.

Changed 4 years ago by tdb01r

Further fix in r4582,r4583.

Note: See TracTickets for help on using tickets.