Filename | /var/www/foswikidev/core/lib/Foswiki/WebFilter.pm |
Statements | Executed 234 statements in 879µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
24 | 1 | 1 | 463µs | 19.3ms | ok | Foswiki::WebFilter::
2 | 1 | 1 | 81µs | 81µs | new | Foswiki::WebFilter::
1 | 1 | 1 | 15µs | 29µs | BEGIN@4 | Foswiki::WebFilter::
1 | 1 | 1 | 10µs | 14µs | BEGIN@5 | Foswiki::WebFilter::
1 | 1 | 1 | 4µs | 4µs | BEGIN@7 | Foswiki::WebFilter::
0 | 0 | 0 | 0s | 0s | public | Foswiki::WebFilter::
0 | 0 | 0 | 0s | 0s | user | Foswiki::WebFilter::
0 | 0 | 0 | 0s | 0s | user_allowed | Foswiki::WebFilter::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # See bottom of file for license and copyright information | ||||
2 | package Foswiki::WebFilter; | ||||
3 | |||||
4 | 2 | 28µs | 2 | 42µs | # spent 29µs (15+13) within Foswiki::WebFilter::BEGIN@4 which was called:
# once (15µs+13µs) by Foswiki::Search::BEGIN@25 at line 4 # spent 29µs making 1 call to Foswiki::WebFilter::BEGIN@4
# spent 13µs making 1 call to strict::import |
5 | 2 | 50µs | 2 | 18µs | # spent 14µs (10+4) within Foswiki::WebFilter::BEGIN@5 which was called:
# once (10µs+4µs) by Foswiki::Search::BEGIN@25 at line 5 # spent 14µs making 1 call to Foswiki::WebFilter::BEGIN@5
# spent 4µs making 1 call to warnings::import |
6 | |||||
7 | # spent 4µs within Foswiki::WebFilter::BEGIN@7 which was called:
# once (4µs+0s) by Foswiki::Search::BEGIN@25 at line 12 | ||||
8 | 1 | 5µs | if ( $Foswiki::cfg{UseLocale} ) { | ||
9 | require locale; | ||||
10 | import locale(); | ||||
11 | } | ||||
12 | 1 | 318µs | 1 | 4µs | } # spent 4µs making 1 call to Foswiki::WebFilter::BEGIN@7 |
13 | |||||
14 | # PH made these lazy getters rather than globals in Item11349 | ||||
15 | 1 | 200ns | my $public; | ||
16 | 1 | 100ns | my $user; | ||
17 | 1 | 0s | my $user_allowed; | ||
18 | |||||
19 | #TODO: documentme | ||||
20 | #TODO: should this be converted to a FilterIterator? | ||||
21 | |||||
22 | # spec in the $filter, | ||||
23 | # which may include one of: | ||||
24 | # 1 'user' (for only user webs) | ||||
25 | # 2 'template' (for only template webs) | ||||
26 | # $filter may also contain the word 'public' which will further filter | ||||
27 | # webs on whether NOSEARCHALL is specified for them or not. | ||||
28 | # 'allowed' filters out webs that the user is denied access to by a *WEBVIEW. | ||||
29 | |||||
30 | # spent 81µs within Foswiki::WebFilter::new which was called 2 times, avg 40µs/call:
# 2 times (81µs+0s) by Foswiki::Func::getListOfWebs at line 1542 of /var/www/foswikidev/core/lib/Foswiki/Func.pm, avg 40µs/call | ||||
31 | 2 | 3µs | my ( $class, $filter ) = @_; | ||
32 | 2 | 16µs | my $this = bless( {}, $class ); | ||
33 | 2 | 3µs | foreach my $f (qw(user template public allowed)) { | ||
34 | 8 | 55µs | $this->{$f} = ( $filter =~ m/\b$f\b/ ); | ||
35 | } | ||||
36 | 2 | 10µs | return $this; | ||
37 | } | ||||
38 | |||||
39 | # spent 19.3ms (463µs+18.9) within Foswiki::WebFilter::ok which was called 24 times, avg 806µs/call:
# 24 times (463µs+18.9ms) by Foswiki::deepWebList at line 1658 of /var/www/foswikidev/core/lib/Foswiki.pm, avg 806µs/call | ||||
40 | 24 | 12µs | my ( $this, $session, $web ) = @_; | ||
41 | |||||
42 | 24 | 8µs | return 0 if $this->{template} && $web !~ /(?:^_|\/_)/; | ||
43 | |||||
44 | 24 | 14µs | return 1 if ( $web eq $session->{webName} ); | ||
45 | |||||
46 | 22 | 64µs | return 0 if $this->{user} && $web =~ m/(?:^_|\/_)/; | ||
47 | |||||
48 | 20 | 48µs | 20 | 1.38ms | return 0 if !$session->webExists($web); # spent 1.38ms making 20 calls to Foswiki::webExists, avg 69µs/call |
49 | |||||
50 | 19 | 53µs | 19 | 210µs | my $webObject = Foswiki::Meta->new( $session, $web ); # spent 210µs making 19 calls to Foswiki::Meta::new, avg 11µs/call |
51 | 19 | 50µs | 38 | 16.8ms | my $thisWebNoSearchAll = # spent 16.6ms making 19 calls to Foswiki::Meta::getPreference, avg 876µs/call
# spent 145µs making 19 calls to Foswiki::isTrue, avg 8µs/call |
52 | Foswiki::isTrue( $webObject->getPreference('NOSEARCHALL') ); | ||||
53 | |||||
54 | 19 | 47µs | 19 | 47µs | return 0 # spent 47µs making 19 calls to Foswiki::Users::isAdmin, avg 2µs/call |
55 | if $this->{public} | ||||
56 | && !$session->{users}->isAdmin( $session->{user} ) | ||||
57 | && $thisWebNoSearchAll; | ||||
58 | |||||
59 | 19 | 28µs | 19 | 454µs | return 0 if $this->{allowed} && !$webObject->haveAccess('VIEW'); # spent 454µs making 19 calls to Foswiki::Meta::haveAccess, avg 24µs/call |
60 | |||||
61 | 19 | 64µs | return 1; | ||
62 | } | ||||
63 | |||||
64 | sub public { | ||||
65 | my ($class) = @_; | ||||
66 | |||||
67 | if ( !defined $public ) { | ||||
68 | $public = $class->new('public'); | ||||
69 | } | ||||
70 | |||||
71 | return $public; | ||||
72 | } | ||||
73 | |||||
74 | sub user { | ||||
75 | my ($class) = @_; | ||||
76 | |||||
77 | if ( !defined $public ) { | ||||
78 | $public = $class->new('user'); | ||||
79 | } | ||||
80 | |||||
81 | return $public; | ||||
82 | } | ||||
83 | |||||
84 | sub user_allowed { | ||||
85 | my ($class) = @_; | ||||
86 | |||||
87 | if ( !defined $public ) { | ||||
88 | $public = $class->new('user,allowed'); | ||||
89 | } | ||||
90 | |||||
91 | return $public; | ||||
92 | } | ||||
93 | |||||
94 | 1 | 3µs | 1; | ||
95 | __END__ |