X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FResultSource.pm;h=7389a044da48ef45ca9af22194ec376cb9c84efa;hb=e989099be9257b775a97dd09b4e9b8dbfec2dfcc;hp=46ad67a4336ec280f52fae67665a901fd36242bd;hpb=4376a1574bc5b25f4b9160e8fc3ce329ae226e0f;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/ResultSource.pm b/lib/DBIx/Class/ResultSource.pm index 46ad67a..7389a04 100644 --- a/lib/DBIx/Class/ResultSource.pm +++ b/lib/DBIx/Class/ResultSource.pm @@ -633,12 +633,11 @@ will be applied to the L of each L sub sequence { my ($self,$seq) = @_; - my $rsrc = $self->result_source; - my @pks = $rsrc->primary_columns + my @pks = $self->primary_columns or next; $_->{sequence} = $seq - for values %{ $rsrc->columns_info (\@pks) }; + for values %{ $self->columns_info (\@pks) }; } @@ -1346,11 +1345,14 @@ sub reverse_relationship_info { my @otherrels = $othertable->relationships(); my $otherrelationship; foreach my $otherrel (@otherrels) { - my $otherrel_info = $othertable->relationship_info($otherrel); + # this may be a partial schema with the related source not being + # available at all + my $back = try { $othertable->related_source($otherrel) } or next; - my $back = $othertable->related_source($otherrel); + # did we get back to ourselves? next unless $back->source_name eq $self->source_name; + my $otherrel_info = $othertable->relationship_info($otherrel); my @othertestconds; if (ref $otherrel_info->{cond} eq 'HASH') { @@ -1781,7 +1783,10 @@ sub handle { { my $global_phase_destroy; - END { $global_phase_destroy++ } + # SpeedyCGI runs END blocks every cycle but keeps object instances + # hence we have to disable the globaldestroy hatch, and rely on the + # eval trap below (which appears to work, but is risky done so late) + END { $global_phase_destroy = 1 unless $CGI::SpeedyCGI::i_am_speedy } sub DESTROY { return if $global_phase_destroy; @@ -1804,12 +1809,23 @@ sub handle { ); # weaken our schema hold forcing the schema to find somewhere else to live - weaken $_[0]->{schema}; + # during global destruction (if we have not yet bailed out) this will throw + # which will serve as a signal to not try doing anything else + local $@; + eval { + weaken $_[0]->{schema}; + 1; + } or do { + $global_phase_destroy = 1; + return; + }; + - # if schema is still there reintroduce ourselves with strong refs back + # if schema is still there reintroduce ourselves with strong refs back to us if ($_[0]->{schema}) { my $srcregs = $_[0]->{schema}->source_registrations; for (keys %$srcregs) { + next unless $srcregs->{$_}; $srcregs->{$_} = $_[0] if $srcregs->{$_} == $_[0]; } }