← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/local/src/github.com/foswiki/core/bin/view
  Run on Sun Dec 4 17:17:59 2011
Reported on Sun Dec 4 17:27:13 2011

Filename/usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/CommentPlugin.pm
StatementsExecuted 31 statements in 1.51ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1113.23ms442msFoswiki::Plugins::CommentPlugin::::_COMMENTFoswiki::Plugins::CommentPlugin::_COMMENT
11146µs3.23msFoswiki::Plugins::CommentPlugin::::initPluginFoswiki::Plugins::CommentPlugin::initPlugin
11132µs619µsFoswiki::Plugins::CommentPlugin::::BEGIN@10Foswiki::Plugins::CommentPlugin::BEGIN@10
11127µs35µsFoswiki::Plugins::CommentPlugin::::BEGIN@7Foswiki::Plugins::CommentPlugin::BEGIN@7
11122µs39µsFoswiki::Plugins::CommentPlugin::::BEGIN@8Foswiki::Plugins::CommentPlugin::BEGIN@8
11119µs93µsFoswiki::Plugins::CommentPlugin::::BEGIN@9Foswiki::Plugins::CommentPlugin::BEGIN@9
11110µs10µsFoswiki::Plugins::CommentPlugin::::BEGIN@13Foswiki::Plugins::CommentPlugin::BEGIN@13
11110µs10µsFoswiki::Plugins::CommentPlugin::::BEGIN@12Foswiki::Plugins::CommentPlugin::BEGIN@12
0000s0sFoswiki::Plugins::CommentPlugin::::__ANON__[:113]Foswiki::Plugins::CommentPlugin::__ANON__[:113]
0000s0sFoswiki::Plugins::CommentPlugin::::__ANON__[:122]Foswiki::Plugins::CommentPlugin::__ANON__[:122]
0000s0sFoswiki::Plugins::CommentPlugin::::__ANON__[:131]Foswiki::Plugins::CommentPlugin::__ANON__[:131]
0000s0sFoswiki::Plugins::CommentPlugin::::_restSaveFoswiki::Plugins::CommentPlugin::_restSave
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# See Plugin topic for history and plugin information
4
5package Foswiki::Plugins::CommentPlugin;
6
7247µs243µs
# spent 35µs (27+8) within Foswiki::Plugins::CommentPlugin::BEGIN@7 which was called: # once (27µs+8µs) by Foswiki::Plugin::BEGIN@2.5 at line 7
use strict;
# spent 35µs making 1 call to Foswiki::Plugins::CommentPlugin::BEGIN@7 # spent 8µs making 1 call to strict::import
8245µs257µs
# spent 39µs (22+18) within Foswiki::Plugins::CommentPlugin::BEGIN@8 which was called: # once (22µs+18µs) by Foswiki::Plugin::BEGIN@2.5 at line 8
use warnings;
# spent 39µs making 1 call to Foswiki::Plugins::CommentPlugin::BEGIN@8 # spent 18µs making 1 call to warnings::import
9257µs2167µs
# spent 93µs (19+74) within Foswiki::Plugins::CommentPlugin::BEGIN@9 which was called: # once (19µs+74µs) by Foswiki::Plugin::BEGIN@2.5 at line 9
use Assert;
# spent 93µs making 1 call to Foswiki::Plugins::CommentPlugin::BEGIN@9 # spent 74µs making 1 call to Assert::import
10277µs21.21ms
# spent 619µs (32+587) within Foswiki::Plugins::CommentPlugin::BEGIN@10 which was called: # once (32µs+587µs) by Foswiki::Plugin::BEGIN@2.5 at line 10
use Error ':try';
# spent 619µs making 1 call to Foswiki::Plugins::CommentPlugin::BEGIN@10 # spent 587µs making 1 call to Error::import
11
12240µs110µs
# spent 10µs within Foswiki::Plugins::CommentPlugin::BEGIN@12 which was called: # once (10µs+0s) by Foswiki::Plugin::BEGIN@2.5 at line 12
use Foswiki::Func ();
# spent 10µs making 1 call to Foswiki::Plugins::CommentPlugin::BEGIN@12
132990µs110µs
# spent 10µs within Foswiki::Plugins::CommentPlugin::BEGIN@13 which was called: # once (10µs+0s) by Foswiki::Plugin::BEGIN@2.5 at line 13
use Foswiki::Plugins ();
# spent 10µs making 1 call to Foswiki::Plugins::CommentPlugin::BEGIN@13
14
1512µsour $VERSION = '$Rev$';
1611µsour $RELEASE = '26 Oct 2011';
1711µsour $SHORTDESCRIPTION =
18 'Quickly post comments to a page without an edit/save cycle';
1911µsour $NO_PREFS_IN_TOPIC = 1;
20
21# Reset when the plugin is reset, this counter counts the instances of the
22# %COMMENT macro and indexes them.
2311µsour $commentIndex;
24
25
# spent 3.23ms (46µs+3.18) within Foswiki::Plugins::CommentPlugin::initPlugin which was called: # once (46µs+3.18ms) by Foswiki::Plugin::__ANON__[/usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugin.pm:235] at line 228 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugin.pm
sub initPlugin {
26
2713µs my ( $topic, $web, $user, $installWeb ) = @_;
2812µs $commentIndex = 0;
29
30112µs187µs Foswiki::Func::registerTagHandler( 'COMMENT', \&_COMMENT );
# spent 87µs making 1 call to Foswiki::Func::registerTagHandler
3119µs13.09ms Foswiki::Func::registerRESTHandler(
# spent 3.09ms making 1 call to Foswiki::Func::registerRESTHandler
32 'comment', \&_restSave,
33
34 # validate => 1, # TODO: needs javascript work
35 http_allow => 'POST'
36 );
37
3817µs15µs if ( (DEBUG)
# spent 5µs making 1 call to Assert::ASSERTS_OFF
39 && $web eq $Foswiki::cfg{SystemWebName}
40 && $topic eq 'InstalledPlugins' )
41 {
42
43 # Compilation check
44 require Foswiki::Plugins::CommentPlugin::Comment;
45 }
46110µs return 1;
47}
48
49
# spent 442ms (3.23+438) within Foswiki::Plugins::CommentPlugin::_COMMENT which was called: # once (3.23ms+438ms) by Foswiki::Func::__ANON__[/usr/local/src/github.com/foswiki/core/lib/Foswiki/Func.pm:573] at line 568 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Func.pm
sub _COMMENT {
5013µs my ( $session, $params, $topic, $web ) = @_;
51
52 # Indexing each macro instance
5315µs $params->{comment_index} = $commentIndex++;
54
55 # Check the context has 'view' script
5615µs113µs my $context = Foswiki::Func::getContext();
# spent 13µs making 1 call to Foswiki::Func::getContext
5712µs my $disabled = '';
5815µs if ( $context->{command_line} ) {
59 $disabled = Foswiki::Func::expandCommonVariables(
60'%MAKETEXT{"Commenting is disabled while running from the command line"}%'
61 );
62 }
63 elsif ( !$context->{view} ) {
64 $disabled = Foswiki::Func::expandCommonVariables(
65 '%MAKETEXT{"Commenting is disabled when not in view context"}%');
66 }
67 elsif (
68 !(
69 $Foswiki::cfg{Plugins}{CommentPlugin}{GuestCanComment}
70 || $context->{authenticated}
71 )
72 )
73 {
74 $disabled = Foswiki::Func::expandCommonVariables(
75 '%MAKETEXT{"Commenting is disabled while not logged in"}%');
76 }
77
781156µs require Foswiki::Plugins::CommentPlugin::Comment;
79
80126µs1437ms Foswiki::Plugins::CommentPlugin::Comment::prompt( $params, $web, $topic,
# spent 437ms making 1 call to Foswiki::Plugins::CommentPlugin::Comment::prompt
81 $disabled );
82}
83
84# REST handler for save operator. We use a REST handler because we need
85# to be able to bypass the permissions checking that the save script
86# would do. We handle the return in several different ways; first, if
87# everything is OK, we set a 200 status and drop back to allow any
88# endPoint to be handled. Second, if we get an exception, and the
89# 'comment_ajax' parameter is set, we return a 500 status. If the
90# parameter is not set, we pass the exception on to the UI package.
91
92sub _restSave {
93 my $session = shift;
94 my $response = $session->{response};
95 my $query = Foswiki::Func::getCgiQuery();
96 my ( $web, $topic ) =
97 Foswiki::Func::normalizeWebTopicName( undef, $query->param('topic') );
98
99 try {
100 require Foswiki::Plugins::CommentPlugin::Comment;
101
102 my ( $meta, $text ) = Foswiki::Func::readTopic( $web, $topic );
103
104 # The save function does access control checking
105 $text =
106 Foswiki::Plugins::CommentPlugin::Comment::save( $text, $web, $topic );
107
108 Foswiki::Func::saveTopic( $web, $topic, $meta, $text,
109 { ignorepermissions => 1 } );
110
111 $response->header( -status => 200 );
112 $response->body("$web.$topic");
113 }
114 catch Foswiki::AccessControlException with {
115 if ( $query->param('comment_ajax') ) {
116 $response->header( -status => 404 );
117 $response->body(shift);
118 }
119 else {
120 shift->throw;
121 }
122 }
123 otherwise {
124 if ( $query->param('comment_ajax') ) {
125 $response->header( -status => 500 );
126 $response->body(shift);
127 }
128 else {
129 shift->throw;
130 }
131 };
132 return undef;
133}
134
13516µs1;
136__END__