← Index
NYTProf Performance Profile   « line view »
For ./view
  Run on Fri Jul 31 18:42:36 2015
Reported on Fri Jul 31 18:48:14 2015

Filename/var/www/foswikidev/core/lib/Foswiki/UI/View.pm
StatementsExecuted 163 statements in 4.02ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1112.15ms3.71msFoswiki::UI::View::::BEGIN@25Foswiki::UI::View::BEGIN@25
331934µs137sFoswiki::UI::View::::_prepareFoswiki::UI::View::_prepare
111800µs4.22msFoswiki::UI::View::::BEGIN@23Foswiki::UI::View::BEGIN@23
111590µs137sFoswiki::UI::View::::viewFoswiki::UI::View::view
111160µs163µsFoswiki::UI::View::::BEGIN@15Foswiki::UI::View::BEGIN@15
11195µs4.44msFoswiki::UI::View::::revisionsAroundFoswiki::UI::View::revisionsAround
11113µs27µsFoswiki::UI::View::::BEGIN@13Foswiki::UI::View::BEGIN@13
1119µs14µsFoswiki::UI::View::::BEGIN@14Foswiki::UI::View::BEGIN@14
1118µs34µsFoswiki::UI::View::::BEGIN@17Foswiki::UI::View::BEGIN@17
1115µs5µsFoswiki::UI::View::::BEGIN@27Foswiki::UI::View::BEGIN@27
1115µs5µsFoswiki::UI::View::::BEGIN@24Foswiki::UI::View::BEGIN@24
1114µs4µsFoswiki::UI::View::::BEGIN@16Foswiki::UI::View::BEGIN@16
1114µs4µsFoswiki::UI::View::::BEGIN@19Foswiki::UI::View::BEGIN@19
1113µs3µsFoswiki::UI::View::::BEGIN@21Foswiki::UI::View::BEGIN@21
1113µs3µsFoswiki::UI::View::::BEGIN@20Foswiki::UI::View::BEGIN@20
1113µs3µsFoswiki::UI::View::::BEGIN@22Foswiki::UI::View::BEGIN@22
Call graph for these subroutines as a Graphviz dot language file.
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::UI::View
6
7UI delegate for view function
8
9=cut
10
11package Foswiki::UI::View;
12
13231µs241µs
# spent 27µs (13+14) within Foswiki::UI::View::BEGIN@13 which was called: # once (13µs+14µs) by Foswiki::UI::BEGIN@2 at line 13
use strict;
# spent 27µs making 1 call to Foswiki::UI::View::BEGIN@13 # spent 14µs making 1 call to strict::import
14222µs218µs
# spent 14µs (9+5) within Foswiki::UI::View::BEGIN@14 which was called: # once (9µs+5µs) by Foswiki::UI::BEGIN@2 at line 14
use warnings;
# spent 14µs making 1 call to Foswiki::UI::View::BEGIN@14 # spent 5µs making 1 call to warnings::import
152174µs2165µs
# spent 163µs (160+3) within Foswiki::UI::View::BEGIN@15 which was called: # once (160µs+3µs) by Foswiki::UI::BEGIN@2 at line 15
use integer;
# spent 163µs making 1 call to Foswiki::UI::View::BEGIN@15 # spent 2µs making 1 call to integer::import
16220µs14µs
# spent 4µs within Foswiki::UI::View::BEGIN@16 which was called: # once (4µs+0s) by Foswiki::UI::BEGIN@2 at line 16
use Monitor ();
# spent 4µs making 1 call to Foswiki::UI::View::BEGIN@16
17224µs260µs
# spent 34µs (8+26) within Foswiki::UI::View::BEGIN@17 which was called: # once (8µs+26µs) by Foswiki::UI::BEGIN@2 at line 17
use Assert;
# spent 34µs making 1 call to Foswiki::UI::View::BEGIN@17 # spent 26µs making 1 call to Exporter::import
18
19219µs14µs
# spent 4µs within Foswiki::UI::View::BEGIN@19 which was called: # once (4µs+0s) by Foswiki::UI::BEGIN@2 at line 19
use Foswiki ();
# spent 4µs making 1 call to Foswiki::UI::View::BEGIN@19
20218µs13µs
# spent 3µs within Foswiki::UI::View::BEGIN@20 which was called: # once (3µs+0s) by Foswiki::UI::BEGIN@2 at line 20
use Foswiki::UI ();
# spent 3µs making 1 call to Foswiki::UI::View::BEGIN@20
21218µs13µs
# spent 3µs within Foswiki::UI::View::BEGIN@21 which was called: # once (3µs+0s) by Foswiki::UI::BEGIN@2 at line 21
use Foswiki::Sandbox ();
# spent 3µs making 1 call to Foswiki::UI::View::BEGIN@21
22217µs13µs
# spent 3µs within Foswiki::UI::View::BEGIN@22 which was called: # once (3µs+0s) by Foswiki::UI::BEGIN@2 at line 22
use Foswiki::OopsException ();
# spent 3µs making 1 call to Foswiki::UI::View::BEGIN@22
232114µs14.22ms
# spent 4.22ms (800µs+3.42) within Foswiki::UI::View::BEGIN@23 which was called: # once (800µs+3.42ms) by Foswiki::UI::BEGIN@2 at line 23
use Foswiki::Store ();
# spent 4.22ms making 1 call to Foswiki::UI::View::BEGIN@23
24220µs15µs
# spent 5µs within Foswiki::UI::View::BEGIN@24 which was called: # once (5µs+0s) by Foswiki::UI::BEGIN@2 at line 24
use Foswiki::Serialise ();
# spent 5µs making 1 call to Foswiki::UI::View::BEGIN@24
252125µs13.71ms
# spent 3.71ms (2.15+1.56) within Foswiki::UI::View::BEGIN@25 which was called: # once (2.15ms+1.56ms) by Foswiki::UI::BEGIN@2 at line 25
use Foswiki::PageCache ();
# spent 3.71ms making 1 call to Foswiki::UI::View::BEGIN@25
26
27
# spent 5µs within Foswiki::UI::View::BEGIN@27 which was called: # once (5µs+0s) by Foswiki::UI::BEGIN@2 at line 32
BEGIN {
2815µs if ( $Foswiki::cfg{UseLocale} ) {
29 require locale;
30 import locale();
31 }
3211.89ms15µs}
# spent 5µs making 1 call to Foswiki::UI::View::BEGIN@27
33
34=begin TML
35
36---++ StaticMethod view( $session )
37
38=view= command handler.
39This method is designed to be
40invoked via the =UI::run= method.
41
42Generate a complete HTML page that represents the viewed topics.
43The view is controlled by CGI parameters as follows:
44
45| =rev= | topic revision to view |
46| =section= | restrict view to a named section |
47| =raw= | no format body text if set |
48| =skin= | comma-separated list of skin(s) to use |
49| =contenttype= | Allows you to specify an alternate content type |
50| =release_lock= | Set to non-blank to release any edit locks held by the current user. |
51
52=cut
53
54
# spent 137s (590µs+137) within Foswiki::UI::View::view which was called: # once (590µs+137s) by Foswiki::UI::__ANON__[/var/www/foswikidev/core/lib/Foswiki/UI.pm:376] at line 374 of /var/www/foswikidev/core/lib/Foswiki/UI.pm
sub view {
551800ns my $session = shift;
56
571900ns my $query = $session->{request};
5811µs my $web = $session->{webName};
5911µs my $topic = $session->{topicName};
601800ns my $user = $session->{user};
611700ns my $users = $session->{users};
62
631800ns if ( $session->{invalidTopic} ) {
64 throw Foswiki::OopsException(
65 'accessdenied',
66 status => 404,
67 def => 'invalid_topic_name',
68 web => $web,
69 topic => $topic,
70 params => [ $session->{invalidTopic} ]
71 );
72 }
7312µs119µs if ( defined $query->param('release_lock')
# spent 19µs making 1 call to Foswiki::Request::param
74 && $query->param('release_lock') ne '' )
75 {
76 $query->delete('release_lock');
77 my $topicObject = Foswiki::Meta->new( $session, $web, $topic );
78
79 my $lease = $topicObject->getLease();
80 if ( $lease && $lease->{user} eq $session->{user} ) {
81 $topicObject->clearLease();
82 }
83 $topicObject->finish();
84 }
85
8614µs15µs return if $session->satisfiedByCache( 'view', $web, $topic );
# spent 5µs making 1 call to Foswiki::satisfiedByCache
87
88 Foswiki::Func::writeDebug("computing page for $web.$topic")
89 if Foswiki::PageCache::TRACE();
90
911900ns my $response = $session->{response};
9213µs13µs my $method = $session->{request}->method || '';
# spent 3µs making 1 call to Foswiki::Request::method
9312µs113µs my $raw = $query->param('raw') || '';
# spent 13µs making 1 call to Foswiki::Request::param
9412µs112µs my $requestedRev = $query->param('rev');
# spent 12µs making 1 call to Foswiki::Request::param
95
9612µs112µs my $contentType = $query->param('contenttype');
# spent 12µs making 1 call to Foswiki::Request::param
97
981300ns my $logEntry = '';
99
100 # is this view indexable by search engines? Default yes.
1011200ns my $indexableView = 1;
1021300ns my $viewTemplate;
103
10414µs190µs Foswiki::UI::checkWebExists( $session, $web, 'view' );
# spent 90µs making 1 call to Foswiki::UI::checkWebExists
105
1061300ns if ( defined $requestedRev ) {
107 $requestedRev = Foswiki::Store::cleanUpRevID($requestedRev);
108 unless ($requestedRev) {
109
110 # Invalid request, remove it from the query.
111 $requestedRev = undef;
112 $query->delete('rev');
113 }
114 }
115
1161800ns my $showLatest = !$requestedRev;
1171200ns my $showRev;
118
1191200ns my $topicObject; # the stub of the topic we are to display
1201100ns my $text; # the text to display, *not* necessarily
121 # the same as $topicObject->text
1221500ns my $revIt; # Iterator over the range of available revs
1231200ns my $maxRev;
124
12514µs159µs if ( $session->topicExists( $web, $topic ) ) {
# spent 59µs making 1 call to Foswiki::topicExists
126
127 # Load the most recent rev. This *should* be maxRev, but may
128 # not say it is because the TOPICINFO could be up the spout
12914µs1565µs $topicObject = Foswiki::Meta->load( $session, $web, $topic );
# spent 565µs making 1 call to Foswiki::Meta::load
13014µs137µs Foswiki::UI::checkAccess( $session, 'VIEW', $topicObject );
# spent 37µs making 1 call to Foswiki::UI::checkAccess
131
132 # If we are applying control to the raw view:
1331400ns if ( $raw
134 && defined $Foswiki::cfg{FeatureAccess}{AllowRaw}
135 && $Foswiki::cfg{FeatureAccess}{AllowRaw} ne 'all' )
136 {
137
138 if ( $Foswiki::cfg{FeatureAccess}{AllowRaw} eq 'authenticated' ) {
139 throw Foswiki::AccessControlException( 'authenticated',
140 $session->{user}, $web, $topic, $Foswiki::Meta::reason )
141 unless $session->inContext("authenticated");
142 }
143 else {
144 Foswiki::UI::checkAccess( $session, 'RAW', $topicObject )
145 unless $topicObject->haveAccess('CHANGE');
146 }
147 }
148
149 # If we are applying control to the revisions:
1501400ns if ( $requestedRev
151 && defined $Foswiki::cfg{FeatureAccess}{AllowHistory}
152 && $Foswiki::cfg{FeatureAccess}{AllowHistory} ne 'all' )
153 {
154
155 if ( $Foswiki::cfg{FeatureAccess}{AllowHistory} eq 'authenticated' )
156 {
157 throw Foswiki::AccessControlException( 'authenticated',
158 $session->{user}, $web, $topic, $Foswiki::Meta::reason )
159 unless $session->inContext("authenticated");
160 }
161 else {
162 Foswiki::UI::checkAccess( $session, 'HISTORY', $topicObject );
163 }
164 }
165
16613µs1408µs $revIt = $topicObject->getRevisionHistory();
# spent 408µs making 1 call to Foswiki::Meta::getRevisionHistory
167
168 # The topic exists; it must have at least one rev
169 ASSERT( $revIt->hasNext() ) if DEBUG;
17013µs14µs $maxRev = $revIt->next();
# spent 4µs making 1 call to Foswiki::Iterator::NumberRangeIterator::next
171
17211µs if ( defined $requestedRev ) {
173
174 # Is the requested rev id known?
175 $revIt->reset();
176 while ( $revIt->hasNext() ) {
177 if ( $requestedRev eq $revIt->next() ) {
178 $showRev = $requestedRev;
179 last;
180 }
181 }
182
183 # if rev was not found; show max rev
184 $showRev = $maxRev unless ( defined $showRev );
185
186 if ( $showRev ne $maxRev ) {
187
188 # Load the old revision instead
189 $topicObject =
190 Foswiki::Meta->load( $session, $web, $topic, $showRev );
191 if ( !$topicObject->haveAccess('VIEW') ) {
192 throw Foswiki::AccessControlException( 'VIEW',
193 $session->{user}, $web, $topic,
194 $Foswiki::Meta::reason );
195 }
196 $logEntry .= 'r' . $requestedRev;
197 }
198 }
199 else {
2001400ns $showRev = $maxRev;
201 }
202
20313µs117µs if ( my $section = $query->param('section') ) {
# spent 17µs making 1 call to Foswiki::Request::param
204
205 # Apply the 'section' selection (and maybe others in the
206 # future as well). $text is cleared unless a named section
207 # matching the 'section' URL parameter is found.
208 my ( $ntext, $sections ) =
209 Foswiki::parseSections( $topicObject->text() );
210 $text = ''; # in the beginning, there was ... NO section
211 FINDSECTION:
212 for my $s (@$sections) {
213 if ( $s->{type} eq 'section' && $s->{name} eq $section ) {
214 $text =
215 substr( $ntext, $s->{start}, $s->{end} - $s->{start} );
216 last FINDSECTION;
217 }
218 }
219 }
220 else {
221
222 # Otherwise take the full topic text
22312µs14µs $text = $topicObject->text();
# spent 4µs making 1 call to Foswiki::Meta::text
224 }
225 }
226 else { # Topic does not exist yet
227 $topicObject = Foswiki::Meta->new( $session, $web, $topic );
228
229 # If user would not be able to access the topic, don't reveal that
230 # it does not exist
231 Foswiki::UI::checkAccess( $session, 'VIEW', $topicObject );
232
233 $indexableView = 0;
234 $session->enterContext('new_topic');
235 $response->status(404);
236 $showRev = 1;
237 $maxRev = 0;
238 $viewTemplate = 'TopicDoesNotExistView';
239 $logEntry .= ' (not exist)';
240 $raw = ''; # There is no raw view of a topic that doesn't exist
241 $revIt = new Foswiki::ListIterator( [1] );
242 }
243
2441500ns if ($raw) {
245 $indexableView = 0;
246 $logEntry .= ' raw=' . $raw;
247 if ( $raw eq 'debug' || $raw eq 'all' ) {
248
249 # We want to see the embedded store form
250 $text = Foswiki::Serialise::serialise( $topicObject, 'Embedded' );
251 }
252 }
253
2541300ns $text = '' unless defined $text;
255
256112µs44.97ms $session->logger->log(
# spent 4.47ms making 1 call to Foswiki::logger # spent 496µs making 1 call to Foswiki::Logger::PlainFile::log # spent 2µs making 1 call to Foswiki::Meta::web # spent 2µs making 1 call to Foswiki::Meta::topic
257 {
258 level => 'info',
259 action => 'view',
260 webTopic => $topicObject->web . '.' . $topicObject->topic,
261 extra => $logEntry . " ($method)"
262 }
263 );
264
26511µs if ( $method && $method eq 'HEAD' ) {
266 return $session->writeCompletePage( '', 'view', 'text/plain' );
267 }
268
269 # Note; must enter all contexts before the template is read, as
270 # TMPL:P is expanded on the fly in the template reader. :-(
27111µs my ( $revTitle, $revArg ) = ( '', '' );
27213µs13µs $revIt->reset();
# spent 3µs making 1 call to Foswiki::Iterator::NumberRangeIterator::reset
27312µs12µs if ( $showRev && $showRev != $revIt->next() ) {
# spent 2µs making 1 call to Foswiki::Iterator::NumberRangeIterator::next
274 $session->enterContext('inactive');
275
276 # disable edit of previous revisions
277 $revTitle = '(r' . $showRev . ')';
278 $revArg = '&rev=' . $showRev;
279 }
280
28116µs238µs my $template =
# spent 20µs making 1 call to Foswiki::Prefs::getPreference # spent 18µs making 1 call to Foswiki::Request::param
282 $viewTemplate
283 || $query->param('template')
284 || $session->{prefs}->getPreference('VIEW_TEMPLATE')
285 || 'view';
286
287 # Always use default view template for raw=debug, raw=all and raw=on
2881600ns if ( $raw =~ m/^(debug|all|on)$/ ) {
289 $template = 'view';
290 }
291
29219µs235.0ms my $tmpl = $session->templates->readTemplate( $template, no_oops => 1 );
# spent 35.0ms making 1 call to Foswiki::Templates::readTemplate # spent 2µs making 1 call to Foswiki::templates
293
294 # If the VIEW_TEMPLATE (or other) doesn't exist, default to view.
29511µs $tmpl = $session->templates->readTemplate('view') unless defined($tmpl);
296
297120µs $tmpl =~ s/%REVTITLE%/$revTitle/g;
298120µs $tmpl =~ s/%REVARG%/$revArg/g;
299
30014µs115µs if ( $indexableView
# spent 15µs making 1 call to Foswiki::Request::param
301 && $Foswiki::cfg{AntiSpam}{RobotsAreWelcome}
302 && !$query->param() )
303 {
304
305 # it's an indexable view type, there are no parameters
306 # on the url, and robots are welcome. Remove the NOINDEX meta tag
307 $tmpl =~ s/<meta name="robots"[^>]*>//gi;
308 }
309
310 # Show revisions around the one being displayed.
311133µs14.44ms $tmpl =~ s/%REVISIONS%/
# spent 4.44ms making 1 call to Foswiki::UI::View::revisionsAround
312 revisionsAround(
313 $session, $topicObject, $requestedRev, $showRev, $maxRev)/e;
314
315 ## SMELL: This is also used in Foswiki::_TOC. Could insert a tag in
316 ## TOC and remove all those here, finding the parameters only once
3171900ns my @qparams = ();
31813µs114µs foreach my $name ( $query->param ) {
# spent 14µs making 1 call to Foswiki::Request::param
3192700ns next if ( $name eq 'keywords' );
3202700ns next if ( $name eq 'topic' );
321
322 # SMELL if multi-value is allowed here, this isn't correct,
323 # but calling multi_param doesn't seem correct either.
32412µs115µs push @qparams, $name => scalar( $query->param($name) );
# spent 15µs making 1 call to Foswiki::Request::param
325 }
326
327 # SMELL: %QUERYPARAMSTRING% isn't a documented macro, and is
328 # no longer used in core or core extensions. Maintained for
329 # legacy only.
33017µs if ( $tmpl =~ m/%QUERYPARAMSTRING%/ ) {
331 my $qps = Foswiki::make_params(@qparams);
332 $qps =~ s/^.*\?/;/; # remove any anchor (there should be none) and the ?
333 $tmpl =~ s/%QUERYPARAMSTRING%/$qps/g;
334 }
335
336 # extract header and footer from the template, if there is a
337 # %TEXT% tag marking the split point. The topic text is inserted
338 # in place of the %TEXT% tag. The text before this tag is inserted
339 # as header, the text after is inserted as footer. If there is a
340 # %STARTTEXT% tag present, the header text between %STARTTEXT% and
341 # %TEXT is rendered together, as is the footer text between %TEXT%
342 # and %ENDTEXT%, if present. This allows correct handling of Foswiki
343 # markup in header or footer if those do require examination of the
344 # topic text to work correctly (e.g., %TOC%).
345 # Note: This feature is experimental and may be replaced by an
346 # alternative solution not requiring additional tags.
3471900ns my ( $start, $end );
348
349 # SMELL: unchecked implicit untaint of data that *may* be coming from
350 # a topic (topics can be templates)
3511169µs if ( $tmpl =~ m/^(.*)%TEXT%(.*)$/s ) {
352116µs my @starts = split( /%STARTTEXT%/, $1 );
35311µs if ( $#starts > 0 ) {
354
355 # we know that there is something before %STARTTEXT%
356 $start = $starts[0];
357 $text = $starts[1] . $text;
358 }
359 else {
36012µs $start = $1;
361 }
362110µs my @ends = split( /%ENDTEXT%/, $2 );
36311µs if ( $#ends > 0 ) {
364
365 # we know that there is something after %ENDTEXT%
366 $text .= $ends[0];
367 $end = $ends[1];
368 }
369 else {
37011µs $end = $2;
371 }
372 }
373 else {
374 my @starts = split( /%STARTTEXT%/, $tmpl );
375 if ( $#starts > 0 ) {
376
377 # we know that there is something before %STARTTEXT%
378 $start = $starts[0];
379 $text = $starts[1];
380 }
381 else {
382 $start = $tmpl;
383 $text = '';
384 }
385 $end = '';
386 }
387
388 # If minimalist is set, images and anchors will be stripped from text
3891600ns my $minimalist = 0;
39017µs2117µs if ($contentType) {
# spent 117µs making 2 calls to Foswiki::getSkin, avg 59µs/call
391 $minimalist = ( $session->getSkin() =~ m/\brss/ );
392 }
393 elsif ( $session->getSkin() =~ m/\brss/ ) {
394 $contentType = 'text/xml';
395 $minimalist = 1;
396 }
397 elsif ( $session->getSkin() =~ m/\bxml/ ) {
398 $contentType = 'text/xml';
399 $minimalist = 1;
400 }
401 elsif ( $raw eq 'text' || $raw eq 'all' ) {
402 $contentType = 'text/plain';
403 }
404 else {
4051600ns $contentType = 'text/html';
406 }
40713µs170µs $session->{prefs}->setSessionPreferences(
# spent 70µs making 1 call to Foswiki::Prefs::setSessionPreferences
408 MAXREV => $maxRev,
409 CURRREV => $showRev
410 );
411
412 # Set page generation mode to RSS if using an RSS skin
41316µs159µs if ( $session->getSkin() =~ m/\brss/ ) {
# spent 59µs making 1 call to Foswiki::getSkin
414 $session->enterContext('rss');
415 $session->enterContext('absolute_urls');
416 }
417
4181500ns my $page;
419
420 # Legacy: If the _only_ skin is 'text' it is used like this:
421 # http://.../view/Codev/MyTopic?skin=text&contenttype=text/plain&raw=on
422 # which shows the topic as plain text; useful for those who want
423 # to download plain text for the topic. So when the skin is 'text'
424 # we do _not_ want to create a textarea.
425 # raw=on&skin=text is deprecated; use raw=text instead.
42612µs11µs Monitor::MARK('Ready to render');
42712µs if ( $raw eq 'text'
428 || $raw eq 'all'
429 || ( $raw && $session->getSkin() eq 'text' ) )
430 {
431
432 # use raw text
433 $page = $text;
434 }
435 else {
43611µs my @args = ( $topicObject, $minimalist );
437
43812µs13µs $session->enterContext('header_text');
# spent 3µs making 1 call to Foswiki::enterContext
43913µs1207ms $page = _prepare( $start, @args );
# spent 207ms making 1 call to Foswiki::UI::View::_prepare
44013µs16µs $session->leaveContext('header_text');
# spent 6µs making 1 call to Foswiki::leaveContext
44113µs13µs Monitor::MARK('Rendered header');
442
44312µs if ($raw) {
444 if ($text) {
445 my $p = $session->{prefs};
446 $page .= CGI::textarea(
447 -readonly => 'readonly',
448 -rows => $p->getPreference('EDITBOXHEIGHT'),
449 -cols => $p->getPreference('EDITBOXWIDTH'),
450 -style => $p->getPreference('EDITBOXSTYLE'),
451 -class => 'foswikiTextarea foswikiTextareaRawView',
452 -id => 'topic',
453 -default => $text
454 );
455 }
456 }
457 else {
45812µs14µs $session->enterContext('body_text');
# spent 4µs making 1 call to Foswiki::enterContext
459115µs1137s $page .= _prepare( $text, @args );
# spent 137s making 1 call to Foswiki::UI::View::_prepare
46015µs110µs $session->leaveContext('body_text');
# spent 10µs making 1 call to Foswiki::leaveContext
461 }
462
46315µs15µs Monitor::MARK('Rendered body');
46412µs16µs $session->enterContext('footer_text');
# spent 6µs making 1 call to Foswiki::enterContext
465115µs1165ms $page .= _prepare( $end, @args );
# spent 165ms making 1 call to Foswiki::UI::View::_prepare
46614µs16µs $session->leaveContext('footer_text');
# spent 6µs making 1 call to Foswiki::leaveContext
46716µs13µs Monitor::MARK('Rendered footer');
468 }
469
470 # Output has to be done in one go, because if we generate the header and
471 # then redirect because of some later constraint, some browsers fall over
47216µs123.4ms $session->writeCompletePage( $page, 'view', $contentType );
# spent 23.4ms making 1 call to Foswiki::writeCompletePage
473130µs12µs Monitor::MARK('Wrote HTML');
474}
475
476
# spent 137s (934µs+137) within Foswiki::UI::View::_prepare which was called 3 times, avg 45.7s/call: # once (79µs+137s) by Foswiki::UI::View::view at line 459 # once (310µs+207ms) by Foswiki::UI::View::view at line 439 # once (545µs+165ms) by Foswiki::UI::View::view at line 465
sub _prepare {
47737µs my ( $text, $topicObject, $minimalist ) = @_;
478
479311µs3137s $text = $topicObject->expandMacros($text);
# spent 137s making 3 calls to Foswiki::Meta::expandMacros, avg 45.7s/call
480311µs344.3ms $text = $topicObject->renderTML($text);
# spent 44.3ms making 3 calls to Foswiki::Meta::renderTML, avg 14.8ms/call
4813884µs $text =~ s/( ?) *<\/?(nop|noautolink)\/?>\n?/$1/gis;
482
48332µs if ($minimalist) {
484 $text =~ s/<img [^>]*>//gi; # remove image tags
485 $text =~ s/<a [^>]*>//gi; # remove anchor tags
486 $text =~ s/<\/a>//gi; # remove anchor tags
487 }
488
489323µs return $text;
490}
491
492=begin TML
493
494---++ StaticMethod revisionsAround($session, $topicObject, $requestedRev, $showRev, $maxRev) -> $output
495
496Calculate the revisions spanning the current one for display in the bottom
497bar.
498
499=cut
500
501
# spent 4.44ms (95µs+4.35) within Foswiki::UI::View::revisionsAround which was called: # once (95µs+4.35ms) by Foswiki::UI::View::view at line 311
sub revisionsAround {
50212µs my ( $session, $topicObject, $requestedRev, $showRev, $maxRev ) = @_;
503
50412µs my $revsToShow = $Foswiki::cfg{NumberOfRevisions} + 1;
505
506 # Soak up the revision iterator
50712µs1339µs my $revIt = $topicObject->getRevisionHistory();
# spent 339µs making 1 call to Foswiki::Meta::getRevisionHistory
50816µs142µs my @revs = $revIt->all();
# spent 42µs making 1 call to Foswiki::Iterator::all
5091300ns my $maxRevDisjoint = 0;
510
51111µs if ( $Foswiki::cfg{NumberOfRevisions} ) {
512
513 # Locate the preferred rev in the array
5141600ns my $showIndex = $#revs;
5151400ns my $left = 0;
5161700ns my $right = $Foswiki::cfg{NumberOfRevisions};
5171400ns if ($requestedRev) {
518 while ( $showIndex && $revs[$showIndex] != $showRev ) {
519 $showIndex--;
520 }
521 $right = $showIndex + $Foswiki::cfg{NumberOfRevisions} - 1;
522 $right = scalar(@revs) if $right > scalar(@revs);
523 $left = $right - $Foswiki::cfg{NumberOfRevisions};
524 if ( $left < 0 ) {
525 $left = 0;
526 $right = $Foswiki::cfg{NumberOfRevisions};
527 }
528 }
5291600ns splice( @revs, $right ) if ( $right < scalar(@revs) );
53011µs splice( @revs, 0, $left );
5311500ns if ( $left > 0 ) {
532
533 # Put the max rev back in at the front, and flag
534 # special treatment
535 $maxRevDisjoint = 1;
536 unshift( @revs, $maxRev );
537 }
538 }
539
5401600ns my $output = '';
5411300ns my $r = 0;
5421800ns while ( $r < scalar(@revs) ) {
54335µs if ( $revs[$r] == $showRev ) {
544 $output .= 'r' . $showRev;
545 }
546 else {
547215µs8180µs $output .= CGI::a(
# spent 101µs making 2 calls to Foswiki::getScriptUrl, avg 51µs/call # spent 72µs making 2 calls to CGI::a, avg 36µs/call # spent 4µs making 2 calls to Foswiki::Meta::web, avg 2µs/call # spent 3µs making 2 calls to Foswiki::Meta::topic, avg 2µs/call
548 {
549 href => $session->getScriptUrl(
550 0, 'view',
551 $topicObject->web, $topicObject->topic,
552 rev => $revs[$r]
553 ),
554 rel => 'nofollow'
555 },
556 'r' . $revs[$r]
557 );
558 }
559325µs83.06ms if ( $r == 0 && $maxRevDisjoint ) {
# spent 2.87ms making 1 call to CGI::AUTOLOAD # spent 157µs making 2 calls to Foswiki::getScriptUrl, avg 78µs/call # spent 35µs making 1 call to CGI::a # spent 4µs making 2 calls to Foswiki::Meta::web, avg 2µs/call # spent 3µs making 2 calls to Foswiki::Meta::topic, avg 2µs/call
560 $output .= ' | ';
561 }
562 elsif ( $r < $#revs ) {
563 $output .= '&nbsp;'
564 . CGI::a(
565 {
566 href => $session->getScriptUrl(
567 0, 'rdiff', $topicObject->web, $topicObject->topic,
568 rev1 => $revs[ $r + 1 ],
569 rev2 => $revs[$r]
570 ),
571 rel => 'nofollow'
572 },
573 '&lt;'
574 ) . '&nbsp;';
575 }
57632µs $r++;
577 }
57817µs return $output;
579}
580
58112µs1;
582__END__