| Filename | /usr/share/perl5/DBIx/Class/Relationship/ManyToMany.pm |
| Statements | Executed 308 statements in 4.64ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 12 | 12 | 9 | 812µs | 3.01ms | DBIx::Class::Relationship::ManyToMany::many_to_many |
| 1 | 1 | 1 | 17µs | 26µs | DBIx::Class::Relationship::ManyToMany::BEGIN@4 |
| 1 | 1 | 1 | 11µs | 46µs | DBIx::Class::Relationship::ManyToMany::BEGIN@8 |
| 1 | 1 | 1 | 11µs | 29µs | DBIx::Class::Relationship::ManyToMany::BEGIN@9 |
| 1 | 1 | 1 | 10µs | 17µs | DBIx::Class::Relationship::ManyToMany::BEGIN@30 |
| 1 | 1 | 1 | 9µs | 27µs | DBIx::Class::Relationship::ManyToMany::BEGIN@10 |
| 1 | 1 | 1 | 9µs | 24µs | DBIx::Class::Relationship::ManyToMany::BEGIN@31 |
| 1 | 1 | 1 | 8µs | 14µs | DBIx::Class::Relationship::ManyToMany::BEGIN@5 |
| 1 | 1 | 1 | 8µs | 50µs | DBIx::Class::Relationship::ManyToMany::BEGIN@7 |
| 1 | 1 | 1 | 8µs | 119µs | DBIx::Class::Relationship::ManyToMany::BEGIN@11 |
| 0 | 0 | 0 | 0s | 0s | DBIx::Class::Relationship::ManyToMany::__ANON__[:109] |
| 0 | 0 | 0 | 0s | 0s | DBIx::Class::Relationship::ManyToMany::__ANON__[:127] |
| 0 | 0 | 0 | 0s | 0s | DBIx::Class::Relationship::ManyToMany::__ANON__[:146] |
| 0 | 0 | 0 | 0s | 0s | DBIx::Class::Relationship::ManyToMany::__ANON__[:70] |
| 0 | 0 | 0 | 0s | 0s | DBIx::Class::Relationship::ManyToMany::__ANON__[:78] |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Aqbasket::add_to_borrowernumbers |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Aqbasket::borrowernumbers |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Aqbasket::borrowernumbers_rs |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Aqbasket::remove_from_borrowernumbers |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Aqbasket::set_borrowernumbers |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Aqbudget::add_to_borrowernumbers |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Aqbudget::borrowernumbers |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Aqbudget::borrowernumbers_rs |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Aqbudget::remove_from_borrowernumbers |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Aqbudget::set_borrowernumbers |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Aqorder::add_to_borrowernumbers |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Aqorder::borrowernumbers |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Aqorder::borrowernumbers_rs |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Aqorder::remove_from_borrowernumbers |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Aqorder::set_borrowernumbers |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Borrower::add_to_basketnoes |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Borrower::add_to_budgets |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Borrower::add_to_courses |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Borrower::add_to_ordernumbers |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Borrower::basketnoes |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Borrower::basketnoes_rs |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Borrower::budgets |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Borrower::budgets_rs |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Borrower::courses |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Borrower::courses_rs |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Borrower::ordernumbers |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Borrower::ordernumbers_rs |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Borrower::remove_from_basketnoes |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Borrower::remove_from_budgets |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Borrower::remove_from_courses |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Borrower::remove_from_ordernumbers |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Borrower::set_basketnoes |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Borrower::set_budgets |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Borrower::set_courses |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Borrower::set_ordernumbers |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::BorrowerMessagePreference::add_to_message_transport_types |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::BorrowerMessagePreference::message_transport_types |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::BorrowerMessagePreference::message_transport_types_rs |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::BorrowerMessagePreference::remove_from_message_transport_types |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::BorrowerMessagePreference::set_message_transport_types |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Branch::add_to_categorycodes |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Branch::categorycodes |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Branch::categorycodes_rs |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Branch::remove_from_categorycodes |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Branch::set_categorycodes |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Branchcategory::add_to_branchcodes |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Branchcategory::branchcodes |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Branchcategory::branchcodes_rs |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Branchcategory::remove_from_branchcodes |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Branchcategory::set_branchcodes |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Course::add_to_borrowernumbers |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Course::borrowernumbers |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Course::borrowernumbers_rs |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Course::remove_from_borrowernumbers |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::Course::set_borrowernumbers |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::MessageTransportType::add_to_borrower_message_preferences |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::MessageTransportType::borrower_message_preferences |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::MessageTransportType::borrower_message_preferences_rs |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::MessageTransportType::remove_from_borrower_message_preferences |
| 0 | 0 | 0 | 0s | 0s | Koha::Schema::Result::MessageTransportType::set_borrower_message_preferences |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package # hide from PAUSE | ||||
| 2 | DBIx::Class::Relationship::ManyToMany; | ||||
| 3 | |||||
| 4 | 2 | 43µs | 2 | 36µs | # spent 26µs (17+9) within DBIx::Class::Relationship::ManyToMany::BEGIN@4 which was called:
# once (17µs+9µs) by Class::C3::Componentised::ensure_class_loaded at line 4 # spent 26µs making 1 call to DBIx::Class::Relationship::ManyToMany::BEGIN@4
# spent 9µs making 1 call to strict::import |
| 5 | 2 | 32µs | 2 | 19µs | # spent 14µs (8+6) within DBIx::Class::Relationship::ManyToMany::BEGIN@5 which was called:
# once (8µs+6µs) by Class::C3::Componentised::ensure_class_loaded at line 5 # spent 14µs making 1 call to DBIx::Class::Relationship::ManyToMany::BEGIN@5
# spent 6µs making 1 call to warnings::import |
| 6 | |||||
| 7 | 2 | 34µs | 2 | 92µs | # spent 50µs (8+42) within DBIx::Class::Relationship::ManyToMany::BEGIN@7 which was called:
# once (8µs+42µs) by Class::C3::Componentised::ensure_class_loaded at line 7 # spent 50µs making 1 call to DBIx::Class::Relationship::ManyToMany::BEGIN@7
# spent 42µs making 1 call to DBIx::Class::Carp::import |
| 8 | 2 | 68µs | 2 | 82µs | # spent 46µs (11+35) within DBIx::Class::Relationship::ManyToMany::BEGIN@8 which was called:
# once (11µs+35µs) by Class::C3::Componentised::ensure_class_loaded at line 8 # spent 46µs making 1 call to DBIx::Class::Relationship::ManyToMany::BEGIN@8
# spent 35µs making 1 call to Exporter::import |
| 9 | 2 | 53µs | 2 | 47µs | # spent 29µs (11+18) within DBIx::Class::Relationship::ManyToMany::BEGIN@9 which was called:
# once (11µs+18µs) by Class::C3::Componentised::ensure_class_loaded at line 9 # spent 29µs making 1 call to DBIx::Class::Relationship::ManyToMany::BEGIN@9
# spent 18µs making 1 call to Exporter::import |
| 10 | 2 | 46µs | 2 | 45µs | # spent 27µs (9+18) within DBIx::Class::Relationship::ManyToMany::BEGIN@10 which was called:
# once (9µs+18µs) by Class::C3::Componentised::ensure_class_loaded at line 10 # spent 27µs making 1 call to DBIx::Class::Relationship::ManyToMany::BEGIN@10
# spent 18µs making 1 call to Exporter::import |
| 11 | 2 | 198µs | 2 | 231µs | # spent 119µs (8+112) within DBIx::Class::Relationship::ManyToMany::BEGIN@11 which was called:
# once (8µs+112µs) by Class::C3::Componentised::ensure_class_loaded at line 11 # spent 119µs making 1 call to DBIx::Class::Relationship::ManyToMany::BEGIN@11
# spent 112µs making 1 call to namespace::clean::import |
| 12 | |||||
| 13 | 1 | 2µs | our %_pod_inherit_config = | ||
| 14 | ( | ||||
| 15 | class_map => { 'DBIx::Class::Relationship::ManyToMany' => 'DBIx::Class::Relationship' } | ||||
| 16 | ); | ||||
| 17 | |||||
| 18 | # spent 3.01ms (812µs+2.20) within DBIx::Class::Relationship::ManyToMany::many_to_many which was called 12 times, avg 251µs/call:
# once (80µs+1.32ms) by Class::C3::Componentised::ensure_class_loaded at line 181 of Koha/Schema/Result/Course.pm
# once (127µs+129µs) by Class::C3::Componentised::ensure_class_loaded at line 492 of Koha/Schema/Result/Aqorder.pm
# once (69µs+96µs) by Class::C3::Componentised::ensure_class_loaded at line 1146 of Koha/Schema/Result/Borrower.pm
# once (78µs+87µs) by Class::C3::Componentised::ensure_class_loaded at line 274 of Koha/Schema/Result/Aqbasket.pm
# once (84µs+80µs) by Class::C3::Componentised::ensure_class_loaded at line 513 of Koha/Schema/Result/Branch.pm
# once (80µs+75µs) by Class::C3::Componentised::ensure_class_loaded at line 268 of Koha/Schema/Result/Aqbudget.pm
# once (74µs+78µs) by Class::C3::Componentised::ensure_class_loaded at line 108 of Koha/Schema/Result/Branchcategory.pm
# once (66µs+83µs) by Class::C3::Componentised::ensure_class_loaded at line 146 of Koha/Schema/Result/MessageTransportType.pm
# once (65µs+84µs) by Class::C3::Componentised::ensure_class_loaded at line 185 of Koha/Schema/Result/BorrowerMessagePreference.pm
# once (41µs+75µs) by Class::C3::Componentised::ensure_class_loaded at line 1176 of Koha/Schema/Result/Borrower.pm
# once (20µs+67µs) by Class::C3::Componentised::ensure_class_loaded at line 1156 of Koha/Schema/Result/Borrower.pm
# once (28µs+20µs) by Class::C3::Componentised::ensure_class_loaded at line 1166 of Koha/Schema/Result/Borrower.pm | ||||
| 19 | 12 | 12µs | my ($class, $meth, $rel, $f_rel, $rel_attrs) = @_; | ||
| 20 | |||||
| 21 | 12 | 3µs | $class->throw_exception( | ||
| 22 | "missing relation in many-to-many" | ||||
| 23 | ) unless $rel; | ||||
| 24 | |||||
| 25 | 12 | 3µs | $class->throw_exception( | ||
| 26 | "missing foreign relation in many-to-many" | ||||
| 27 | ) unless $f_rel; | ||||
| 28 | |||||
| 29 | { | ||||
| 30 | 14 | 87µs | 2 | 24µs | # spent 17µs (10+7) within DBIx::Class::Relationship::ManyToMany::BEGIN@30 which was called:
# once (10µs+7µs) by Class::C3::Componentised::ensure_class_loaded at line 30 # spent 17µs making 1 call to DBIx::Class::Relationship::ManyToMany::BEGIN@30
# spent 7µs making 1 call to strict::unimport |
| 31 | 2 | 1.08ms | 2 | 39µs | # spent 24µs (9+15) within DBIx::Class::Relationship::ManyToMany::BEGIN@31 which was called:
# once (9µs+15µs) by Class::C3::Componentised::ensure_class_loaded at line 31 # spent 24µs making 1 call to DBIx::Class::Relationship::ManyToMany::BEGIN@31
# spent 15µs making 1 call to warnings::unimport |
| 32 | |||||
| 33 | 12 | 12µs | my $add_meth = "add_to_${meth}"; | ||
| 34 | 12 | 10µs | my $remove_meth = "remove_from_${meth}"; | ||
| 35 | 12 | 9µs | my $set_meth = "set_${meth}"; | ||
| 36 | 12 | 10µs | my $rs_meth = "${meth}_rs"; | ||
| 37 | |||||
| 38 | 12 | 17µs | for ($add_meth, $remove_meth, $set_meth, $rs_meth) { | ||
| 39 | 48 | 901µs | 48 | 692µs | if ( $class->can ($_) ) { # spent 692µs making 48 calls to UNIVERSAL::can, avg 14µs/call |
| 40 | carp (<<"EOW") unless $ENV{DBIC_OVERWRITE_HELPER_METHODS_OK}; | ||||
| 41 | |||||
| 42 | *************************************************************************** | ||||
| 43 | The many-to-many relationship '$meth' is trying to create a utility method | ||||
| 44 | called $_. | ||||
| 45 | This will completely overwrite one such already existing method on class | ||||
| 46 | $class. | ||||
| 47 | |||||
| 48 | You almost certainly want to rename your method or the many-to-many | ||||
| 49 | relationship, as the functionality of the original method will not be | ||||
| 50 | accessible anymore. | ||||
| 51 | |||||
| 52 | To disable this warning set to a true value the environment variable | ||||
| 53 | DBIC_OVERWRITE_HELPER_METHODS_OK | ||||
| 54 | |||||
| 55 | *************************************************************************** | ||||
| 56 | EOW | ||||
| 57 | } | ||||
| 58 | } | ||||
| 59 | |||||
| 60 | 12 | 25µs | $rel_attrs->{alias} ||= $f_rel; | ||
| 61 | |||||
| 62 | 12 | 16µs | my $rs_meth_name = join '::', $class, $rs_meth; | ||
| 63 | *$rs_meth_name = subname $rs_meth_name, sub { | ||||
| 64 | my $self = shift; | ||||
| 65 | my $attrs = @_ > 1 && ref $_[$#_] eq 'HASH' ? pop(@_) : {}; | ||||
| 66 | my $rs = $self->search_related($rel)->search_related( | ||||
| 67 | $f_rel, @_ > 0 ? @_ : undef, { %{$rel_attrs||{}}, %$attrs } | ||||
| 68 | ); | ||||
| 69 | return $rs; | ||||
| 70 | 12 | 152µs | 12 | 64µs | }; # spent 64µs making 12 calls to Sub::Name::subname, avg 5µs/call |
| 71 | |||||
| 72 | 12 | 12µs | my $meth_name = join '::', $class, $meth; | ||
| 73 | *$meth_name = subname $meth_name, sub { | ||||
| 74 | DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_WANTARRAY and my $sog = fail_on_internal_wantarray; | ||||
| 75 | my $self = shift; | ||||
| 76 | my $rs = $self->$rs_meth( @_ ); | ||||
| 77 | return (wantarray ? $rs->all : $rs); | ||||
| 78 | 12 | 122µs | 12 | 48µs | }; # spent 48µs making 12 calls to Sub::Name::subname, avg 4µs/call |
| 79 | |||||
| 80 | 12 | 11µs | my $add_meth_name = join '::', $class, $add_meth; | ||
| 81 | *$add_meth_name = subname $add_meth_name, sub { | ||||
| 82 | my $self = shift; | ||||
| 83 | @_ > 0 or $self->throw_exception( | ||||
| 84 | "${add_meth} needs an object or hashref" | ||||
| 85 | ); | ||||
| 86 | my $source = $self->result_source; | ||||
| 87 | my $schema = $source->schema; | ||||
| 88 | my $rel_source_name = $source->relationship_info($rel)->{source}; | ||||
| 89 | my $rel_source = $schema->resultset($rel_source_name)->result_source; | ||||
| 90 | my $f_rel_source_name = $rel_source->relationship_info($f_rel)->{source}; | ||||
| 91 | my $f_rel_rs = $schema->resultset($f_rel_source_name)->search({}, $rel_attrs||{}); | ||||
| 92 | |||||
| 93 | my $obj; | ||||
| 94 | if (ref $_[0]) { | ||||
| 95 | if (ref $_[0] eq 'HASH') { | ||||
| 96 | $obj = $f_rel_rs->find_or_create($_[0]); | ||||
| 97 | } else { | ||||
| 98 | $obj = $_[0]; | ||||
| 99 | } | ||||
| 100 | } else { | ||||
| 101 | $obj = $f_rel_rs->find_or_create({@_}); | ||||
| 102 | } | ||||
| 103 | |||||
| 104 | my $link_vals = @_ > 1 && ref $_[$#_] eq 'HASH' ? pop(@_) : {}; | ||||
| 105 | my $link = $self->search_related($rel)->new_result($link_vals); | ||||
| 106 | $link->set_from_related($f_rel, $obj); | ||||
| 107 | $link->insert(); | ||||
| 108 | return $obj; | ||||
| 109 | 12 | 140µs | 12 | 51µs | }; # spent 51µs making 12 calls to Sub::Name::subname, avg 4µs/call |
| 110 | |||||
| 111 | 12 | 11µs | my $set_meth_name = join '::', $class, $set_meth; | ||
| 112 | *$set_meth_name = subname $set_meth_name, sub { | ||||
| 113 | my $self = shift; | ||||
| 114 | @_ > 0 or $self->throw_exception( | ||||
| 115 | "{$set_meth} needs a list of objects or hashrefs" | ||||
| 116 | ); | ||||
| 117 | my @to_set = (ref($_[0]) eq 'ARRAY' ? @{ $_[0] } : @_); | ||||
| 118 | # if there is a where clause in the attributes, ensure we only delete | ||||
| 119 | # rows that are within the where restriction | ||||
| 120 | if ($rel_attrs && $rel_attrs->{where}) { | ||||
| 121 | $self->search_related( $rel, $rel_attrs->{where},{join => $f_rel})->delete; | ||||
| 122 | } else { | ||||
| 123 | $self->search_related( $rel, {} )->delete; | ||||
| 124 | } | ||||
| 125 | # add in the set rel objects | ||||
| 126 | $self->$add_meth($_, ref($_[1]) ? $_[1] : {}) for (@to_set); | ||||
| 127 | 12 | 1.37ms | 12 | 1.29ms | }; # spent 1.29ms making 12 calls to Sub::Name::subname, avg 108µs/call |
| 128 | |||||
| 129 | 12 | 10µs | my $remove_meth_name = join '::', $class, $remove_meth; | ||
| 130 | *$remove_meth_name = subname $remove_meth_name, sub { | ||||
| 131 | my ($self, $obj) = @_; | ||||
| 132 | $self->throw_exception("${remove_meth} needs an object") | ||||
| 133 | unless blessed ($obj); | ||||
| 134 | my $rel_source = $self->search_related($rel)->result_source; | ||||
| 135 | my $cond = $rel_source->relationship_info($f_rel)->{cond}; | ||||
| 136 | my ($link_cond, $crosstable) = $rel_source->_resolve_condition( | ||||
| 137 | $cond, $obj, $f_rel, $f_rel | ||||
| 138 | ); | ||||
| 139 | |||||
| 140 | $self->throw_exception( | ||||
| 141 | "Relationship '$rel' does not resolve to a join-free condition, " | ||||
| 142 | ."unable to use with the ManyToMany helper '$f_rel'" | ||||
| 143 | ) if $crosstable; | ||||
| 144 | |||||
| 145 | $self->search_related($rel, $link_cond)->delete; | ||||
| 146 | 12 | 137µs | 12 | 53µs | }; # spent 53µs making 12 calls to Sub::Name::subname, avg 4µs/call |
| 147 | |||||
| 148 | } | ||||
| 149 | } | ||||
| 150 | |||||
| 151 | 1 | 3µs | 1 | 166µs | 1; # spent 166µs making 1 call to B::Hooks::EndOfScope::XS::__ANON__ |