Filename | /var/www/foswikidev/core/lib/Foswiki/Plugins.pm |
Statements | Executed 7239 statements in 8.20ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
350 | 13 | 4 | 5.43ms | 43.1ms | dispatch (recurses: max depth 1, inclusive time 188µs) | Foswiki::Plugins::
1 | 1 | 1 | 1.94ms | 3.98ms | BEGIN@21 | Foswiki::Plugins::
1 | 1 | 1 | 466µs | 118ms | preload | Foswiki::Plugins::
86 | 1 | 1 | 198µs | 198µs | addListener | Foswiki::Plugins::
1 | 1 | 1 | 193µs | 3.06ms | load | Foswiki::Plugins::
1 | 1 | 1 | 179µs | 65.8ms | enable | Foswiki::Plugins::
1 | 1 | 1 | 165µs | 703µs | finish | Foswiki::Plugins::
1 | 1 | 1 | 92µs | 12.0ms | settings | Foswiki::Plugins::
1 | 1 | 1 | 32µs | 118ms | new | Foswiki::Plugins::
10 | 2 | 1 | 24µs | 24µs | haveHandlerFor | Foswiki::Plugins::
1 | 1 | 1 | 17µs | 30µs | BEGIN@17 | Foswiki::Plugins::
1 | 1 | 1 | 16µs | 55µs | BEGIN@39 | Foswiki::Plugins::
1 | 1 | 1 | 10µs | 22µs | BEGIN@379 | Foswiki::Plugins::
1 | 1 | 1 | 9µs | 34µs | BEGIN@19 | Foswiki::Plugins::
1 | 1 | 1 | 9µs | 13µs | BEGIN@18 | Foswiki::Plugins::
1 | 1 | 1 | 8µs | 17µs | BEGIN@381 | Foswiki::Plugins::
1 | 1 | 1 | 5µs | 5µs | BEGIN@23 | Foswiki::Plugins::
0 | 0 | 0 | 0s | 0s | __ANON__[:159] | Foswiki::Plugins::
0 | 0 | 0 | 0s | 0s | _handleACTIVATEDPLUGINS | Foswiki::Plugins::
0 | 0 | 0 | 0s | 0s | _handleFAILEDPLUGINS | Foswiki::Plugins::
0 | 0 | 0 | 0s | 0s | _handlePLUGINDESCRIPTIONS | Foswiki::Plugins::
0 | 0 | 0 | 0s | 0s | _handleRESTHANDLERS | Foswiki::Plugins::
0 | 0 | 0 | 0s | 0s | getPluginVersion | Foswiki::Plugins::
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::Plugins | ||||
6 | |||||
7 | This module defines the singleton object that handles Plugins | ||||
8 | loading, initialization and execution. | ||||
9 | |||||
10 | This class uses Chain of Responsibility (GOF) pattern to dispatch | ||||
11 | handler calls to registered plugins. | ||||
12 | |||||
13 | =cut | ||||
14 | |||||
15 | package Foswiki::Plugins; | ||||
16 | |||||
17 | 2 | 28µs | 2 | 43µs | # spent 30µs (17+13) within Foswiki::Plugins::BEGIN@17 which was called:
# once (17µs+13µs) by Foswiki::BEGIN@646 at line 17 # spent 30µs making 1 call to Foswiki::Plugins::BEGIN@17
# spent 13µs making 1 call to strict::import |
18 | 2 | 23µs | 2 | 17µs | # spent 13µs (9+4) within Foswiki::Plugins::BEGIN@18 which was called:
# once (9µs+4µs) by Foswiki::BEGIN@646 at line 18 # spent 13µs making 1 call to Foswiki::Plugins::BEGIN@18
# spent 4µs making 1 call to warnings::import |
19 | 2 | 25µs | 2 | 59µs | # spent 34µs (9+25) within Foswiki::Plugins::BEGIN@19 which was called:
# once (9µs+25µs) by Foswiki::BEGIN@646 at line 19 # spent 34µs making 1 call to Foswiki::Plugins::BEGIN@19
# spent 25µs making 1 call to Exporter::import |
20 | |||||
21 | 2 | 124µs | 1 | 3.98ms | # spent 3.98ms (1.94+2.03) within Foswiki::Plugins::BEGIN@21 which was called:
# once (1.94ms+2.03ms) by Foswiki::BEGIN@646 at line 21 # spent 3.98ms making 1 call to Foswiki::Plugins::BEGIN@21 |
22 | |||||
23 | # spent 5µs within Foswiki::Plugins::BEGIN@23 which was called:
# once (5µs+0s) by Foswiki::BEGIN@646 at line 28 | ||||
24 | 1 | 5µs | if ( $Foswiki::cfg{UseLocale} ) { | ||
25 | require locale; | ||||
26 | import locale(); | ||||
27 | } | ||||
28 | 1 | 27µs | 1 | 5µs | } # spent 5µs making 1 call to Foswiki::Plugins::BEGIN@23 |
29 | |||||
30 | =begin TML | ||||
31 | |||||
32 | ---++ PUBLIC constant $VERSION | ||||
33 | |||||
34 | This is the version number of the plugins package. Use it for checking | ||||
35 | if you have a recent enough version. | ||||
36 | |||||
37 | =cut | ||||
38 | |||||
39 | 4 | 1.15ms | 4 | 101µs | # spent 55µs (16+38) within Foswiki::Plugins::BEGIN@39 which was called:
# once (16µs+38µs) by Foswiki::BEGIN@646 at line 39 # spent 55µs making 1 call to Foswiki::Plugins::BEGIN@39
# spent 26µs making 1 call to version::import
# spent 13µs making 1 call to version::vxs::_VERSION
# spent 8µs making 1 call to version::vxs::parse |
40 | |||||
41 | 1 | 200ns | our $inited = 0; | ||
42 | |||||
43 | 1 | 4µs | my %onlyOnceHandlers = ( | ||
44 | registrationHandler => 1, | ||||
45 | writeHeaderHandler => 1, | ||||
46 | redirectCgiQueryHandler => 1, | ||||
47 | renderFormFieldForEditHandler => 1, | ||||
48 | renderWikiWordHandler => 1, | ||||
49 | ); | ||||
50 | |||||
51 | =begin TML | ||||
52 | |||||
53 | ---++ PUBLIC $SESSION | ||||
54 | |||||
55 | This is a reference to the Foswiki session object. It can be used in | ||||
56 | plugins to get at the methods of the Foswiki kernel. | ||||
57 | |||||
58 | You are _highly_ recommended to only use the methods in the | ||||
59 | =Foswiki::Func= interface, unless you have no other choice, | ||||
60 | as kernel methods may change between Foswiki releases. | ||||
61 | |||||
62 | =cut | ||||
63 | |||||
64 | 1 | 100ns | our $SESSION; | ||
65 | |||||
66 | =begin TML | ||||
67 | |||||
68 | ---++ ClassMethod new( $session ) | ||||
69 | |||||
70 | Construct new singleton plugins collection object. The object is a | ||||
71 | container for a list of plugins and the handlers registered by the plugins. | ||||
72 | The plugins and the handlers are carefully ordered. | ||||
73 | |||||
74 | =cut | ||||
75 | |||||
76 | # spent 118ms (32µs+118) within Foswiki::Plugins::new which was called:
# once (32µs+118ms) by Foswiki::new at line 2089 of /var/www/foswikidev/core/lib/Foswiki.pm | ||||
77 | 1 | 1µs | my ( $class, $session ) = @_; | ||
78 | 1 | 5µs | my $this = bless( { session => $session }, $class ); | ||
79 | |||||
80 | # Load the plugins code and invoke preload handlers | ||||
81 | 1 | 2µs | 1 | 118ms | $this->preload(); # spent 118ms making 1 call to Foswiki::Plugins::preload |
82 | |||||
83 | 1 | 900ns | unless ($inited) { | ||
84 | 1 | 4µs | 1 | 6µs | Foswiki::registerTagHandler( 'PLUGINDESCRIPTIONS', # spent 6µs making 1 call to Foswiki::registerTagHandler |
85 | \&_handlePLUGINDESCRIPTIONS ); | ||||
86 | 1 | 2µs | 1 | 2µs | Foswiki::registerTagHandler( 'ACTIVATEDPLUGINS', # spent 2µs making 1 call to Foswiki::registerTagHandler |
87 | \&_handleACTIVATEDPLUGINS ); | ||||
88 | 1 | 2µs | 1 | 2µs | Foswiki::registerTagHandler( 'FAILEDPLUGINS', \&_handleFAILEDPLUGINS ); # spent 2µs making 1 call to Foswiki::registerTagHandler |
89 | 1 | 2µs | 1 | 2µs | Foswiki::registerTagHandler( 'RESTHANDLERS', \&_handleRESTHANDLERS ); # spent 2µs making 1 call to Foswiki::registerTagHandler |
90 | 1 | 600ns | $inited = 1; | ||
91 | } | ||||
92 | |||||
93 | 1 | 4µs | return $this; | ||
94 | } | ||||
95 | |||||
96 | =begin TML | ||||
97 | |||||
98 | ---++ ObjectMethod finish() | ||||
99 | Break circular references. | ||||
100 | |||||
101 | =cut | ||||
102 | |||||
103 | # Note to developers; please undef *all* fields in the object explicitly, | ||||
104 | # whether they are references or not. That way this method is "golden | ||||
105 | # documentation" of the live fields in the object. | ||||
106 | # spent 703µs (165+538) within Foswiki::Plugins::finish which was called:
# once (165µs+538µs) by Foswiki::finish at line 2488 of /var/www/foswikidev/core/lib/Foswiki.pm | ||||
107 | 1 | 500ns | my $this = shift; | ||
108 | |||||
109 | 1 | 1µs | 1 | 184µs | $this->dispatch('finishPlugin'); # spent 184µs making 1 call to Foswiki::Plugins::dispatch |
110 | |||||
111 | 1 | 37µs | undef $this->{registeredHandlers}; | ||
112 | 1 | 2µs | foreach ( @{ $this->{plugins} } ) { | ||
113 | 42 | 62µs | 42 | 354µs | $_->finish(); # spent 354µs making 42 calls to Foswiki::Plugin::finish, avg 8µs/call |
114 | } | ||||
115 | 1 | 26µs | undef $this->{plugins}; | ||
116 | 1 | 5µs | undef $this->{session}; | ||
117 | } | ||||
118 | |||||
119 | =begin TML | ||||
120 | |||||
121 | ---++ ObjectMethod preload() -> $loginName | ||||
122 | |||||
123 | Find all active plugins, load the code and and invoke the preload handler | ||||
124 | |||||
125 | =cut | ||||
126 | |||||
127 | # spent 118ms (466µs+118) within Foswiki::Plugins::preload which was called:
# once (466µs+118ms) by Foswiki::Plugins::new at line 81 | ||||
128 | 1 | 800ns | my ($this) = @_; | ||
129 | 1 | 300ns | my %lookup; | ||
130 | 1 | 600ns | our @pluginList = (); | ||
131 | |||||
132 | 1 | 500ns | my $session = $this->{session}; | ||
133 | 1 | 300ns | my $query = $session->{request}; | ||
134 | |||||
135 | 1 | 200ns | my %already; | ||
136 | 1 | 2µs | unless ( $Foswiki::cfg{DisableAllPlugins} ) { | ||
137 | |||||
138 | # debugenableplugins only supported in DEBUG and unit test modes | ||||
139 | 1 | 3µs | 1 | 17µs | if ( # spent 17µs making 1 call to Foswiki::Request::param |
140 | $query | ||||
141 | && defined( | ||||
142 | $query->param('debugenableplugins') | ||||
143 | && ( DEBUG || $query->isa('Unit::Request') ) | ||||
144 | ) | ||||
145 | ) | ||||
146 | { | ||||
147 | foreach | ||||
148 | my $pn ( split( /[,\s]+/, $query->param('debugenableplugins') ) ) | ||||
149 | { | ||||
150 | push( | ||||
151 | @pluginList, | ||||
152 | Foswiki::Sandbox::untaint( | ||||
153 | $pn, | ||||
154 | sub { | ||||
155 | my $pn = shift; | ||||
156 | throw Error::Simple('Bad debugenableplugins') | ||||
157 | unless $pn =~ m/^[a-zA-Z0-9_]+$/; | ||||
158 | return $pn; | ||||
159 | } | ||||
160 | ) | ||||
161 | ); | ||||
162 | } | ||||
163 | } | ||||
164 | else { | ||||
165 | 1 | 2µs | if ( $Foswiki::cfg{PluginsOrder} ) { | ||
166 | 1 | 5µs | foreach | ||
167 | my $plugin ( split( /[,\s]+/, $Foswiki::cfg{PluginsOrder} ) ) | ||||
168 | { | ||||
169 | |||||
170 | # Note this allows the same plugin to be listed | ||||
171 | # multiple times! Thus their handlers can be called | ||||
172 | # more than once. This is *desireable*. | ||||
173 | 3 | 5µs | if ( $Foswiki::cfg{Plugins}{$plugin}{Enabled} ) { | ||
174 | 2 | 8µs | 2 | 7µs | $plugin = Foswiki::Sandbox::untaintUnchecked($plugin) # spent 7µs making 2 calls to Foswiki::Sandbox::untaintUnchecked, avg 3µs/call |
175 | ; # Item 11953 | ||||
176 | 2 | 2µs | push( @pluginList, $plugin ); | ||
177 | 2 | 2µs | $already{$plugin} = 1; | ||
178 | } | ||||
179 | } | ||||
180 | } | ||||
181 | 1 | 28µs | foreach my $plugin ( sort keys %{ $Foswiki::cfg{Plugins} } ) { | ||
182 | 46 | 19µs | next unless ref( $Foswiki::cfg{Plugins}{$plugin} ) eq 'HASH'; | ||
183 | 45 | 41µs | if ( $Foswiki::cfg{Plugins}{$plugin}{Enabled} | ||
184 | && !$already{$plugin} ) | ||||
185 | { | ||||
186 | 40 | 8µs | push( @pluginList, $plugin ); | ||
187 | 40 | 14µs | $already{$plugin} = 1; | ||
188 | } | ||||
189 | } | ||||
190 | } | ||||
191 | } | ||||
192 | |||||
193 | 1 | 16µs | foreach my $pn (@pluginList) { | ||
194 | 42 | 6µs | my $p; | ||
195 | 42 | 164µs | 42 | 117ms | unless ( $p = $lookup{$pn} ) { # spent 117ms making 42 calls to Foswiki::Plugin::new, avg 2.80ms/call |
196 | |||||
197 | # The 'new' will call the preload handler | ||||
198 | $p = new Foswiki::Plugin( $session, $pn ); | ||||
199 | } | ||||
200 | 42 | 32µs | push @{ $this->{plugins} }, $p; | ||
201 | 42 | 62µs | $lookup{$pn} = $p; | ||
202 | } | ||||
203 | } | ||||
204 | |||||
205 | =begin TML | ||||
206 | |||||
207 | ---++ ObjectMethod load($allDisabled) -> $loginName | ||||
208 | |||||
209 | Find all active plugins, and invoke the early initialisation. | ||||
210 | Has to be done _after_ prefs are read. | ||||
211 | |||||
212 | Returns the user returned by the last =initializeUserHandler= to be | ||||
213 | called. | ||||
214 | |||||
215 | If allDisabled is set, no plugin handlers will be called. | ||||
216 | |||||
217 | =cut | ||||
218 | |||||
219 | # spent 3.06ms (193µs+2.87) within Foswiki::Plugins::load which was called:
# once (193µs+2.87ms) by Foswiki::Users::initialiseUser at line 267 of /var/www/foswikidev/core/lib/Foswiki/Users.pm | ||||
220 | 1 | 600ns | my ($this) = @_; | ||
221 | |||||
222 | 1 | 600ns | my $session = $this->{session}; | ||
223 | |||||
224 | # Uncomment this to monitor plugin load times | ||||
225 | #Monitor::MARK('About to initPlugins'); | ||||
226 | |||||
227 | 1 | 400ns | my $user; # the user login name | ||
228 | 1 | 200ns | my $userDefiner; # the plugin that is defining the user | ||
229 | 1 | 1µs | foreach my $p ( @{ $this->{plugins} } ) { | ||
230 | 42 | 73µs | 42 | 2.87ms | my $anotherUser = $p->load(); # spent 2.87ms making 42 calls to Foswiki::Plugin::load, avg 68µs/call |
231 | 42 | 8µs | if ($anotherUser) { | ||
232 | 1 | 400ns | if ($userDefiner) { | ||
233 | die 'Two plugins - ' | ||||
234 | . $userDefiner->{name} . ' and ' | ||||
235 | . $p->{name} | ||||
236 | . ' are both trying to define the user login name.'; | ||||
237 | } | ||||
238 | else { | ||||
239 | 1 | 200ns | $userDefiner = $p; | ||
240 | 1 | 300ns | $user = $anotherUser; | ||
241 | } | ||||
242 | } | ||||
243 | |||||
244 | # Report initialisation errors | ||||
245 | 42 | 53µs | if ( $p->{errors} && @{ $p->{errors} } ) { | ||
246 | $this->{session} | ||||
247 | ->logger->log( 'error', join( "\n", @{ $p->{errors} } ) ); | ||||
248 | } | ||||
249 | |||||
250 | # Uncomment this to monitor plugin load times | ||||
251 | #Monitor::MARK($pn); | ||||
252 | } | ||||
253 | |||||
254 | 1 | 4µs | return $user; | ||
255 | } | ||||
256 | |||||
257 | =begin TML | ||||
258 | |||||
259 | ---++ ObjectMethod settings() | ||||
260 | |||||
261 | Push plugin settings onto preference stack | ||||
262 | |||||
263 | =cut | ||||
264 | |||||
265 | # spent 12.0ms (92µs+11.9) within Foswiki::Plugins::settings which was called:
# once (92µs+11.9ms) by Foswiki::new at line 2243 of /var/www/foswikidev/core/lib/Foswiki.pm | ||||
266 | 1 | 500ns | my $this = shift; | ||
267 | |||||
268 | # Set the session for this call stack | ||||
269 | 1 | 800ns | local $Foswiki::Plugins::SESSION = $this->{session}; | ||
270 | ASSERT( $Foswiki::Plugins::SESSION->isa('Foswiki') ) if DEBUG; | ||||
271 | |||||
272 | 1 | 5µs | foreach my $plugin ( @{ $this->{plugins} } ) { | ||
273 | 42 | 53µs | 42 | 11.9ms | $plugin->registerSettings($this); # spent 11.9ms making 42 calls to Foswiki::Plugin::registerSettings, avg 285µs/call |
274 | } | ||||
275 | } | ||||
276 | |||||
277 | =begin TML | ||||
278 | |||||
279 | ---++ ObjectMethod enable() | ||||
280 | |||||
281 | Initialisation that is done after the user is known. | ||||
282 | |||||
283 | =cut | ||||
284 | |||||
285 | # spent 65.8ms (179µs+65.6) within Foswiki::Plugins::enable which was called:
# once (179µs+65.6ms) by Foswiki::new at line 2267 of /var/www/foswikidev/core/lib/Foswiki.pm | ||||
286 | 1 | 700ns | my $this = shift; | ||
287 | 1 | 800ns | my $prefs = $this->{session}->{prefs}; | ||
288 | 1 | 3µs | 1 | 35µs | my $dissed = $prefs->getPreference('DISABLEDPLUGINS') || ''; # spent 35µs making 1 call to Foswiki::Prefs::getPreference |
289 | 1 | 2µs | my %disabled = map { s/^\s+//; s/\s+$//; $_ => 1 } split( /,/, $dissed ); | ||
290 | |||||
291 | # Set the session for this call stack | ||||
292 | 1 | 1µs | local $Foswiki::Plugins::SESSION = $this->{session}; | ||
293 | ASSERT( $Foswiki::Plugins::SESSION->isa('Foswiki') ) if DEBUG; | ||||
294 | |||||
295 | 1 | 6µs | foreach my $plugin ( @{ $this->{plugins} } ) { | ||
296 | 42 | 40µs | if ( $disabled{ $plugin->{name} } ) { | ||
297 | $plugin->{disabled} = 1; | ||||
298 | $plugin->{reason} = | ||||
299 | $this->{session} | ||||
300 | ->i18n->maketext('See the DISABLEDPLUGINS preference setting.'); | ||||
301 | push( | ||||
302 | @{ $plugin->{errors} }, | ||||
303 | $plugin->{name} . ' has been disabled' | ||||
304 | ) if DEBUG; | ||||
305 | } | ||||
306 | else { | ||||
307 | 42 | 53µs | 42 | 65.6ms | $plugin->registerHandlers($this); # spent 65.6ms making 42 calls to Foswiki::Plugin::registerHandlers, avg 1.56ms/call |
308 | } | ||||
309 | |||||
310 | # Report initialisation errors | ||||
311 | 42 | 44µs | if ( $plugin->{errors} && @{ $plugin->{errors} } ) { | ||
312 | $this->{session} | ||||
313 | ->logger->log( 'warning', join( "\n", @{ $plugin->{errors} } ) ); | ||||
314 | } | ||||
315 | } | ||||
316 | } | ||||
317 | |||||
318 | =begin TML | ||||
319 | |||||
320 | ---++ ObjectMethod getPluginVersion() -> $number | ||||
321 | |||||
322 | Returns the $Foswiki::Plugins::VERSION number if no parameter is specified, | ||||
323 | else returns the version number of a named Plugin. If the Plugin cannot | ||||
324 | be found or is not active, 0 is returned. | ||||
325 | |||||
326 | =cut | ||||
327 | |||||
328 | sub getPluginVersion { | ||||
329 | my ( $this, $thePlugin ) = @_; | ||||
330 | |||||
331 | return $VERSION unless $thePlugin; | ||||
332 | |||||
333 | foreach my $plugin ( @{ $this->{plugins} } ) { | ||||
334 | if ( $plugin->{name} eq $thePlugin ) { | ||||
335 | return $plugin->getVersion(); | ||||
336 | } | ||||
337 | } | ||||
338 | return 0; | ||||
339 | } | ||||
340 | |||||
341 | =begin TML | ||||
342 | |||||
343 | ---++ ObjectMethod addListener( $command, $handler ) | ||||
344 | |||||
345 | * =$command= - name of the event | ||||
346 | * =$handler= - the handler object. | ||||
347 | |||||
348 | Add a listener to the end of the list of registered listeners for this event. | ||||
349 | The listener must implement =invoke($command,...)=, which will be triggered | ||||
350 | when the event is to be processed. | ||||
351 | |||||
352 | =cut | ||||
353 | |||||
354 | # spent 198µs within Foswiki::Plugins::addListener which was called 86 times, avg 2µs/call:
# 86 times (198µs+0s) by Foswiki::Plugin::registerHandlers at line 298 of /var/www/foswikidev/core/lib/Foswiki/Plugin.pm, avg 2µs/call | ||||
355 | 86 | 43µs | my ( $this, $c, $h ) = @_; | ||
356 | |||||
357 | 86 | 261µs | push( @{ $this->{registeredHandlers}{$c} }, $h ); | ||
358 | } | ||||
359 | |||||
360 | =begin TML | ||||
361 | |||||
362 | ---++ ObjectMethod dispatch( $handlerName, ...) | ||||
363 | Dispatch the given handler, passing on ... in the parameter vector | ||||
364 | |||||
365 | =cut | ||||
366 | |||||
367 | # spent 43.1ms (5.43+37.7) within Foswiki::Plugins::dispatch which was called 350 times, avg 123µs/call:
# 100 times (2.92ms+13.6ms) by Foswiki::expandMacros at line 3625 of /var/www/foswikidev/core/lib/Foswiki.pm, avg 165µs/call
# 100 times (1.39ms+3.07ms) by Foswiki::expandMacros at line 3595 of /var/www/foswikidev/core/lib/Foswiki.pm, avg 45µs/call
# 100 times (536µs+879µs) by Foswiki::expandMacros at line 3658 of /var/www/foswikidev/core/lib/Foswiki.pm, avg 14µs/call
# 18 times (50µs+0s) by Foswiki::Render::internalLink at line 174 of /var/www/foswikidev/core/lib/Foswiki/Render.pm, avg 3µs/call
# 8 times (237µs+680µs) by Foswiki::__ANON__[/var/www/foswikidev/core/lib/Foswiki/Macros/INCLUDE.pm:339] at line 306 of /var/www/foswikidev/core/lib/Foswiki/Macros/INCLUDE.pm, avg 115µs/call
# 5 times (144µs+18.3ms) by Foswiki::Render::getRenderedVersion at line 269 of /var/www/foswikidev/core/lib/Foswiki/Render.pm, avg 3.69ms/call
# 5 times (77µs+448µs) by Foswiki::Render::getRenderedVersion at line 569 of /var/www/foswikidev/core/lib/Foswiki/Render.pm, avg 105µs/call
# 5 times (36µs+446µs) by Foswiki::Render::getRenderedVersion at line 548 of /var/www/foswikidev/core/lib/Foswiki/Render.pm, avg 96µs/call
# 5 times (16µs+0s) by Foswiki::Render::getRenderedVersion at line 261 of /var/www/foswikidev/core/lib/Foswiki/Render.pm, avg 3µs/call
# once (8µs+176µs) by Foswiki::Plugins::finish at line 109
# once (7µs+42µs) by Foswiki::generateHTTPHeaders at line 1095 of /var/www/foswikidev/core/lib/Foswiki.pm
# once (4µs+0s) by Foswiki::writeCompletePage at line 750 of /var/www/foswikidev/core/lib/Foswiki.pm
# once (3µs+0s) by Foswiki::generateHTTPHeaders at line 1067 of /var/www/foswikidev/core/lib/Foswiki.pm | ||||
368 | |||||
369 | # must be shifted to clear parameter vector | ||||
370 | 350 | 84µs | my $this = shift; | ||
371 | 350 | 62µs | my $handlerName = shift; | ||
372 | 350 | 382µs | foreach my $plugin ( @{ $this->{registeredHandlers}{$handlerName} } ) { | ||
373 | |||||
374 | # Set the value of $SESSION for this call stack | ||||
375 | 1632 | 621µs | local $SESSION = $this->{session}; | ||
376 | ASSERT( $Foswiki::Plugins::SESSION->isa('Foswiki') ) if DEBUG; | ||||
377 | |||||
378 | # apply handler on the remaining list of args | ||||
379 | 2 | 40µs | 2 | 34µs | # spent 22µs (10+12) within Foswiki::Plugins::BEGIN@379 which was called:
# once (10µs+12µs) by Foswiki::BEGIN@646 at line 379 # spent 22µs making 1 call to Foswiki::Plugins::BEGIN@379
# spent 12µs making 1 call to strict::unimport |
380 | 1632 | 2.02ms | 1632 | 37.7ms | my $status = $plugin->invoke( $handlerName, @_ ); # spent 37.9ms making 1632 calls to Foswiki::Plugin::invoke, avg 23µs/call, recursion: max depth 1, sum of overlapping time 136µs |
381 | 2 | 822µs | 2 | 27µs | # spent 17µs (8+9) within Foswiki::Plugins::BEGIN@381 which was called:
# once (8µs+9µs) by Foswiki::BEGIN@646 at line 381 # spent 17µs making 1 call to Foswiki::Plugins::BEGIN@381
# spent 9µs making 1 call to strict::import |
382 | 1632 | 912µs | if ( $status && $onlyOnceHandlers{$handlerName} ) { | ||
383 | return $status; | ||||
384 | } | ||||
385 | } | ||||
386 | 350 | 601µs | return; | ||
387 | } | ||||
388 | |||||
389 | =begin TML | ||||
390 | |||||
391 | ---++ ObjectMethod haveHandlerFor( $handlerName ) -> $boolean | ||||
392 | |||||
393 | * =$handlerName= - name of the handler e.g. preRenderingHandler | ||||
394 | Return: true if at least one plugin has registered a handler of | ||||
395 | this type. | ||||
396 | |||||
397 | =cut | ||||
398 | |||||
399 | # spent 24µs within Foswiki::Plugins::haveHandlerFor which was called 10 times, avg 2µs/call:
# 5 times (16µs+0s) by Foswiki::Render::getRenderedVersion at line 271 of /var/www/foswikidev/core/lib/Foswiki/Render.pm, avg 3µs/call
# 5 times (8µs+0s) by Foswiki::Render::getRenderedVersion at line 289 of /var/www/foswikidev/core/lib/Foswiki/Render.pm, avg 2µs/call | ||||
400 | 10 | 6µs | my ( $this, $handlerName ) = @_; | ||
401 | |||||
402 | 10 | 28µs | return 0 unless defined( $this->{registeredHandlers}{$handlerName} ); | ||
403 | return scalar( @{ $this->{registeredHandlers}{$handlerName} } ); | ||||
404 | } | ||||
405 | |||||
406 | # %RESTHANDLERS% reports the registred rest handlers and a bit of information | ||||
407 | # about them | ||||
408 | # | ||||
409 | sub _handleRESTHANDLERS { | ||||
410 | my $this = shift->{plugins}; | ||||
411 | |||||
412 | return | ||||
413 | '%MAKETEXT{"The details about REST Handlers are only available to users with Admin authority."}%' | ||||
414 | unless ( $SESSION->{users}->isAdmin( $SESSION->{user} ) ); | ||||
415 | |||||
416 | require Foswiki::UI::Rest; | ||||
417 | my $restHandlers = Foswiki::UI::Rest::getRegisteredHandlers(); | ||||
418 | my $out = <<DONE | ||||
419 | | *Extension* | *REST Verb* | *HTTP<br />Method* | *Validation* | *Requires<br />Authentication* | *Description* | | ||||
420 | DONE | ||||
421 | ; #Collect output for display | ||||
422 | |||||
423 | foreach my $handler ( sort keys %$restHandlers ) { | ||||
424 | $out .= | ||||
425 | "| [[$Foswiki::cfg{SystemWebName}.$handler][$handler]] | ||||||\n"; | ||||
426 | foreach my $verb ( keys %{ $restHandlers->{$handler} } ) { | ||||
427 | my $method = | ||||
428 | ( defined $restHandlers->{$handler}{$verb}{http_allow} ) | ||||
429 | ? $restHandlers->{$handler}{$verb}{http_allow} | ||||
430 | : 'undef'; | ||||
431 | my $authenticate = | ||||
432 | ( defined $restHandlers->{$handler}{$verb}{authenticate} ) | ||||
433 | ? $restHandlers->{$handler}{$verb}{authenticate} | ||||
434 | : 'undef'; | ||||
435 | my $validate = | ||||
436 | ( defined $restHandlers->{$handler}{$verb}{validate} ) | ||||
437 | ? $restHandlers->{$handler}{$verb}{validate} | ||||
438 | : 'undef'; | ||||
439 | $out .= | ||||
440 | "| | $verb | $method | $validate | $authenticate | " | ||||
441 | . ( $restHandlers->{$handler}{$verb}{description} || '' ) | ||||
442 | . " |\n"; | ||||
443 | |||||
444 | } | ||||
445 | } | ||||
446 | |||||
447 | return $out; | ||||
448 | } | ||||
449 | |||||
450 | # %FAILEDPLUGINS reports reasons why plugins failed to load | ||||
451 | # note this is invoked with the session as the first parameter | ||||
452 | sub _handleFAILEDPLUGINS { | ||||
453 | my $this = shift->{plugins}; | ||||
454 | |||||
455 | my $text = CGI::start_table( | ||||
456 | { | ||||
457 | border => 1, | ||||
458 | class => 'foswikiTable', | ||||
459 | summary => $this->{session}->i18n->maketext("Failed plugins") | ||||
460 | } | ||||
461 | ) . CGI::Tr( {}, CGI::th( {}, 'Plugin' ) . CGI::th( {}, 'Errors' ) ); | ||||
462 | |||||
463 | foreach my $plugin ( @{ $this->{plugins} } ) { | ||||
464 | my $td; | ||||
465 | if ( $plugin->{errors} && @{ $plugin->{errors} } ) { | ||||
466 | $td = CGI::td( | ||||
467 | { class => 'foswikiAlert' }, | ||||
468 | "\n<verbatim>\n" | ||||
469 | . join( "\n", @{ $plugin->{errors} } ) | ||||
470 | . "\n</verbatim>\n" | ||||
471 | ); | ||||
472 | } | ||||
473 | else { | ||||
474 | $td = CGI::td( {}, 'none' ); | ||||
475 | } | ||||
476 | my $web = $plugin->topicWeb(); | ||||
477 | my $modname = ''; | ||||
478 | if ( $SESSION->{users}->isAdmin( $SESSION->{user} ) ) { | ||||
479 | if ( $Foswiki::cfg{Plugins}{ $plugin->{name} }{Module} ) { | ||||
480 | $modname = | ||||
481 | $Foswiki::cfg{Plugins}{ $plugin->{name} }{Module} . ' '; | ||||
482 | } | ||||
483 | else { | ||||
484 | $modname = "Foswiki::Plugins::$plugin->{name} _(guessed)_ "; | ||||
485 | } | ||||
486 | } | ||||
487 | |||||
488 | $text .= CGI::Tr( | ||||
489 | { valign => 'top' }, | ||||
490 | CGI::td( {}, | ||||
491 | ' ' | ||||
492 | . ( $web ? "$web." : '!' ) | ||||
493 | . $plugin->{name} . ' ' | ||||
494 | . CGI::br() | ||||
495 | . $modname ) | ||||
496 | . $td | ||||
497 | ); | ||||
498 | } | ||||
499 | |||||
500 | $text .= CGI::end_table() | ||||
501 | . CGI::start_table( | ||||
502 | { | ||||
503 | border => 1, | ||||
504 | class => 'foswikiTable', | ||||
505 | summary => $this->{session}->i18n->maketext("Plugin handlers") | ||||
506 | } | ||||
507 | ) . CGI::Tr( {}, CGI::th( {}, 'Handler' ) . CGI::th( {}, 'Plugins' ) ); | ||||
508 | |||||
509 | foreach my $handler (@Foswiki::Plugin::registrableHandlers) { | ||||
510 | my $h = ''; | ||||
511 | if ( defined( $this->{registeredHandlers}{$handler} ) ) { | ||||
512 | $h = join( | ||||
513 | CGI::br(), | ||||
514 | map { $_->{name} } @{ $this->{registeredHandlers}{$handler} } | ||||
515 | ); | ||||
516 | } | ||||
517 | if ($h) { | ||||
518 | if ( defined( $Foswiki::Plugin::deprecated{$handler} ) ) { | ||||
519 | $h .= CGI::br() | ||||
520 | . CGI::span( | ||||
521 | { class => 'foswikiAlert' }, | ||||
522 | " __This handler is deprecated__ - please check for updated versions of the plugins that use it!" | ||||
523 | ); | ||||
524 | } | ||||
525 | $text .= CGI::Tr( { valign => 'top' }, | ||||
526 | CGI::td( {}, $handler ) . CGI::td( {}, $h ) ); | ||||
527 | } | ||||
528 | } | ||||
529 | |||||
530 | return | ||||
531 | $text | ||||
532 | . CGI::end_table() . "\n*" | ||||
533 | . scalar( @{ $this->{plugins} } ) | ||||
534 | . " plugins*\n\n"; | ||||
535 | } | ||||
536 | |||||
537 | # note this is invoked with the session as the first parameter | ||||
538 | sub _handlePLUGINDESCRIPTIONS { | ||||
539 | my $this = shift->{plugins}; | ||||
540 | my $text = ''; | ||||
541 | foreach my $plugin ( @{ $this->{plugins} } ) { | ||||
542 | $text .= CGI::li( {}, $plugin->getDescription() . ' ' ); | ||||
543 | } | ||||
544 | |||||
545 | return CGI::ul( {}, $text ); | ||||
546 | } | ||||
547 | |||||
548 | # note this is invoked with the session as the first parameter | ||||
549 | sub _handleACTIVATEDPLUGINS { | ||||
550 | my $this = shift->{plugins}; | ||||
551 | my $text = ''; | ||||
552 | foreach my $plugin ( @{ $this->{plugins} } ) { | ||||
553 | unless ( $plugin->{disabled} ) { | ||||
554 | my $web = $plugin->topicWeb(); | ||||
555 | $text .= ( $web ? "$web." : '!' ) . "$plugin->{name}, "; | ||||
556 | } | ||||
557 | } | ||||
558 | $text =~ s/\,\s*$//; | ||||
559 | return $text; | ||||
560 | } | ||||
561 | |||||
562 | 1 | 5µs | 1; | ||
563 | __END__ |