Filename | /var/www/foswiki11/lib/Foswiki/Plugins.pm |
Statements | Executed 2067 statements in 4.99ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
68 | 13 | 4 | 1.96ms | 40.5ms | dispatch (recurses: max depth 1, inclusive time 594µs) | Foswiki::Plugins::
1 | 1 | 1 | 1.81ms | 3.67ms | BEGIN@21 | Foswiki::Plugins::
1 | 1 | 1 | 542µs | 97.9ms | load | Foswiki::Plugins::
1 | 1 | 1 | 287µs | 1.30s | settings | Foswiki::Plugins::
79 | 1 | 1 | 260µs | 260µs | addListener | Foswiki::Plugins::
1 | 1 | 1 | 255µs | 49.9ms | enable | Foswiki::Plugins::
1 | 1 | 1 | 186µs | 668µs | finish | Foswiki::Plugins::
10 | 2 | 1 | 32µs | 32µs | haveHandlerFor | Foswiki::Plugins::
1 | 1 | 1 | 21µs | 29µs | new | Foswiki::Plugins::
1 | 1 | 1 | 17µs | 56µs | BEGIN@32 | Foswiki::Plugins::
1 | 1 | 1 | 14µs | 27µs | BEGIN@17 | Foswiki::Plugins::
1 | 1 | 1 | 12µs | 18µs | BEGIN@18 | Foswiki::Plugins::
1 | 1 | 1 | 9µs | 21µs | BEGIN@340 | Foswiki::Plugins::
1 | 1 | 1 | 8µs | 21µs | BEGIN@19 | Foswiki::Plugins::
1 | 1 | 1 | 8µs | 17µs | BEGIN@342 | Foswiki::Plugins::
0 | 0 | 0 | 0s | 0s | __ANON__[:147] | 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 | 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 | 41µs | # spent 27µs (14+14) within Foswiki::Plugins::BEGIN@17 which was called:
# once (14µs+14µs) by Foswiki::BEGIN@634 at line 17 # spent 27µs making 1 call to Foswiki::Plugins::BEGIN@17
# spent 14µs making 1 call to strict::import |
18 | 2 | 25µs | 2 | 24µs | # spent 18µs (12+6) within Foswiki::Plugins::BEGIN@18 which was called:
# once (12µs+6µs) by Foswiki::BEGIN@634 at line 18 # spent 18µs making 1 call to Foswiki::Plugins::BEGIN@18
# spent 6µs making 1 call to warnings::import |
19 | 2 | 23µs | 2 | 34µs | # spent 21µs (8+13) within Foswiki::Plugins::BEGIN@19 which was called:
# once (8µs+13µs) by Foswiki::BEGIN@634 at line 19 # spent 21µs making 1 call to Foswiki::Plugins::BEGIN@19
# spent 13µs making 1 call to Assert::import |
20 | |||||
21 | 2 | 105µs | 1 | 3.67ms | # spent 3.67ms (1.81+1.86) within Foswiki::Plugins::BEGIN@21 which was called:
# once (1.81ms+1.86ms) by Foswiki::BEGIN@634 at line 21 # spent 3.67ms making 1 call to Foswiki::Plugins::BEGIN@21 |
22 | |||||
23 | =begin TML | ||||
24 | |||||
25 | ---++ PUBLIC constant $VERSION | ||||
26 | |||||
27 | This is the version number of the plugins package. Use it for checking | ||||
28 | if you have a recent enough version. | ||||
29 | |||||
30 | =cut | ||||
31 | |||||
32 | 4 | 1.02ms | 4 | 103µs | # spent 56µs (17+39) within Foswiki::Plugins::BEGIN@32 which was called:
# once (17µs+39µs) by Foswiki::BEGIN@634 at line 32 # spent 56µs making 1 call to Foswiki::Plugins::BEGIN@32
# spent 27µs making 1 call to version::import
# spent 12µs making 1 call to version::vxs::_VERSION
# spent 8µs making 1 call to version::vxs::parse |
33 | |||||
34 | 1 | 200ns | our $inited = 0; | ||
35 | |||||
36 | 1 | 3µs | my %onlyOnceHandlers = ( | ||
37 | registrationHandler => 1, | ||||
38 | writeHeaderHandler => 1, | ||||
39 | redirectCgiQueryHandler => 1, | ||||
40 | renderFormFieldForEditHandler => 1, | ||||
41 | renderWikiWordHandler => 1, | ||||
42 | ); | ||||
43 | |||||
44 | =begin TML | ||||
45 | |||||
46 | ---++ PUBLIC $SESSION | ||||
47 | |||||
48 | This is a reference to the Foswiki session object. It can be used in | ||||
49 | plugins to get at the methods of the Foswiki kernel. | ||||
50 | |||||
51 | You are _highly_ recommended to only use the methods in the | ||||
52 | =Foswiki::Func= interface, unless you have no other choice, | ||||
53 | as kernel methods may change between Foswiki releases. | ||||
54 | |||||
55 | =cut | ||||
56 | |||||
57 | 1 | 100ns | our $SESSION; | ||
58 | |||||
59 | =begin TML | ||||
60 | |||||
61 | ---++ ClassMethod new( $session ) | ||||
62 | |||||
63 | Construct new singleton plugins collection object. The object is a | ||||
64 | container for a list of plugins and the handlers registered by the plugins. | ||||
65 | The plugins and the handlers are carefully ordered. | ||||
66 | |||||
67 | =cut | ||||
68 | |||||
69 | # spent 29µs (21+8) within Foswiki::Plugins::new which was called:
# once (21µs+8µs) by Foswiki::new at line 1754 of /var/www/foswiki11/lib/Foswiki.pm | ||||
70 | 1 | 900ns | my ( $class, $session ) = @_; | ||
71 | 1 | 6µs | my $this = bless( { session => $session }, $class ); | ||
72 | |||||
73 | 1 | 500ns | unless ($inited) { | ||
74 | 1 | 2µs | 1 | 3µs | Foswiki::registerTagHandler( 'PLUGINDESCRIPTIONS', # spent 3µs making 1 call to Foswiki::registerTagHandler |
75 | \&_handlePLUGINDESCRIPTIONS ); | ||||
76 | 1 | 2µs | 1 | 2µs | Foswiki::registerTagHandler( 'ACTIVATEDPLUGINS', # spent 2µs making 1 call to Foswiki::registerTagHandler |
77 | \&_handleACTIVATEDPLUGINS ); | ||||
78 | 1 | 1µs | 1 | 2µs | Foswiki::registerTagHandler( 'FAILEDPLUGINS', \&_handleFAILEDPLUGINS ); # spent 2µs making 1 call to Foswiki::registerTagHandler |
79 | 1 | 600ns | $inited = 1; | ||
80 | } | ||||
81 | |||||
82 | 1 | 5µs | return $this; | ||
83 | } | ||||
84 | |||||
85 | =begin TML | ||||
86 | |||||
87 | ---++ ObjectMethod finish() | ||||
88 | Break circular references. | ||||
89 | |||||
90 | =cut | ||||
91 | |||||
92 | # Note to developers; please undef *all* fields in the object explicitly, | ||||
93 | # whether they are references or not. That way this method is "golden | ||||
94 | # documentation" of the live fields in the object. | ||||
95 | # spent 668µs (186+483) within Foswiki::Plugins::finish which was called:
# once (186µs+483µs) by Foswiki::finish at line 2163 of /var/www/foswiki11/lib/Foswiki.pm | ||||
96 | 1 | 600ns | my $this = shift; | ||
97 | |||||
98 | 1 | 2µs | 1 | 166µs | $this->dispatch('finishPlugin'); # spent 166µs making 1 call to Foswiki::Plugins::dispatch |
99 | |||||
100 | 1 | 40µs | undef $this->{registeredHandlers}; | ||
101 | 1 | 2µs | foreach ( @{ $this->{plugins} } ) { | ||
102 | 37 | 66µs | 37 | 316µs | $_->finish(); # spent 316µs making 37 calls to Foswiki::Plugin::finish, avg 9µs/call |
103 | } | ||||
104 | 1 | 34µs | undef $this->{plugins}; | ||
105 | 1 | 6µs | undef $this->{session}; | ||
106 | } | ||||
107 | |||||
108 | =begin TML | ||||
109 | |||||
110 | ---++ ObjectMethod load($allDisabled) -> $loginName | ||||
111 | |||||
112 | Find all active plugins, and invoke the early initialisation. | ||||
113 | Has to be done _after_ prefs are read. | ||||
114 | |||||
115 | Returns the user returned by the last =initializeUserHandler= to be | ||||
116 | called. | ||||
117 | |||||
118 | If allDisabled is set, no plugin handlers will be called. | ||||
119 | |||||
120 | =cut | ||||
121 | |||||
122 | # spent 97.9ms (542µs+97.4) within Foswiki::Plugins::load which was called:
# once (542µs+97.4ms) by Foswiki::Users::initialiseUser at line 266 of /var/www/foswiki11/lib/Foswiki/Users.pm | ||||
123 | 1 | 2µs | my ( $this, $allDisabled ) = @_; | ||
124 | |||||
125 | 1 | 500ns | my %lookup; | ||
126 | |||||
127 | 1 | 800ns | my $session = $this->{session}; | ||
128 | 1 | 2µs | my $query = $session->{request}; | ||
129 | |||||
130 | 1 | 700ns | my @pluginList = (); | ||
131 | 1 | 200ns | my %already; | ||
132 | |||||
133 | 1 | 2µs | unless ($allDisabled) { | ||
134 | 1 | 6µs | 1 | 42µs | if ( $query && defined( $query->param('debugenableplugins') ) ) { # spent 42µs making 1 call to Foswiki::Request::param |
135 | foreach | ||||
136 | my $pn ( split( /[,\s]+/, $query->param('debugenableplugins') ) ) | ||||
137 | { | ||||
138 | push( | ||||
139 | @pluginList, | ||||
140 | Foswiki::Sandbox::untaint( | ||||
141 | $pn, | ||||
142 | sub { | ||||
143 | my $pn = shift; | ||||
144 | throw Error::Simple('Bad debugenableplugins') | ||||
145 | unless $pn =~ /^\w+$/; | ||||
146 | return $pn; | ||||
147 | } | ||||
148 | ) | ||||
149 | ); | ||||
150 | } | ||||
151 | } | ||||
152 | else { | ||||
153 | 1 | 2µs | if ( $Foswiki::cfg{PluginsOrder} ) { | ||
154 | 1 | 5µs | foreach | ||
155 | my $plugin ( split( /[,\s]+/, $Foswiki::cfg{PluginsOrder} ) ) | ||||
156 | { | ||||
157 | |||||
158 | # Note this allows the same plugin to be listed | ||||
159 | # multiple times! Thus their handlers can be called | ||||
160 | # more than once. This is *desireable*. | ||||
161 | 3 | 6µs | if ( $Foswiki::cfg{Plugins}{$plugin}{Enabled} ) { | ||
162 | 3 | 2µs | push( @pluginList, $plugin ); | ||
163 | 3 | 4µs | $already{$plugin} = 1; | ||
164 | } | ||||
165 | } | ||||
166 | } | ||||
167 | 1 | 31µs | foreach my $plugin ( sort keys %{ $Foswiki::cfg{Plugins} } ) { | ||
168 | 41 | 18µs | next unless ref( $Foswiki::cfg{Plugins}{$plugin} ) eq 'HASH'; | ||
169 | 40 | 38µs | if ( $Foswiki::cfg{Plugins}{$plugin}{Enabled} | ||
170 | && !$already{$plugin} ) | ||||
171 | { | ||||
172 | 34 | 8µs | push( @pluginList, $plugin ); | ||
173 | 34 | 16µs | $already{$plugin} = 1; | ||
174 | } | ||||
175 | } | ||||
176 | } | ||||
177 | } | ||||
178 | |||||
179 | # Uncomment this to monitor plugin load times | ||||
180 | #Monitor::MARK('About to initPlugins'); | ||||
181 | |||||
182 | 1 | 100ns | my $user; # the user login name | ||
183 | 1 | 300ns | my $userDefiner; # the plugin that is defining the user | ||
184 | 1 | 1µs | foreach my $pn (@pluginList) { | ||
185 | 37 | 4µs | my $p; | ||
186 | 37 | 128µs | 37 | 386µs | unless ( $p = $lookup{$pn} ) { # spent 386µs making 37 calls to Foswiki::Plugin::new, avg 10µs/call |
187 | $p = new Foswiki::Plugin( $session, $pn ); | ||||
188 | } | ||||
189 | 37 | 30µs | push @{ $this->{plugins} }, $p; | ||
190 | 37 | 58µs | 37 | 92.2ms | my $anotherUser = $p->load(); # spent 92.2ms making 37 calls to Foswiki::Plugin::load, avg 2.49ms/call |
191 | 37 | 9µs | if ($anotherUser) { | ||
192 | 1 | 300ns | if ($userDefiner) { | ||
193 | die 'Two plugins - ' | ||||
194 | . $userDefiner->{name} . ' and ' | ||||
195 | . $p->{name} | ||||
196 | . ' are both trying to define the user login name.'; | ||||
197 | } | ||||
198 | else { | ||||
199 | 1 | 400ns | $userDefiner = $p; | ||
200 | 1 | 200ns | $user = $anotherUser; | ||
201 | } | ||||
202 | } | ||||
203 | |||||
204 | # Report initialisation errors | ||||
205 | 37 | 27µs | 2 | 4.79ms | if ( $p->{errors} ) { # spent 2.95ms making 1 call to Foswiki::logger
# spent 1.85ms making 1 call to Foswiki::Logger::PlainFile::log |
206 | $this->{session} | ||||
207 | ->logger->log( 'warning', join( "\n", @{ $p->{errors} } ) ); | ||||
208 | } | ||||
209 | 37 | 54µs | $lookup{$pn} = $p; | ||
210 | |||||
211 | # Uncomment this to monitor plugin load times | ||||
212 | #Monitor::MARK($pn); | ||||
213 | } | ||||
214 | |||||
215 | 1 | 80µs | return $user; | ||
216 | } | ||||
217 | |||||
218 | =begin TML | ||||
219 | |||||
220 | ---++ ObjectMethod settings() | ||||
221 | |||||
222 | Push plugin settings onto preference stack | ||||
223 | |||||
224 | =cut | ||||
225 | |||||
226 | # spent 1.30s (287µs+1.30) within Foswiki::Plugins::settings which was called:
# once (287µs+1.30s) by Foswiki::new at line 1955 of /var/www/foswiki11/lib/Foswiki.pm | ||||
227 | 1 | 600ns | my $this = shift; | ||
228 | |||||
229 | # Set the session for this call stack | ||||
230 | 1 | 900ns | local $Foswiki::Plugins::SESSION = $this->{session}; | ||
231 | 1 | 1µs | 1 | 1µs | ASSERT( $Foswiki::Plugins::SESSION->isa('Foswiki') ) if DEBUG; # spent 1µs making 1 call to Assert::ASSERTS_OFF |
232 | |||||
233 | 1 | 34µs | foreach my $plugin ( @{ $this->{plugins} } ) { | ||
234 | 37 | 193µs | 37 | 1.30s | $plugin->registerSettings($this); # spent 1.30s making 37 calls to Foswiki::Plugin::registerSettings, avg 35.1ms/call |
235 | } | ||||
236 | } | ||||
237 | |||||
238 | =begin TML | ||||
239 | |||||
240 | ---++ ObjectMethod enable() | ||||
241 | |||||
242 | Initialisation that is done after the user is known. | ||||
243 | |||||
244 | =cut | ||||
245 | |||||
246 | # spent 49.9ms (255µs+49.6) within Foswiki::Plugins::enable which was called:
# once (255µs+49.6ms) by Foswiki::new at line 1976 of /var/www/foswiki11/lib/Foswiki.pm | ||||
247 | 1 | 600ns | my $this = shift; | ||
248 | 1 | 2µs | my $prefs = $this->{session}->{prefs}; | ||
249 | 1 | 5µs | 1 | 56µs | my $dissed = $prefs->getPreference('DISABLEDPLUGINS') || ''; # spent 56µs making 1 call to Foswiki::Prefs::getPreference |
250 | 1 | 3µs | my %disabled = map { s/^\s+//; s/\s+$//; $_ => 1 } split( /,/, $dissed ); | ||
251 | |||||
252 | # Set the session for this call stack | ||||
253 | 1 | 1µs | local $Foswiki::Plugins::SESSION = $this->{session}; | ||
254 | 1 | 2µs | 1 | 2µs | ASSERT( $Foswiki::Plugins::SESSION->isa('Foswiki') ) if DEBUG; # spent 2µs making 1 call to Assert::ASSERTS_OFF |
255 | |||||
256 | 1 | 9µs | foreach my $plugin ( @{ $this->{plugins} } ) { | ||
257 | 37 | 55µs | if ( $disabled{ $plugin->{name} } ) { | ||
258 | $plugin->{disabled} = 1; | ||||
259 | $plugin->{reason} = | ||||
260 | $this->{session} | ||||
261 | ->i18n->maketext('See the DISABLEDPLUGINS preference setting.'); | ||||
262 | push( | ||||
263 | @{ $plugin->{errors} }, | ||||
264 | $plugin->{name} . ' has been disabled' | ||||
265 | ); | ||||
266 | } | ||||
267 | else { | ||||
268 | 37 | 65µs | 37 | 49.3ms | $plugin->registerHandlers($this); # spent 49.3ms making 37 calls to Foswiki::Plugin::registerHandlers, avg 1.33ms/call |
269 | } | ||||
270 | |||||
271 | # Report initialisation errors | ||||
272 | 37 | 69µs | 2 | 321µs | if ( $plugin->{errors} ) { # spent 312µs making 1 call to Foswiki::Logger::PlainFile::log
# spent 10µs making 1 call to Foswiki::logger |
273 | $this->{session} | ||||
274 | ->logger->log( 'warning', join( "\n", @{ $plugin->{errors} } ) ); | ||||
275 | } | ||||
276 | } | ||||
277 | } | ||||
278 | |||||
279 | =begin TML | ||||
280 | |||||
281 | ---++ ObjectMethod getPluginVersion() -> $number | ||||
282 | |||||
283 | Returns the $Foswiki::Plugins::VERSION number if no parameter is specified, | ||||
284 | else returns the version number of a named Plugin. If the Plugin cannot | ||||
285 | be found or is not active, 0 is returned. | ||||
286 | |||||
287 | =cut | ||||
288 | |||||
289 | sub getPluginVersion { | ||||
290 | my ( $this, $thePlugin ) = @_; | ||||
291 | |||||
292 | return $VERSION unless $thePlugin; | ||||
293 | |||||
294 | foreach my $plugin ( @{ $this->{plugins} } ) { | ||||
295 | if ( $plugin->{name} eq $thePlugin ) { | ||||
296 | return $plugin->getVersion(); | ||||
297 | } | ||||
298 | } | ||||
299 | return 0; | ||||
300 | } | ||||
301 | |||||
302 | =begin TML | ||||
303 | |||||
304 | ---++ ObjectMethod addListener( $command, $handler ) | ||||
305 | |||||
306 | * =$command= - name of the event | ||||
307 | * =$handler= - the handler object. | ||||
308 | |||||
309 | Add a listener to the end of the list of registered listeners for this event. | ||||
310 | The listener must implement =invoke($command,...)=, which will be triggered | ||||
311 | when the event is to be processed. | ||||
312 | |||||
313 | =cut | ||||
314 | |||||
315 | # spent 260µs within Foswiki::Plugins::addListener which was called 79 times, avg 3µs/call:
# 79 times (260µs+0s) by Foswiki::Plugin::registerHandlers at line 282 of /var/www/foswiki11/lib/Foswiki/Plugin.pm, avg 3µs/call | ||||
316 | 79 | 51µs | my ( $this, $c, $h ) = @_; | ||
317 | |||||
318 | 79 | 335µs | push( @{ $this->{registeredHandlers}{$c} }, $h ); | ||
319 | } | ||||
320 | |||||
321 | =begin TML | ||||
322 | |||||
323 | ---++ ObjectMethod dispatch( $handlerName, ...) | ||||
324 | Dispatch the given handler, passing on ... in the parameter vector | ||||
325 | |||||
326 | =cut | ||||
327 | |||||
328 | # spent 40.5ms (1.96+38.5) within Foswiki::Plugins::dispatch which was called 68 times, avg 595µs/call:
# 17 times (73µs+0s) by Foswiki::Render::internalLink at line 585 of /var/www/foswiki11/lib/Foswiki/Render.pm, avg 4µs/call
# 7 times (548µs+6.88ms) by Foswiki::expandMacros at line 3347 of /var/www/foswiki11/lib/Foswiki.pm, avg 1.06ms/call
# 7 times (241µs+457µs) by Foswiki::expandMacros at line 3317 of /var/www/foswiki11/lib/Foswiki.pm, avg 100µs/call
# 7 times (72µs+88µs) by Foswiki::expandMacros at line 3380 of /var/www/foswiki11/lib/Foswiki.pm, avg 23µs/call
# 6 times (589µs+2.10ms) by Foswiki::__ANON__[/var/www/foswiki11/lib/Foswiki/Macros/INCLUDE.pm:331] at line 303 of /var/www/foswiki11/lib/Foswiki/Macros/INCLUDE.pm, avg 449µs/call
# 5 times (162µs+18.4ms) by Foswiki::Render::getRenderedVersion at line 1166 of /var/www/foswiki11/lib/Foswiki/Render.pm, avg 3.71ms/call
# 5 times (74µs+9.67ms) by Foswiki::Render::getRenderedVersion at line 1158 of /var/www/foswiki11/lib/Foswiki/Render.pm, avg 1.95ms/call
# 5 times (146µs+717µs) by Foswiki::Render::getRenderedVersion at line 1466 of /var/www/foswiki11/lib/Foswiki/Render.pm, avg 173µs/call
# 5 times (16µs+0s) by Foswiki::Render::getRenderedVersion at line 1448 of /var/www/foswiki11/lib/Foswiki/Render.pm, avg 3µs/call
# once (12µs+154µs) by Foswiki::Plugins::finish at line 98
# once (12µs+70µs) by Foswiki::generateHTTPHeaders at line 951 of /var/www/foswiki11/lib/Foswiki.pm
# once (6µs+0s) by Foswiki::writeCompletePage at line 832 of /var/www/foswiki11/lib/Foswiki.pm
# once (6µs+0s) by Foswiki::generateHTTPHeaders at line 927 of /var/www/foswiki11/lib/Foswiki.pm | ||||
329 | |||||
330 | # must be shifted to clear parameter vector | ||||
331 | 68 | 26µs | my $this = shift; | ||
332 | 68 | 19µs | my $handlerName = shift; | ||
333 | 68 | 151µs | foreach my $plugin ( @{ $this->{registeredHandlers}{$handlerName} } ) { | ||
334 | |||||
335 | # Set the value of $SESSION for this call stack | ||||
336 | 238 | 152µs | local $SESSION = $this->{session}; | ||
337 | 238 | 329µs | 238 | 286µs | ASSERT( $Foswiki::Plugins::SESSION->isa('Foswiki') ) if DEBUG; # spent 286µs making 238 calls to Assert::ASSERTS_OFF, avg 1µs/call |
338 | |||||
339 | # apply handler on the remaining list of args | ||||
340 | 2 | 36µs | 2 | 33µs | # spent 21µs (9+12) within Foswiki::Plugins::BEGIN@340 which was called:
# once (9µs+12µs) by Foswiki::BEGIN@634 at line 340 # spent 21µs making 1 call to Foswiki::Plugins::BEGIN@340
# spent 12µs making 1 call to strict::unimport |
341 | 238 | 451µs | 238 | 38.5ms | my $status = $plugin->invoke( $handlerName, @_ ); # spent 38.8ms making 238 calls to Foswiki::Plugin::invoke, avg 163µs/call, recursion: max depth 1, sum of overlapping time 381µs |
342 | 2 | 584µs | 2 | 26µs | # spent 17µs (8+9) within Foswiki::Plugins::BEGIN@342 which was called:
# once (8µs+9µs) by Foswiki::BEGIN@634 at line 342 # spent 17µs making 1 call to Foswiki::Plugins::BEGIN@342
# spent 9µs making 1 call to strict::import |
343 | 238 | 248µs | if ( $status && $onlyOnceHandlers{$handlerName} ) { | ||
344 | return $status; | ||||
345 | } | ||||
346 | } | ||||
347 | 68 | 208µs | return; | ||
348 | } | ||||
349 | |||||
350 | =begin TML | ||||
351 | |||||
352 | ---++ ObjectMethod haveHandlerFor( $handlerName ) -> $boolean | ||||
353 | |||||
354 | * =$handlerName= - name of the handler e.g. preRenderingHandler | ||||
355 | Return: true if at least one plugin has registered a handler of | ||||
356 | this type. | ||||
357 | |||||
358 | =cut | ||||
359 | |||||
360 | # spent 32µs within Foswiki::Plugins::haveHandlerFor which was called 10 times, avg 3µs/call:
# 5 times (22µs+0s) by Foswiki::Render::getRenderedVersion at line 1168 of /var/www/foswiki11/lib/Foswiki/Render.pm, avg 4µs/call
# 5 times (10µs+0s) by Foswiki::Render::getRenderedVersion at line 1186 of /var/www/foswiki11/lib/Foswiki/Render.pm, avg 2µs/call | ||||
361 | 10 | 7µs | my ( $this, $handlerName ) = @_; | ||
362 | |||||
363 | 10 | 38µs | return 0 unless defined( $this->{registeredHandlers}{$handlerName} ); | ||
364 | return scalar( @{ $this->{registeredHandlers}{$handlerName} } ); | ||||
365 | } | ||||
366 | |||||
367 | # %FAILEDPLUGINS reports reasons why plugins failed to load | ||||
368 | # note this is invoked with the session as the first parameter | ||||
369 | sub _handleFAILEDPLUGINS { | ||||
370 | my $this = shift->{plugins}; | ||||
371 | |||||
372 | my $text = CGI::start_table( | ||||
373 | { | ||||
374 | border => 1, | ||||
375 | class => 'foswikiTable', | ||||
376 | summary => $this->{session}->i18n->maketext("Failed plugins") | ||||
377 | } | ||||
378 | ) . CGI::Tr( {}, CGI::th( {}, 'Plugin' ) . CGI::th( {}, 'Errors' ) ); | ||||
379 | |||||
380 | foreach my $plugin ( @{ $this->{plugins} } ) { | ||||
381 | my $td; | ||||
382 | if ( $plugin->{errors} ) { | ||||
383 | $td = CGI::td( | ||||
384 | { class => 'foswikiAlert' }, | ||||
385 | "\n<verbatim>\n" | ||||
386 | . join( "\n", @{ $plugin->{errors} } ) | ||||
387 | . "\n</verbatim>\n" | ||||
388 | ); | ||||
389 | } | ||||
390 | else { | ||||
391 | $td = CGI::td( {}, 'none' ); | ||||
392 | } | ||||
393 | my $web = $plugin->topicWeb(); | ||||
394 | $text .= CGI::Tr( | ||||
395 | { valign => 'top' }, | ||||
396 | CGI::td( | ||||
397 | {}, | ||||
398 | ' ' | ||||
399 | . ( $web ? "$web." : '!' ) | ||||
400 | . $plugin->{name} . ' ' | ||||
401 | . CGI::br() | ||||
402 | . ( | ||||
403 | $SESSION->{users}->isAdmin( $SESSION->{user} ) | ||||
404 | ? $Foswiki::cfg{Plugins}{ $plugin->{name} }{Module} . ' ' | ||||
405 | : '' | ||||
406 | ) | ||||
407 | ) | ||||
408 | . $td | ||||
409 | ); | ||||
410 | } | ||||
411 | |||||
412 | $text .= CGI::end_table() | ||||
413 | . CGI::start_table( | ||||
414 | { | ||||
415 | border => 1, | ||||
416 | class => 'foswikiTable', | ||||
417 | summary => $this->{session}->i18n->maketext("Plugin handlers") | ||||
418 | } | ||||
419 | ) . CGI::Tr( {}, CGI::th( {}, 'Handler' ) . CGI::th( {}, 'Plugins' ) ); | ||||
420 | |||||
421 | foreach my $handler (@Foswiki::Plugin::registrableHandlers) { | ||||
422 | my $h = ''; | ||||
423 | if ( defined( $this->{registeredHandlers}{$handler} ) ) { | ||||
424 | $h = join( | ||||
425 | CGI::br(), | ||||
426 | map { $_->{name} } @{ $this->{registeredHandlers}{$handler} } | ||||
427 | ); | ||||
428 | } | ||||
429 | if ($h) { | ||||
430 | if ( defined( $Foswiki::Plugin::deprecated{$handler} ) ) { | ||||
431 | $h .= CGI::br() | ||||
432 | . CGI::span( | ||||
433 | { class => 'foswikiAlert' }, | ||||
434 | " __This handler is deprecated__ - please check for updated versions of the plugins that use it!" | ||||
435 | ); | ||||
436 | } | ||||
437 | $text .= CGI::Tr( { valign => 'top' }, | ||||
438 | CGI::td( {}, $handler ) . CGI::td( {}, $h ) ); | ||||
439 | } | ||||
440 | } | ||||
441 | |||||
442 | return | ||||
443 | $text | ||||
444 | . CGI::end_table() . "\n*" | ||||
445 | . scalar( @{ $this->{plugins} } ) | ||||
446 | . " plugins*\n\n"; | ||||
447 | } | ||||
448 | |||||
449 | # note this is invoked with the session as the first parameter | ||||
450 | sub _handlePLUGINDESCRIPTIONS { | ||||
451 | my $this = shift->{plugins}; | ||||
452 | my $text = ''; | ||||
453 | foreach my $plugin ( @{ $this->{plugins} } ) { | ||||
454 | $text .= CGI::li( {}, $plugin->getDescription() . ' ' ); | ||||
455 | } | ||||
456 | |||||
457 | return CGI::ul( {}, $text ); | ||||
458 | } | ||||
459 | |||||
460 | # note this is invoked with the session as the first parameter | ||||
461 | sub _handleACTIVATEDPLUGINS { | ||||
462 | my $this = shift->{plugins}; | ||||
463 | my $text = ''; | ||||
464 | foreach my $plugin ( @{ $this->{plugins} } ) { | ||||
465 | unless ( $plugin->{disabled} ) { | ||||
466 | my $web = $plugin->topicWeb(); | ||||
467 | $text .= ( $web ? "$web." : '!' ) . "$plugin->{name}, "; | ||||
468 | } | ||||
469 | } | ||||
470 | $text =~ s/\,\s*$//o; | ||||
471 | return $text; | ||||
472 | } | ||||
473 | |||||
474 | 1 | 5µs | 1; | ||
475 | __END__ |