← Index
NYTProf Performance Profile   « line view »
For ./view
  Run on Fri Jul 31 19:05:14 2015
Reported on Fri Jul 31 19:08:09 2015

Filename/var/www/foswiki11/lib/Foswiki/Store.pm
StatementsExecuted 1593 statements in 5.20ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
780433.77ms3.77msFoswiki::Store::::cleanUpRevIDFoswiki::Store::cleanUpRevID
11126µs86µsFoswiki::Store::::getWorkAreaFoswiki::Store::getWorkArea
11114µs20µsFoswiki::Store::::BEGIN@53Foswiki::Store::BEGIN@53
11112µs25µsFoswiki::Store::::BEGIN@52Foswiki::Store::BEGIN@52
11110µs10µsFoswiki::Store::::newFoswiki::Store::new
11110µs22µsFoswiki::Store::::BEGIN@56Foswiki::Store::BEGIN@56
1118µs112µsFoswiki::Store::::BEGIN@55Foswiki::Store::BEGIN@55
1114µs4µsFoswiki::Store::::BEGIN@58Foswiki::Store::BEGIN@58
1113µs3µsFoswiki::Store::::BEGIN@61Foswiki::Store::BEGIN@61
1113µs3µsFoswiki::Store::::BEGIN@60Foswiki::Store::BEGIN@60
1113µs3µsFoswiki::Store::::BEGIN@59Foswiki::Store::BEGIN@59
1112µs2µsFoswiki::Store::::finishFoswiki::Store::finish
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::Store
6
7This class is a pure virtual base class that specifies the interface
8between the actual store implementation and the rest of the Foswiki
9system.
10
11Subclasses of this class (known as "store implementations") are
12responsible for checking for topic existance, access permissions, and
13all the other general admin tasks required of a store.
14
15This class knows *nothing* about how the data is actually _stored_ -
16that knowledge is entirely encapsulated in the implementation.
17
18The general contract for methods in the class requires that errors
19are signalled using exceptions. Foswiki::AccessControlException is
20used for access control exceptions, and Error::Simple for all other
21types of error.
22
23Reference implementations of this base class are =Foswiki::Store::RcsWrap=
24and =Foswiki::Store::RcsLite= (these are both implemented in terms of
25VC::Store, which is an abstract implementation of a store based on a
26version control system).
27
28Methods of this class and all subclasses should *only* be called from
29=Foswiki= and =Foswiki::Meta=. All other system components must delegate
30store interactions via =Foswiki::Meta=.
31
32For readers who are familiar with Foswiki version 1.0.0, this class
33_describes_ the interface to the old =Foswiki::Store= without actually
34_implementing_ it.
35
36Note that most methods are passed a Foswiki::Meta object. This pattern is
37employed to reinforce the encapsulation of a "path" in a meta object, and
38also to allow the store to modify META fields in the object, something it
39would be unable to do if passed $web, $topic.
40
41Version numbers are required to be positive, non-zero integers. When
42passing in version numbers to the methods of a store implementation, 0,
43undef and '' are treated as referring to the *latest* (most recent)
44revision of the object. Version numbers are required to increase (later
45version numbers are greater than earlier) but are *not* required to be
46sequential.
47
48=cut
49
50package Foswiki::Store;
51
52226µs238µs
# spent 25µs (12+13) within Foswiki::Store::BEGIN@52 which was called: # once (12µs+13µs) by Foswiki::BEGIN@635 at line 52
use strict;
# spent 25µs making 1 call to Foswiki::Store::BEGIN@52 # spent 13µs making 1 call to strict::import
53233µs226µs
# spent 20µs (14+6) within Foswiki::Store::BEGIN@53 which was called: # once (14µs+6µs) by Foswiki::BEGIN@635 at line 53
use warnings;
# spent 20µs making 1 call to Foswiki::Store::BEGIN@53 # spent 6µs making 1 call to warnings::import
54
55228µs2216µs
# spent 112µs (8+104) within Foswiki::Store::BEGIN@55 which was called: # once (8µs+104µs) by Foswiki::BEGIN@635 at line 55
use Error qw( :try );
# spent 112µs making 1 call to Foswiki::Store::BEGIN@55 # spent 104µs making 1 call to Error::import
56223µs234µs
# spent 22µs (10+12) within Foswiki::Store::BEGIN@56 which was called: # once (10µs+12µs) by Foswiki::BEGIN@635 at line 56
use Assert;
# spent 22µs making 1 call to Foswiki::Store::BEGIN@56 # spent 12µs making 1 call to Assert::import
57
58217µs14µs
# spent 4µs within Foswiki::Store::BEGIN@58 which was called: # once (4µs+0s) by Foswiki::BEGIN@635 at line 58
use Foswiki ();
# spent 4µs making 1 call to Foswiki::Store::BEGIN@58
59216µs13µs
# spent 3µs within Foswiki::Store::BEGIN@59 which was called: # once (3µs+0s) by Foswiki::BEGIN@635 at line 59
use Foswiki::Meta ();
# spent 3µs making 1 call to Foswiki::Store::BEGIN@59
60219µs13µs
# spent 3µs within Foswiki::Store::BEGIN@60 which was called: # once (3µs+0s) by Foswiki::BEGIN@635 at line 60
use Foswiki::Sandbox ();
# spent 3µs making 1 call to Foswiki::Store::BEGIN@60
612234µs13µs
# spent 3µs within Foswiki::Store::BEGIN@61 which was called: # once (3µs+0s) by Foswiki::BEGIN@635 at line 61
use Foswiki::AccessControlException ();
# spent 3µs making 1 call to Foswiki::Store::BEGIN@61
62
631600nsour $STORE_FORMAT_VERSION = '1.1';
64
65=begin TML
66
67---++ ClassMethod new()
68
69Construct a Store module.
70
71=cut
72
73
# spent 10µs within Foswiki::Store::new which was called: # once (10µs+0s) by Foswiki::new at line 1758 of /var/www/foswiki11/lib/Foswiki.pm
sub new {
7411µs my ($class) = @_;
7517µs my $this = bless( {}, $class );
7614µs return $this;
77}
78
79=begin TML
80
81---++ ObjectMethod finish()
82Break circular references.
83
84=cut
85
86# Note to developers; please undef *all* fields in the object explicitly,
87# whether they are references or not. That way this method is "golden
88# documentation" of the live fields in the object.
89
# spent 2µs within Foswiki::Store::finish which was called: # once (2µs+0s) by Foswiki::Store::VC::Store::finish at line 60 of /var/www/foswiki11/lib/Foswiki/Store/VC/Store.pm
sub finish {
9017µs my $this = shift;
91}
92
93=begin TML
94
95---++ StaticMethod cleanUpRevID( $rev ) -> $integer
96
97Cleans up (maps) a user-supplied revision ID and converts it to an integer
98number that can be incremented to create a new revision number.
99
100This method should be used to sanitise user-provided revision IDs.
101
102Returns 0 if it was unable to determine a valid rev number from the
103string passed.
104
105=cut
106
107
# spent 3.77ms within Foswiki::Store::cleanUpRevID which was called 780 times, avg 5µs/call: # 425 times (2.47ms+0s) by Foswiki::Meta::setEmbeddedStoreForm at line 3598 of /var/www/foswiki11/lib/Foswiki/Meta.pm, avg 6µs/call # 341 times (1.08ms+0s) by Foswiki::Meta::setEmbeddedStoreForm at line 3600 of /var/www/foswiki11/lib/Foswiki/Meta.pm, avg 3µs/call # 11 times (206µs+0s) by Foswiki::Store::VC::Handler::_getTOPICINFO at line 274 of /var/www/foswiki11/lib/Foswiki/Store/VC/Handler.pm, avg 19µs/call # 3 times (15µs+0s) by Foswiki::REVINFO at line 18 of /var/www/foswiki11/lib/Foswiki/Macros/REVINFO.pm, avg 5µs/call
sub cleanUpRevID {
108780230µs my $rev = shift;
109
110 # RCS format: 1.2, or plain integer: 2
1117804.51ms if ( defined $rev && $rev =~ /^(?:\d+\.)?(\d+)$/ ) {
112 return $1;
113 }
114
115521µs return 0;
116}
117
118=begin TML
119
120---+++ ObjectMethod getWorkArea( $key ) -> $directorypath
121
122Gets a private directory uniquely identified by $key. The directory is
123intended as a work area for plugins.
124
125The standard is a directory named the same as "key" under
126$Foswiki::cfg{WorkingDir}/work_areas
127
128=cut
129
130
# spent 86µs (26+60) within Foswiki::Store::getWorkArea which was called: # once (26µs+60µs) by Foswiki::getWorkArea at line 3782 of /var/www/foswiki11/lib/Foswiki.pm
sub getWorkArea {
13111µs my ( $this, $key ) = @_;
132
133 # untaint and detect nasties. The rules are the same as for
134 # attachment names.
13515µs160µs $key = Foswiki::Sandbox::untaint( $key,
# spent 60µs making 1 call to Foswiki::Sandbox::untaint
136 \&Foswiki::Sandbox::validateAttachmentName );
1371500ns throw Error::Simple("Bad work area name $key") unless ($key);
138
13913µs my $dir = "$Foswiki::cfg{WorkingDir}/work_areas/$key";
140
141110µs unless ( -d $dir ) {
142 mkdir($dir) || throw Error::Simple(<<ERROR);
143Failed to create $key work area. Check your setting of {WorkingDir}
144in =configure=.
145ERROR
146 }
14719µs return $dir;
148}
149
15012µs1;
151__END__