← 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:26:57 2011

Filename/usr/local/src/github.com/foswiki/core/lib/Foswiki/Contrib/MailerContrib/WebNotify.pm
StatementsExecuted 286073 statements in 1.18s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1216411645ms169sFoswiki::Contrib::MailerContrib::WebNotify::::subscribeFoswiki::Contrib::MailerContrib::WebNotify::subscribe
1216411337ms170sFoswiki::Contrib::MailerContrib::WebNotify::::_subscribeTopicFoswiki::Contrib::MailerContrib::WebNotify::_subscribeTopic
1218222135ms147msFoswiki::Contrib::MailerContrib::WebNotify::::getSubscriberFoswiki::Contrib::MailerContrib::WebNotify::getSubscriber
21170.2ms175sFoswiki::Contrib::MailerContrib::WebNotify::::_loadFoswiki::Contrib::MailerContrib::WebNotify::_load
10681124.2ms171sFoswiki::Contrib::MailerContrib::WebNotify::::parsePageSubscriptionsFoswiki::Contrib::MailerContrib::WebNotify::parsePageSubscriptions
32522114.2ms14.2msFoswiki::Contrib::MailerContrib::WebNotify::::CORE:matchFoswiki::Contrib::MailerContrib::WebNotify::CORE:match (opcode)
2186217.91ms7.91msFoswiki::Contrib::MailerContrib::WebNotify::::CORE:regcompFoswiki::Contrib::MailerContrib::WebNotify::CORE:regcomp (opcode)
2138316.39ms6.39msFoswiki::Contrib::MailerContrib::WebNotify::::CORE:substFoswiki::Contrib::MailerContrib::WebNotify::CORE:subst (opcode)
1111.79ms1.95msFoswiki::Contrib::MailerContrib::WebNotify::::BEGIN@23Foswiki::Contrib::MailerContrib::WebNotify::BEGIN@23
1111.21ms1.69msFoswiki::Contrib::MailerContrib::WebNotify::::BEGIN@24Foswiki::Contrib::MailerContrib::WebNotify::BEGIN@24
211399µs175sFoswiki::Contrib::MailerContrib::WebNotify::::newFoswiki::Contrib::MailerContrib::WebNotify::new
21136µs36µsFoswiki::Contrib::MailerContrib::WebNotify::::CORE:qrFoswiki::Contrib::MailerContrib::WebNotify::CORE:qr (opcode)
11131µs39µsFoswiki::Contrib::MailerContrib::WebNotify::::BEGIN@15Foswiki::Contrib::MailerContrib::WebNotify::BEGIN@15
11129µs98µsFoswiki::Contrib::MailerContrib::WebNotify::::BEGIN@19Foswiki::Contrib::MailerContrib::WebNotify::BEGIN@19
11128µs38µsFoswiki::Contrib::MailerContrib::WebNotify::::BEGIN@17Foswiki::Contrib::MailerContrib::WebNotify::BEGIN@17
11121µs40µsFoswiki::Contrib::MailerContrib::WebNotify::::BEGIN@16Foswiki::Contrib::MailerContrib::WebNotify::BEGIN@16
1119µs9µsFoswiki::Contrib::MailerContrib::WebNotify::::BEGIN@21Foswiki::Contrib::MailerContrib::WebNotify::BEGIN@21
1119µs9µsFoswiki::Contrib::MailerContrib::WebNotify::::BEGIN@22Foswiki::Contrib::MailerContrib::WebNotify::BEGIN@22
0000s0sFoswiki::Contrib::MailerContrib::WebNotify::::_emailWarnFoswiki::Contrib::MailerContrib::WebNotify::_emailWarn
0000s0sFoswiki::Contrib::MailerContrib::WebNotify::::getSubscribersFoswiki::Contrib::MailerContrib::WebNotify::getSubscribers
0000s0sFoswiki::Contrib::MailerContrib::WebNotify::::isEmptyFoswiki::Contrib::MailerContrib::WebNotify::isEmpty
0000s0sFoswiki::Contrib::MailerContrib::WebNotify::::processChangeFoswiki::Contrib::MailerContrib::WebNotify::processChange
0000s0sFoswiki::Contrib::MailerContrib::WebNotify::::processCompulsoryFoswiki::Contrib::MailerContrib::WebNotify::processCompulsory
0000s0sFoswiki::Contrib::MailerContrib::WebNotify::::stringifyFoswiki::Contrib::MailerContrib::WebNotify::stringify
0000s0sFoswiki::Contrib::MailerContrib::WebNotify::::unsubscribeFoswiki::Contrib::MailerContrib::WebNotify::unsubscribe
0000s0sFoswiki::Contrib::MailerContrib::WebNotify::::writeWebNotifyFoswiki::Contrib::MailerContrib::WebNotify::writeWebNotify
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::Contrib::MailerContrib::WebNotify
6Object that represents the contents of a %NOTIFYTOPIC% topic in a Foswiki web.
7
8Note that =$Foswiki::Plugins::SESSION= is used to find the Foswiki session, and
9must be set up before this class is used.
10
11=cut
12
13package Foswiki::Contrib::MailerContrib::WebNotify;
14
15257µs247µs
# spent 39µs (31+8) within Foswiki::Contrib::MailerContrib::WebNotify::BEGIN@15 which was called: # once (31µs+8µs) by Foswiki::Contrib::MailerContrib::BEGIN@25 at line 15
use strict;
# spent 39µs making 1 call to Foswiki::Contrib::MailerContrib::WebNotify::BEGIN@15 # spent 8µs making 1 call to strict::import
16246µs260µs
# spent 40µs (21+19) within Foswiki::Contrib::MailerContrib::WebNotify::BEGIN@16 which was called: # once (21µs+19µs) by Foswiki::Contrib::MailerContrib::BEGIN@25 at line 16
use warnings;
# spent 40µs making 1 call to Foswiki::Contrib::MailerContrib::WebNotify::BEGIN@16 # spent 20µs making 1 call to warnings::import
17258µs247µs
# spent 38µs (28+10) within Foswiki::Contrib::MailerContrib::WebNotify::BEGIN@17 which was called: # once (28µs+10µs) by Foswiki::Contrib::MailerContrib::BEGIN@25 at line 17
use locale; # required for matching \w with international characters
# spent 38µs making 1 call to Foswiki::Contrib::MailerContrib::WebNotify::BEGIN@17 # spent 10µs making 1 call to locale::import
18
19256µs2166µs
# spent 98µs (29+69) within Foswiki::Contrib::MailerContrib::WebNotify::BEGIN@19 which was called: # once (29µs+69µs) by Foswiki::Contrib::MailerContrib::BEGIN@25 at line 19
use Assert;
# spent 98µs making 1 call to Foswiki::Contrib::MailerContrib::WebNotify::BEGIN@19 # spent 69µs making 1 call to Assert::import
20
21240µs19µs
# spent 9µs within Foswiki::Contrib::MailerContrib::WebNotify::BEGIN@21 which was called: # once (9µs+0s) by Foswiki::Contrib::MailerContrib::BEGIN@25 at line 21
use Foswiki::Func ();
22238µs19µs
# spent 9µs within Foswiki::Contrib::MailerContrib::WebNotify::BEGIN@22 which was called: # once (9µs+0s) by Foswiki::Contrib::MailerContrib::BEGIN@25 at line 22
use Foswiki::Contrib::MailerContrib ();
232182µs11.95ms
# spent 1.95ms (1.79+160µs) within Foswiki::Contrib::MailerContrib::WebNotify::BEGIN@23 which was called: # once (1.79ms+160µs) by Foswiki::Contrib::MailerContrib::BEGIN@25 at line 23
use Foswiki::Contrib::MailerContrib::Subscriber ();
2422.98ms11.69ms
# spent 1.69ms (1.21+477µs) within Foswiki::Contrib::MailerContrib::WebNotify::BEGIN@24 which was called: # once (1.21ms+477µs) by Foswiki::Contrib::MailerContrib::BEGIN@25 at line 24
use Foswiki::Contrib::MailerContrib::Subscription ();
25
26=begin TML
27
28---++ new($web, $topic)
29 * =$web= - web name
30 * =$topic= - topic name
31 * =$noexpandgroups= - True will prevent expansion of group subscriptions
32 (False is best for checking subscriptions, but True is best for
33 writing results back to $topic)
34
35Create a new object by parsing the content of the given topic in the
36given web. This is the normal way to load a %NOTIFYTOPIC% topic. If the
37topic does not exist, it will create an empty object.
38
39=cut
40
41
# spent 175s (399µs+175) within Foswiki::Contrib::MailerContrib::WebNotify::new which was called 2 times, avg 87.7s/call: # 2 times (399µs+175s) by Foswiki::Contrib::MailerContrib::_isSubscribedToTopic at line 160 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Contrib/MailerContrib.pm, avg 87.7s/call
sub new {
4220376µs my ( $class, $web, $topic, $noexpandgroups ) = @_;
43
44 my $this = bless( {}, $class );
45
46 # Ensure the contrib is initialised
47219µs Foswiki::Contrib::MailerContrib::initContrib();
# spent 19µs making 2 calls to Foswiki::Contrib::MailerContrib::initContrib, avg 9µs/call
48
49 $this->{web} = $web;
50 $this->{topic} = $topic || $Foswiki::cfg{NotifyTopicName} || 'WebNotify';
51 $this->{pretext} = '';
52 $this->{posttext} = '';
53 $this->{noexpandgroups} = $noexpandgroups;
54
55218µs2681µs if ( Foswiki::Func::topicExists( $web, $topic ) ) {
# spent 681µs making 2 calls to Foswiki::Func::topicExists, avg 341µs/call
562175s $this->_load();
# spent 175s making 2 calls to Foswiki::Contrib::MailerContrib::WebNotify::_load, avg 87.7s/call
57 }
58
59 return $this;
60}
61
62=begin TML
63
64---++ writeWebNotify()
65Write the object to the %NOTIFYTOPIC% topic it was read from.
66If there is a problem writing the topic (e.g. it is locked),
67the method will throw an exception.
68
69=cut
70
71sub writeWebNotify {
72 my $this = shift;
73 Foswiki::Func::saveTopicText( $this->{web}, $this->{topic},
74 $this->stringify(), 1, 1 );
75}
76
77=begin TML
78
79---++ getSubscriber($name, $noAdd)
80 * =$name= - Name of subscriber (wikiname with no web or email address)
81 * =$noAdd= - If false or undef, a new subscriber will be created for this name
82Get a subscriber from the list of subscribers, and return a reference
83to the Subscriber object. If $noAdd is true, and the subscriber is not
84found, undef will be returned. Otherwise a new Subscriber object will
85be added if necessary.
86
87=cut
88
89
# spent 147ms (135+11.4) within Foswiki::Contrib::MailerContrib::WebNotify::getSubscriber which was called 12182 times, avg 12µs/call: # 12180 times (135ms+11.4ms) by Foswiki::Contrib::MailerContrib::WebNotify::subscribe at line 142, avg 12µs/call # 2 times (21µs+0s) by Foswiki::Contrib::MailerContrib::_isSubscribedToTopic at line 163 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Contrib/MailerContrib.pm, avg 10µs/call
sub getSubscriber {
9048728142ms my ( $this, $name, $noAdd ) = @_;
91
92 my $subscriber = $this->{subscribers}{$name};
9321329.85ms unless ( $noAdd || defined($subscriber) ) {
94106611.4ms $subscriber = new Foswiki::Contrib::MailerContrib::Subscriber($name);
# spent 11.4ms making 1066 calls to Foswiki::Contrib::MailerContrib::Subscriber::new, avg 11µs/call
95 $this->{subscribers}{$name} = $subscriber;
96 }
97 return $subscriber;
98}
99
100=begin TML
101
102---++ getSubscribers()
103Get a list of all subscriber names (unsorted)
104
105=cut
106
107sub getSubscribers {
108 my ($this) = @_;
109
110 return keys %{ $this->{subscribers} };
111}
112
113=begin TML
114
115---++ subscribe($name, $topics, $depth, $options)
116 * =$name= - Name of subscriber (wikiname with no web or email address)
117 * =$topics= - wildcard expression giving topics to subscribe to
118 * =$depth= - Child depth to scan (default 0)
119 * =$options= - Bitmap of Mailer::Const options
120Add a subscription, adding the subscriber if necessary.
121
122=cut
123
124
# spent 169s (645ms+169) within Foswiki::Contrib::MailerContrib::WebNotify::subscribe which was called 12164 times, avg 13.9ms/call: # 12164 times (645ms+169s) by Foswiki::Contrib::MailerContrib::WebNotify::_subscribeTopic at line 446, avg 13.9ms/call
sub subscribe {
12560820261ms my ( $this, $name, $topics, $depth, $opts ) = @_;
126
1271216440.2ms ASSERT( defined($opts) && $opts =~ /^\d*$/ ) if DEBUG;
# spent 40.2ms making 12164 calls to Assert::ASSERTS_OFF, avg 3µs/call
128
129 my @names = ($name);
1302432882.3ms unless ( $this->{noexpandgroups} ) {
131121644.28s my $it = Foswiki::Func::eachGroupMember($name);
# spent 4.28s making 12164 calls to Foswiki::Func::eachGroupMember, avg 352µs/call
132426µs if ($it) {
133 @names = ();
1342326µs while ( $it->hasNext() ) {
# spent 326µs making 2 calls to Foswiki::AggregateIterator::hasNext, avg 163µs/call
13536241µs185.71ms my $member = $it->next();
# spent 5.71ms making 18 calls to Foswiki::AggregateIterator::next, avg 317µs/call
136181.55ms push( @names, $member );
# spent 1.55ms making 18 calls to Foswiki::AggregateIterator::hasNext, avg 86µs/call
137 }
138 }
139 }
140
141 foreach my $n (@names) {
14236540238ms12180147ms my $subscriber = $this->getSubscriber($n);
# spent 147ms making 12180 calls to Foswiki::Contrib::MailerContrib::WebNotify::getSubscriber, avg 12µs/call
14312180776ms my $sub =
# spent 776ms making 12180 calls to Foswiki::Contrib::MailerContrib::Subscription::new, avg 64µs/call
144 new Foswiki::Contrib::MailerContrib::Subscription( $topics, $depth,
145 $opts );
14612180163s $subscriber->subscribe($sub);
# spent 163s making 12180 calls to Foswiki::Contrib::MailerContrib::Subscriber::subscribe, avg 13.4ms/call
147 }
148}
149
150=begin TML
151
152---++ unsubscribe($name, $topics, $depth)
153 * =$name= - Name of subscriber (wikiname with no web or email address)
154 * =$topics= - wildcard expression giving topics to subscribe to
155 * =$depth= - Child depth to scan (default 0)
156Add an unsubscription, adding the subscriber if necessary. An unsubscription
157is a specific request to ignore notifications for a topic for this
158particular subscriber.
159
160=cut
161
162sub unsubscribe {
163 my ( $this, $name, $topics, $depth ) = @_;
164
165 my @names = ($name);
166 unless ( $this->{noexpandgroups} ) {
167 my $it = Foswiki::Func::eachGroupMember($name);
168 if ($it) {
169 @names = ();
170 while ( $it->hasNext() ) {
171 my $member = $it->next();
172 push( @names, $member );
173 }
174 }
175 }
176
177 foreach my $n (@names) {
178 my $subscriber = $this->getSubscriber($n);
179 my $sub =
180 new Foswiki::Contrib::MailerContrib::Subscription( $topics, $depth,
181 0 );
182 $subscriber->unsubscribe($sub);
183 }
184}
185
186=begin TML
187
188---++ stringify() -> string
189Return a string representation of this object, in %NOTIFYTOPIC% format.
190
191Optional =$subscribersOnly= parameter to only print the parsed subscription list.
192Used when running a mailnotify, where printing out the entire WebNotify topic is confusing,
193as it's different from the actual topic contents, but doesn't inform the user why.
194
195=cut
196
197sub stringify {
198 my $this = shift;
199 my $subscribersOnly = shift || 0;
200
201 my $page = '';
202
203 $page .= $this->{pretext} if ( !$subscribersOnly );
204 foreach my $name ( sort keys %{ $this->{subscribers} } ) {
205 my $subscriber = $this->{subscribers}{$name};
206 $page .= $subscriber->stringify() . "\n";
207 }
208 $page .= $this->{posttext} if ( !$subscribersOnly );
209
210 return $page;
211}
212
213=begin TML
214
215---++ processChange($change, $db, $changeSet, $seenSet, $allSet)
216 * =$change= - ref of a Foswiki::Contrib::Mailer::Change
217 * =$db= - Foswiki::Contrib::MailerContrib::UpData database of parent references
218 * =$changeSet= - ref of a hash mapping emails to sets of changes
219 * =$seenSet= - ref of a hash recording indices of topics already seen
220 * =$allSet= - ref of a hash that maps topics to email addresses for news subscriptions
221Find all subscribers that are interested in the given change. Only the most
222recent change to each topic listed in the .changes file is retained. This
223method does _not_ change this object.
224
225=cut
226
227sub processChange {
228 my ( $this, $change, $db, $changeSet, $seenSet, $allSet ) = @_;
229
230 my $topic = $change->{TOPIC};
231 my $web = $change->{WEB};
232 my %authors = map { $_ => 1 } @{
233 Foswiki::Contrib::MailerContrib::Subscriber::getEmailAddressesForUser(
234 $change->{author}
235 )
236 };
237
238 foreach my $name ( keys %{ $this->{subscribers} } ) {
239 my $subscriber = $this->{subscribers}{$name};
240 my $subs = $subscriber->isSubscribedTo( $topic, $db );
241 if ( $subs && !$subscriber->isUnsubscribedFrom( $topic, $db ) ) {
242
243 next
244 unless Foswiki::Func::checkAccessPermission( 'VIEW', $name, undef,
245 $topic, $this->{web}, undef );
246
247 my $emails = $subscriber->getEmailAddresses();
248 if ( $emails && scalar(@$emails) ) {
249 foreach my $email (@$emails) {
250
251 # Skip this change if the subscriber is the author
252 # of the change, and we are not always sending
253 next
254 if (
255 !(
256 $subs->{options} &
257 Foswiki::Contrib::MailerContrib::Subscription::ALWAYS
258 )
259 && $authors{$email}
260 );
261
262 if ( $subs->{options} &
263 Foswiki::Contrib::MailerContrib::Subscription::FULL_TOPIC
264 )
265 {
266 push( @{ $allSet->{$topic} }, $email );
267 }
268 else {
269 my $at = $seenSet->{$email}{$topic};
270 if ($at) {
271 $changeSet->{$email}[ $at - 1 ]->merge($change);
272 }
273 else {
274 $seenSet->{$email}{$topic} =
275 push( @{ $changeSet->{$email} }, $change );
276 }
277 }
278 }
279 }
280 else {
281 $this->_emailWarn( $subscriber, $name, $web );
282 }
283 }
284 }
285}
286
287=begin TML
288
289---++ processCompulsory($topic, $db, \%allSet)
290 * =$topic= - topic name
291 * =$db= - Foswiki::Contrib::MailerContrib::UpData database of parent references
292 * =\%allSet= - ref of a hash that maps topics to email addresses for news subscriptions
293
294=cut
295
296sub processCompulsory {
297 my ( $this, $topic, $db, $allSet ) = @_;
298
299 foreach my $name ( keys %{ $this->{subscribers} } ) {
300 my $subscriber = $this->{subscribers}{$name};
301 my $subs = $subscriber->isSubscribedTo( $topic, $db );
302 next unless $subs;
303 next
304 unless ( $subs->{options} &
305 Foswiki::Contrib::MailerContrib::Subscription::ALWAYS );
306 unless ( $subscriber->isUnsubscribedFrom( $topic, $db ) ) {
307 my $emails = $subscriber->getEmailAddresses();
308 if ($emails) {
309 foreach my $address (@$emails) {
310 push( @{ $allSet->{$topic} }, $address );
311 }
312 }
313 }
314 }
315}
316
317=begin TML
318
319---++ isEmpty() -> boolean
320Return true if there are no subscribers
321
322=cut
323
324sub isEmpty {
325 my $this = shift;
326 return ( scalar( keys %{ $this->{subscribers} } ) == 0 );
327}
328
329# PRIVATE parse a topic extracting formatted lines
330
# spent 175s (70.2ms+175) within Foswiki::Contrib::MailerContrib::WebNotify::_load which was called 2 times, avg 87.7s/call: # 2 times (70.2ms+175s) by Foswiki::Contrib::MailerContrib::WebNotify::new at line 56, avg 87.7s/call
sub _load {
331181.89ms my $this = shift;
332
33323.16s my ( $meta, $text ) =
# spent 3.16s making 2 calls to Foswiki::Func::readTopic, avg 1.58s/call
334 Foswiki::Func::readTopic( $this->{web}, $this->{topic} );
335 my $in_pre = 1;
336 $this->{pretext} = '';
337 $this->{posttext} = '';
338 $this->{meta} = $meta;
339
340 # join \ terminated lines
3412252µs $text =~ s/\\\r?\n//gs;
# spent 252µs making 2 calls to Foswiki::Contrib::MailerContrib::WebNotify::CORE:subst, avg 126µs/call
342471µs my $webRE = qr/(?:$Foswiki::cfg{UsersWebName}\.)?/;
# spent 36µs making 2 calls to Foswiki::Contrib::MailerContrib::WebNotify::CORE:qr, avg 18µs/call # spent 35µs making 2 calls to Foswiki::Contrib::MailerContrib::WebNotify::CORE:regcomp, avg 18µs/call
343 foreach my $baseline ( split( /\r?\n/, $text ) ) {
344218453.4ms10921.24s my $line =
# spent 1.24s making 1092 calls to Foswiki::Func::expandCommonVariables, avg 1.14ms/call
345 Foswiki::Func::expandCommonVariables( $baseline, $this->{topic},
346 $this->{web}, $meta );
347750033.0ms436820.3ms if (
# spent 12.4ms making 2184 calls to Foswiki::Contrib::MailerContrib::WebNotify::CORE:match, avg 6µs/call # spent 7.88ms making 2184 calls to Foswiki::Contrib::MailerContrib::WebNotify::CORE:regcomp, avg 4µs/call
348 $line =~ m{
349 ^\s+\*\s$webRE
350 ($Foswiki::regex{wikiWordRegex})
351 \s+\-\s+
352 ($Foswiki::cfg{MailerContrib}{EmailFilterIn}+)
353 \s*$}x
354 && $1 ne $Foswiki::cfg{DefaultUserWikiName}
355 )
356 {
357
358 # Main.WikiName - email@domain (legacy format)
359 $this->subscribe( $2, '*', 0, 0 );
360 $in_pre = 0;
361 }
362 elsif (
363 $line =~ m{
364 ^\s+\*\s$webRE
365 (
366 $Foswiki::regex{wikiWordRegex}
367 | '.*?'
368 | ".*?"
369 | $Foswiki::cfg{MailerContrib}{EmailFilterIn}
370 )
371 \s*(:.*)?$
372 }x
373 && $1 ne $Foswiki::cfg{DefaultUserWikiName}
374 )
375 {
376 my $subscriber = $1;
377
378 # Get the topic list from the last bracket matched. Have to do it
379 # this awkward way because the email filter may contain braces
380 my $topics = $+;
381
382 # email addresses can't start with :
38310683.62ms $topics = undef unless ( $topics =~ s/^:// );
# spent 3.62ms making 1068 calls to Foswiki::Contrib::MailerContrib::WebNotify::CORE:subst, avg 3µs/call
38410682.52ms $subscriber =~ s/^(['"])(.*)\1$/$2/; # remove quotes
# spent 2.52ms making 1068 calls to Foswiki::Contrib::MailerContrib::WebNotify::CORE:subst, avg 2µs/call
385
386 # CDot: I don't understand how this can ever be tainted, but the
387 # unit tests fail without this untaint. The subscriber is
388 # validated, and should be untainted, by the conditional regex.
389106818.8ms $subscriber = Foswiki::Sandbox::untaintUnchecked($subscriber);
# spent 18.8ms making 1068 calls to Foswiki::Sandbox::untaintUnchecked, avg 18µs/call
390
39110685.98ms if ( defined $topics ) {
3921068171s $this->parsePageSubscriptions( $subscriber, $topics );
# spent 171s making 1068 calls to Foswiki::Contrib::MailerContrib::WebNotify::parsePageSubscriptions, avg 160ms/call
393 }
394 else {
395 $this->subscribe( $subscriber, '*', 0, 0 );
396 }
397 $in_pre = 0;
398 }
399 else {
40024113µs if ($in_pre) {
401 $this->{pretext} .= "$baseline\n";
402 }
403 else {
404 $this->{posttext} .= "$baseline\n";
405 }
406 }
407 }
408}
409
410# parse a pages list, adding subscriptions as appropriate
411# $unsubscribe is set to '-' by SubscribePlugin to force a '-' operation
412
# spent 171s (24.2ms+171) within Foswiki::Contrib::MailerContrib::WebNotify::parsePageSubscriptions which was called 1068 times, avg 160ms/call: # 1068 times (24.2ms+171s) by Foswiki::Contrib::MailerContrib::WebNotify::_load at line 392, avg 160ms/call
sub parsePageSubscriptions {
413534025.4ms my ( $this, $who, $spec, $unsubscribe ) = @_;
414
415 $this->{topicSub} = \&_subscribeTopic;
416
41710680s my $ret =
# spent 171s making 1068 calls to Foswiki::Contrib::MailerContrib::parsePageList, avg 160ms/call, recursion: max depth 1, sum of overlapping time 171s
418 Foswiki::Contrib::MailerContrib::parsePageList( $this, $who, $spec,
419 $unsubscribe );
42010681.79ms if ( $ret =~ m/\S/ ) {
# spent 1.79ms making 1068 calls to Foswiki::Contrib::MailerContrib::WebNotify::CORE:match, avg 2µs/call
421 Foswiki::Func::writeWarning("Badly formatted page list at $who: $spec");
422 return -1;
423 }
424 return;
425}
426
427
# spent 170s (337ms+170) within Foswiki::Contrib::MailerContrib::WebNotify::_subscribeTopic which was called 12164 times, avg 14.0ms/call: # 12164 times (337ms+170s) by Foswiki::Contrib::MailerContrib::parsePageList at line 210 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Contrib/MailerContrib.pm, avg 14.0ms/call
sub _subscribeTopic {
42885148252ms my ( $this, $who, $unsubscribe, $webTopic, $options, $childDepth ) = @_;
429
43012164739ms my ( $web, $topic ) =
# spent 739ms making 12164 calls to Foswiki::Func::normalizeWebTopicName, avg 61µs/call
431 Foswiki::Func::normalizeWebTopicName( $this->{web}, $webTopic );
432
433 #print STDERR "_subscribeTopic($topic)\n";
434 my $opts = 0;
435 if ($options) {
436 $opts |= Foswiki::Contrib::MailerContrib::Subscription::FULL_TOPIC;
437 if ( $options =~ /!/ ) {
438 $opts |= Foswiki::Contrib::MailerContrib::Subscription::ALWAYS;
439 }
440 }
441 my $kids = $childDepth or 0;
4421216467.6ms if ( $unsubscribe && $unsubscribe eq '-' ) {
443 $this->unsubscribe( $who, $topic, $kids );
444 }
445 else {
44612164169s $this->subscribe( $who, $topic, $kids, $opts );
# spent 169s making 12164 calls to Foswiki::Contrib::MailerContrib::WebNotify::subscribe, avg 13.9ms/call
447 }
448
449 #TODO: howto find & report errors?
450 return '';
451}
452
453# PRIVATE emailWarn to warn when an email address cannot be found
454# for a subscriber.
455sub _emailWarn {
456 my ( $this, $subscriber, $name, $web ) = @_;
457
458 # Make sure we only warn once. Don't want to see this for every
459 # Topic we are notifying on.
460 unless ( defined $this->{nomail}{$name} ) {
461 $this->{nomail}{$name} = 1;
462 Foswiki::Func::writeWarning( "Failed to find permitted email for '"
463 . $subscriber->stringify()
464 . "' when processing web '$web'" );
465 }
466}
467
46814µs1;
469__END__
 
# spent 14.2ms within Foswiki::Contrib::MailerContrib::WebNotify::CORE:match which was called 3252 times, avg 4µs/call: # 2184 times (12.4ms+0s) by Foswiki::Contrib::MailerContrib::WebNotify::_load at line 347, avg 6µs/call # 1068 times (1.79ms+0s) by Foswiki::Contrib::MailerContrib::WebNotify::parsePageSubscriptions at line 420, avg 2µs/call
sub Foswiki::Contrib::MailerContrib::WebNotify::CORE:match; # opcode
# spent 36µs within Foswiki::Contrib::MailerContrib::WebNotify::CORE:qr which was called 2 times, avg 18µs/call: # 2 times (36µs+0s) by Foswiki::Contrib::MailerContrib::WebNotify::_load at line 342, avg 18µs/call
sub Foswiki::Contrib::MailerContrib::WebNotify::CORE:qr; # opcode
# spent 7.91ms within Foswiki::Contrib::MailerContrib::WebNotify::CORE:regcomp which was called 2186 times, avg 4µs/call: # 2184 times (7.88ms+0s) by Foswiki::Contrib::MailerContrib::WebNotify::_load at line 347, avg 4µs/call # 2 times (35µs+0s) by Foswiki::Contrib::MailerContrib::WebNotify::_load at line 342, avg 18µs/call
sub Foswiki::Contrib::MailerContrib::WebNotify::CORE:regcomp; # opcode
# spent 6.39ms within Foswiki::Contrib::MailerContrib::WebNotify::CORE:subst which was called 2138 times, avg 3µs/call: # 1068 times (3.62ms+0s) by Foswiki::Contrib::MailerContrib::WebNotify::_load at line 383, avg 3µs/call # 1068 times (2.52ms+0s) by Foswiki::Contrib::MailerContrib::WebNotify::_load at line 384, avg 2µs/call # 2 times (252µs+0s) by Foswiki::Contrib::MailerContrib::WebNotify::_load at line 341, avg 126µs/call
sub Foswiki::Contrib::MailerContrib::WebNotify::CORE:subst; # opcode