Filename | /var/www/foswikidev/core/lib/Foswiki/If/OP_allows.pm |
Statements | Executed 31 statements in 524µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 38µs | 180µs | evaluate | Foswiki::If::OP_allows::
1 | 1 | 1 | 19µs | 26µs | new | Foswiki::If::OP_allows::
1 | 1 | 1 | 18µs | 30µs | BEGIN@12 | Foswiki::If::OP_allows::
1 | 1 | 1 | 9µs | 13µs | BEGIN@13 | Foswiki::If::OP_allows::
1 | 1 | 1 | 9µs | 34µs | BEGIN@18 | Foswiki::If::OP_allows::
1 | 1 | 1 | 3µs | 3µs | BEGIN@19 | Foswiki::If::OP_allows::
1 | 1 | 1 | 3µs | 3µs | BEGIN@21 | Foswiki::If::OP_allows::
1 | 1 | 1 | 3µs | 3µs | BEGIN@15 | Foswiki::If::OP_allows::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # See bottom of file for license and copyright information | ||||
2 | |||||
3 | =begin TML | ||||
4 | |||||
5 | ---+ package Foswiki::If::OP_allows | ||||
6 | Test that the topic name on the LHS allows the access mode on the RHS. | ||||
7 | |||||
8 | =cut | ||||
9 | |||||
10 | package Foswiki::If::OP_allows; | ||||
11 | |||||
12 | 2 | 27µs | 2 | 42µs | # spent 30µs (18+12) within Foswiki::If::OP_allows::BEGIN@12 which was called:
# once (18µs+12µs) by Foswiki::If::Parser::BEGIN@22 at line 12 # spent 30µs making 1 call to Foswiki::If::OP_allows::BEGIN@12
# spent 12µs making 1 call to strict::import |
13 | 2 | 22µs | 2 | 17µs | # spent 13µs (9+4) within Foswiki::If::OP_allows::BEGIN@13 which was called:
# once (9µs+4µs) by Foswiki::If::Parser::BEGIN@22 at line 13 # spent 13µs making 1 call to Foswiki::If::OP_allows::BEGIN@13
# spent 4µs making 1 call to warnings::import |
14 | |||||
15 | 2 | 30µs | 1 | 3µs | # spent 3µs within Foswiki::If::OP_allows::BEGIN@15 which was called:
# once (3µs+0s) by Foswiki::If::Parser::BEGIN@22 at line 15 # spent 3µs making 1 call to Foswiki::If::OP_allows::BEGIN@15 |
16 | 1 | 6µs | our @ISA = ('Foswiki::Query::OP'); | ||
17 | |||||
18 | 2 | 27µs | 2 | 58µs | # spent 34µs (9+25) within Foswiki::If::OP_allows::BEGIN@18 which was called:
# once (9µs+25µs) by Foswiki::If::Parser::BEGIN@22 at line 18 # spent 34µs making 1 call to Foswiki::If::OP_allows::BEGIN@18
# spent 25µs making 1 call to Exporter::import |
19 | 2 | 39µs | 1 | 3µs | # spent 3µs within Foswiki::If::OP_allows::BEGIN@19 which was called:
# once (3µs+0s) by Foswiki::If::Parser::BEGIN@22 at line 19 # spent 3µs making 1 call to Foswiki::If::OP_allows::BEGIN@19 |
20 | |||||
21 | # spent 3µs within Foswiki::If::OP_allows::BEGIN@21 which was called:
# once (3µs+0s) by Foswiki::If::Parser::BEGIN@22 at line 26 | ||||
22 | 1 | 4µs | if ( $Foswiki::cfg{UseLocale} ) { | ||
23 | require locale; | ||||
24 | import locale(); | ||||
25 | } | ||||
26 | 1 | 231µs | 1 | 3µs | } # spent 3µs making 1 call to Foswiki::If::OP_allows::BEGIN@21 |
27 | |||||
28 | # spent 26µs (19+6) within Foswiki::If::OP_allows::new which was called:
# once (19µs+6µs) by Foswiki::If::Parser::new at line 49 of /var/www/foswikidev/core/lib/Foswiki/If/Parser.pm | ||||
29 | 1 | 300ns | my $class = shift; | ||
30 | 1 | 109µs | 1 | 6µs | return $class->SUPER::new( arity => 2, name => 'allows', prec => 600 ); # spent 6µs making 1 call to Foswiki::Query::OP::new |
31 | } | ||||
32 | |||||
33 | # spent 180µs (38+142) within Foswiki::If::OP_allows::evaluate which was called:
# once (38µs+142µs) by Foswiki::Query::Node::evaluate at line 223 of /var/www/foswikidev/core/lib/Foswiki/Query/Node.pm | ||||
34 | 1 | 200ns | my $this = shift; | ||
35 | 1 | 100ns | my $node = shift; | ||
36 | 1 | 500ns | my $a = $node->{params}->[0]; # topic name (string) | ||
37 | 1 | 300ns | my $b = $node->{params}->[1]; # access mode (string) | ||
38 | 1 | 1µs | 1 | 2µs | my $mode = $b->_evaluate(@_) || 'view'; # spent 2µs making 1 call to Foswiki::If::Node::_evaluate |
39 | 1 | 1µs | my %domain = @_; | ||
40 | 1 | 2µs | 1 | 1µs | my $session = $domain{tom}->session; # spent 1µs making 1 call to Foswiki::Meta::session |
41 | 1 | 300ns | throw Error::Simple( | ||
42 | 'No context in which to evaluate "' . $a->stringify() . '"' ) | ||||
43 | unless $session; | ||||
44 | |||||
45 | 1 | 1µs | 1 | 0s | my $str = $a->evaluate(@_); # spent 4µs making 1 call to Foswiki::Query::Node::evaluate, recursion: max depth 1, sum of overlapping time 4µs |
46 | 1 | 100ns | return 0 unless $str; | ||
47 | |||||
48 | 1 | 3µs | 1 | 8µs | my ( $web, $topic ) = # spent 8µs making 1 call to Foswiki::normalizeWebTopicName |
49 | $session->normalizeWebTopicName( $session->{webName}, $str ); | ||||
50 | |||||
51 | 1 | 300ns | my $ok = 0; | ||
52 | |||||
53 | # Try for an existing topic first. | ||||
54 | 1 | 3µs | 1 | 69µs | if ( $session->topicExists( $web, $topic ) ) { # spent 69µs making 1 call to Foswiki::topicExists |
55 | |||||
56 | 1 | 4µs | 1 | 15µs | my $topicObject = Foswiki::Meta->new( $session, $web, $topic ); # spent 15µs making 1 call to Foswiki::Meta::new |
57 | 1 | 4µs | 1 | 43µs | $ok = $topicObject->haveAccess($mode); # spent 43µs making 1 call to Foswiki::Meta::haveAccess |
58 | } | ||||
59 | |||||
60 | # Not an existing web.topic name, see if the string on its own | ||||
61 | # is a web name | ||||
62 | elsif ( $session->webExists($str) ) { | ||||
63 | my $webObject = Foswiki::Meta->new( $session, $str ); | ||||
64 | $ok = $webObject->haveAccess($mode); | ||||
65 | } | ||||
66 | |||||
67 | # Not an existing web.topic or a web on it's own; maybe it's | ||||
68 | # web.topic for an existing web but non-existing topic | ||||
69 | elsif ( $session->webExists($web) ) { | ||||
70 | my $webObject = Foswiki::Meta->new( $session, $web ); | ||||
71 | $ok = $webObject->haveAccess($mode); | ||||
72 | } | ||||
73 | else { | ||||
74 | $ok = 0; | ||||
75 | } | ||||
76 | 1 | 4µs | return $ok ? 1 : 0; | ||
77 | } | ||||
78 | |||||
79 | 1 | 3µs | 1; | ||
80 | __END__ |