Filename | /var/www/foswikidev/core/lib/Foswiki/Plugins/UpdatesPlugin.pm |
Statements | Executed 31 statements in 482µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 70µs | 6.02ms | initPlugin | Foswiki::Plugins::UpdatesPlugin::
1 | 1 | 1 | 14µs | 28µs | BEGIN@18 | Foswiki::Plugins::UpdatesPlugin::
1 | 1 | 1 | 12µs | 50µs | BEGIN@29 | Foswiki::Plugins::UpdatesPlugin::
1 | 1 | 1 | 9µs | 14µs | BEGIN@19 | Foswiki::Plugins::UpdatesPlugin::
1 | 1 | 1 | 4µs | 4µs | BEGIN@21 | Foswiki::Plugins::UpdatesPlugin::
0 | 0 | 0 | 0s | 0s | __ANON__[:76] | Foswiki::Plugins::UpdatesPlugin::
0 | 0 | 0 | 0s | 0s | getCore | Foswiki::Plugins::UpdatesPlugin::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/ | ||||
2 | # | ||||
3 | # UpdatesPlugin is Copyright (C) 2011-2015 Foswiki Contributors | ||||
4 | # | ||||
5 | # This program is free software; you can redistribute it and/or | ||||
6 | # modify it under the terms of the GNU General Public License | ||||
7 | # as published by the Free Software Foundation; either version 2 | ||||
8 | # of the License, or (at your option) any later version. | ||||
9 | # | ||||
10 | # This program is distributed in the hope that it will be useful, | ||||
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
13 | # GNU General Public License for more details, published at | ||||
14 | # http://www.gnu.org/copyleft/gpl.html | ||||
15 | |||||
16 | package Foswiki::Plugins::UpdatesPlugin; | ||||
17 | |||||
18 | 2 | 28µs | 2 | 42µs | # spent 28µs (14+14) within Foswiki::Plugins::UpdatesPlugin::BEGIN@18 which was called:
# once (14µs+14µs) by Foswiki::Plugin::BEGIN@2.41 at line 18 # spent 28µs making 1 call to Foswiki::Plugins::UpdatesPlugin::BEGIN@18
# spent 14µs making 1 call to strict::import |
19 | 2 | 25µs | 2 | 18µs | # spent 14µs (9+4) within Foswiki::Plugins::UpdatesPlugin::BEGIN@19 which was called:
# once (9µs+4µs) by Foswiki::Plugin::BEGIN@2.41 at line 19 # spent 14µs making 1 call to Foswiki::Plugins::UpdatesPlugin::BEGIN@19
# spent 4µs making 1 call to warnings::import |
20 | |||||
21 | 2 | 62µs | 1 | 4µs | # spent 4µs within Foswiki::Plugins::UpdatesPlugin::BEGIN@21 which was called:
# once (4µs+0s) by Foswiki::Plugin::BEGIN@2.41 at line 21 # spent 4µs making 1 call to Foswiki::Plugins::UpdatesPlugin::BEGIN@21 |
22 | |||||
23 | 1 | 700ns | our $VERSION = '1.01'; | ||
24 | 1 | 200ns | our $RELEASE = '1.01'; | ||
25 | 1 | 200ns | our $SHORTDESCRIPTION = 'Checks Foswiki.org for updates'; | ||
26 | 1 | 100ns | our $NO_PREFS_IN_TOPIC = 1; | ||
27 | 1 | 100ns | our $core; | ||
28 | |||||
29 | 2 | 317µs | 2 | 88µs | # spent 50µs (12+38) within Foswiki::Plugins::UpdatesPlugin::BEGIN@29 which was called:
# once (12µs+38µs) by Foswiki::Plugin::BEGIN@2.41 at line 29 # spent 50µs making 1 call to Foswiki::Plugins::UpdatesPlugin::BEGIN@29
# spent 38µs making 1 call to constant::import |
30 | |||||
31 | # spent 6.02ms (70µs+5.95) within Foswiki::Plugins::UpdatesPlugin::initPlugin which was called:
# once (70µs+5.95ms) by Foswiki::Plugin::__ANON__[/var/www/foswikidev/core/lib/Foswiki/Plugin.pm:257] at line 250 of /var/www/foswikidev/core/lib/Foswiki/Plugin.pm | ||||
32 | |||||
33 | # bail out if not an admin and not in view mode | ||||
34 | 1 | 2µs | 1 | 1µs | my $context = Foswiki::Func::getContext(); # spent 1µs making 1 call to Foswiki::Func::getContext |
35 | 1 | 3µs | 1 | 12µs | return 1 # spent 12µs making 1 call to Foswiki::Func::isAnAdmin |
36 | unless Foswiki::Func::isAnAdmin() | ||||
37 | && ( $context->{view} || $context->{rest} ); | ||||
38 | |||||
39 | 1 | 2µs | 1 | 1µs | my $request = Foswiki::Func::getRequestObject(); # spent 1µs making 1 call to Foswiki::Func::getRequestObject |
40 | 1 | 500ns | my $cookie; | ||
41 | |||||
42 | 1 | 3µs | 1 | 27µs | $cookie = $request->cookie("FOSWIKI_UPDATESPLUGIN") unless TRACE; # spent 27µs making 1 call to Foswiki::Request::cookie |
43 | |||||
44 | 1 | 300ns | return 1 if defined($cookie) && $cookie <= 0; # 0: DoNothing | ||
45 | |||||
46 | 1 | 2µs | 1 | 4.48ms | Foswiki::Func::readTemplate("updatesplugin"); # spent 4.48ms making 1 call to Foswiki::Func::readTemplate |
47 | |||||
48 | # add stuff to page | ||||
49 | 1 | 3µs | 1 | 75µs | my $css = Foswiki::Func::expandTemplate("css"); # spent 75µs making 1 call to Foswiki::Func::expandTemplate |
50 | 1 | 2µs | 1 | 130µs | my $messageTmpl = Foswiki::Func::expandTemplate("messagetmpl"); # spent 130µs making 1 call to Foswiki::Func::expandTemplate |
51 | |||||
52 | 1 | 2µs | 1 | 450µs | Foswiki::Plugins::JQueryPlugin::createPlugin("cookie"); # spent 450µs making 1 call to Foswiki::Plugins::JQueryPlugin::createPlugin |
53 | 1 | 1µs | 1 | 667µs | Foswiki::Plugins::JQueryPlugin::createPlugin("render"); # spent 667µs making 1 call to Foswiki::Plugins::JQueryPlugin::createPlugin |
54 | |||||
55 | 1 | 1µs | my $jsFile = | ||
56 | (TRACE) ? 'jquery.updates.uncompressed.js' : 'jquery.updates.js'; | ||||
57 | |||||
58 | 1 | 4µs | 1 | 31µs | my $configureUrl = $Foswiki::cfg{Plugins}{UpdatesPlugin}{ConfigureUrl} # spent 31µs making 1 call to Foswiki::Func::getScriptUrl |
59 | || Foswiki::Func::getScriptUrl( undef, undef, "configure" ); | ||||
60 | |||||
61 | 1 | 4µs | 1 | 31µs | Foswiki::Func::addToZone( "head", "UPDATESPLUGIN::META", <<META); # spent 31µs making 1 call to Foswiki::Func::addToZone |
62 | <meta name="foswiki.UPDATESPLUGIN::CONFIGUREURL" content="$configureUrl" /> | ||||
63 | $css | ||||
64 | $messageTmpl | ||||
65 | META | ||||
66 | |||||
67 | 1 | 3µs | 1 | 24µs | Foswiki::Func::addToZone( "script", "UPDATESPLUGIN::JS", # spent 24µs making 1 call to Foswiki::Func::addToZone |
68 | <<JS, "JQUERYPLUGIN::FOSWIKI, JQUERYPLUGIN::COOKIE, JQUERYPLUGIN::RENDER" ); | ||||
69 | <script src="%PUBURLPATH%/%SYSTEMWEB%/UpdatesPlugin/$jsFile"></script> | ||||
70 | JS | ||||
71 | |||||
72 | Foswiki::Func::registerRESTHandler( | ||||
73 | 'check', | ||||
74 | sub { | ||||
75 | return getCore( shift, debug => TRACE )->handleRESTCheck(@_); | ||||
76 | }, | ||||
77 | 1 | 6µs | 1 | 24µs | authenticate => 0, # Safe. initPlugin bails if user not an admin. # spent 24µs making 1 call to Foswiki::Func::registerRESTHandler |
78 | validate => 0, # Doesn't update. | ||||
79 | http_allow => 'GET', | ||||
80 | description => 'Check if any extensions are out-of-date', | ||||
81 | ); | ||||
82 | |||||
83 | 1 | 5µs | return 1; | ||
84 | } | ||||
85 | |||||
86 | sub getCore { | ||||
87 | unless ($core) { | ||||
88 | require Foswiki::Plugins::UpdatesPlugin::Core; | ||||
89 | $core = new Foswiki::Plugins::UpdatesPlugin::Core(@_); | ||||
90 | } | ||||
91 | |||||
92 | return $core; | ||||
93 | } | ||||
94 | |||||
95 | 1 | 4µs | 1; |