Filename | /var/www/foswiki11/lib/Foswiki/Store.pm |
Statements | Executed 1593 statements in 5.20ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
780 | 4 | 3 | 3.77ms | 3.77ms | cleanUpRevID | Foswiki::Store::
1 | 1 | 1 | 26µs | 86µs | getWorkArea | Foswiki::Store::
1 | 1 | 1 | 14µs | 20µs | BEGIN@53 | Foswiki::Store::
1 | 1 | 1 | 12µs | 25µs | BEGIN@52 | Foswiki::Store::
1 | 1 | 1 | 10µs | 10µs | new | Foswiki::Store::
1 | 1 | 1 | 10µs | 22µs | BEGIN@56 | Foswiki::Store::
1 | 1 | 1 | 8µs | 112µs | BEGIN@55 | Foswiki::Store::
1 | 1 | 1 | 4µs | 4µs | BEGIN@58 | Foswiki::Store::
1 | 1 | 1 | 3µs | 3µs | BEGIN@61 | Foswiki::Store::
1 | 1 | 1 | 3µs | 3µs | BEGIN@60 | Foswiki::Store::
1 | 1 | 1 | 3µs | 3µs | BEGIN@59 | Foswiki::Store::
1 | 1 | 1 | 2µs | 2µs | finish | Foswiki::Store::
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 | |||||
7 | This class is a pure virtual base class that specifies the interface | ||||
8 | between the actual store implementation and the rest of the Foswiki | ||||
9 | system. | ||||
10 | |||||
11 | Subclasses of this class (known as "store implementations") are | ||||
12 | responsible for checking for topic existance, access permissions, and | ||||
13 | all the other general admin tasks required of a store. | ||||
14 | |||||
15 | This class knows *nothing* about how the data is actually _stored_ - | ||||
16 | that knowledge is entirely encapsulated in the implementation. | ||||
17 | |||||
18 | The general contract for methods in the class requires that errors | ||||
19 | are signalled using exceptions. Foswiki::AccessControlException is | ||||
20 | used for access control exceptions, and Error::Simple for all other | ||||
21 | types of error. | ||||
22 | |||||
23 | Reference implementations of this base class are =Foswiki::Store::RcsWrap= | ||||
24 | and =Foswiki::Store::RcsLite= (these are both implemented in terms of | ||||
25 | VC::Store, which is an abstract implementation of a store based on a | ||||
26 | version control system). | ||||
27 | |||||
28 | Methods of this class and all subclasses should *only* be called from | ||||
29 | =Foswiki= and =Foswiki::Meta=. All other system components must delegate | ||||
30 | store interactions via =Foswiki::Meta=. | ||||
31 | |||||
32 | For 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 | |||||
36 | Note that most methods are passed a Foswiki::Meta object. This pattern is | ||||
37 | employed to reinforce the encapsulation of a "path" in a meta object, and | ||||
38 | also to allow the store to modify META fields in the object, something it | ||||
39 | would be unable to do if passed $web, $topic. | ||||
40 | |||||
41 | Version numbers are required to be positive, non-zero integers. When | ||||
42 | passing in version numbers to the methods of a store implementation, 0, | ||||
43 | undef and '' are treated as referring to the *latest* (most recent) | ||||
44 | revision of the object. Version numbers are required to increase (later | ||||
45 | version numbers are greater than earlier) but are *not* required to be | ||||
46 | sequential. | ||||
47 | |||||
48 | =cut | ||||
49 | |||||
50 | package Foswiki::Store; | ||||
51 | |||||
52 | 2 | 26µs | 2 | 38µ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 # spent 25µs making 1 call to Foswiki::Store::BEGIN@52
# spent 13µs making 1 call to strict::import |
53 | 2 | 33µs | 2 | 26µ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 # spent 20µs making 1 call to Foswiki::Store::BEGIN@53
# spent 6µs making 1 call to warnings::import |
54 | |||||
55 | 2 | 28µs | 2 | 216µ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 # spent 112µs making 1 call to Foswiki::Store::BEGIN@55
# spent 104µs making 1 call to Error::import |
56 | 2 | 23µs | 2 | 34µ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 # spent 22µs making 1 call to Foswiki::Store::BEGIN@56
# spent 12µs making 1 call to Assert::import |
57 | |||||
58 | 2 | 17µs | 1 | 4µs | # spent 4µs within Foswiki::Store::BEGIN@58 which was called:
# once (4µs+0s) by Foswiki::BEGIN@635 at line 58 # spent 4µs making 1 call to Foswiki::Store::BEGIN@58 |
59 | 2 | 16µs | 1 | 3µs | # spent 3µs within Foswiki::Store::BEGIN@59 which was called:
# once (3µs+0s) by Foswiki::BEGIN@635 at line 59 # spent 3µs making 1 call to Foswiki::Store::BEGIN@59 |
60 | 2 | 19µs | 1 | 3µs | # spent 3µs within Foswiki::Store::BEGIN@60 which was called:
# once (3µs+0s) by Foswiki::BEGIN@635 at line 60 # spent 3µs making 1 call to Foswiki::Store::BEGIN@60 |
61 | 2 | 234µs | 1 | 3µs | # spent 3µs within Foswiki::Store::BEGIN@61 which was called:
# once (3µs+0s) by Foswiki::BEGIN@635 at line 61 # spent 3µs making 1 call to Foswiki::Store::BEGIN@61 |
62 | |||||
63 | 1 | 600ns | our $STORE_FORMAT_VERSION = '1.1'; | ||
64 | |||||
65 | =begin TML | ||||
66 | |||||
67 | ---++ ClassMethod new() | ||||
68 | |||||
69 | Construct 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 | ||||
74 | 1 | 1µs | my ($class) = @_; | ||
75 | 1 | 7µs | my $this = bless( {}, $class ); | ||
76 | 1 | 4µs | return $this; | ||
77 | } | ||||
78 | |||||
79 | =begin TML | ||||
80 | |||||
81 | ---++ ObjectMethod finish() | ||||
82 | Break 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 | ||||
90 | 1 | 7µs | my $this = shift; | ||
91 | } | ||||
92 | |||||
93 | =begin TML | ||||
94 | |||||
95 | ---++ StaticMethod cleanUpRevID( $rev ) -> $integer | ||||
96 | |||||
97 | Cleans up (maps) a user-supplied revision ID and converts it to an integer | ||||
98 | number that can be incremented to create a new revision number. | ||||
99 | |||||
100 | This method should be used to sanitise user-provided revision IDs. | ||||
101 | |||||
102 | Returns 0 if it was unable to determine a valid rev number from the | ||||
103 | string 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 | ||||
108 | 780 | 230µs | my $rev = shift; | ||
109 | |||||
110 | # RCS format: 1.2, or plain integer: 2 | ||||
111 | 780 | 4.51ms | if ( defined $rev && $rev =~ /^(?:\d+\.)?(\d+)$/ ) { | ||
112 | return $1; | ||||
113 | } | ||||
114 | |||||
115 | 5 | 21µs | return 0; | ||
116 | } | ||||
117 | |||||
118 | =begin TML | ||||
119 | |||||
120 | ---+++ ObjectMethod getWorkArea( $key ) -> $directorypath | ||||
121 | |||||
122 | Gets a private directory uniquely identified by $key. The directory is | ||||
123 | intended as a work area for plugins. | ||||
124 | |||||
125 | The 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 | ||||
131 | 1 | 1µs | my ( $this, $key ) = @_; | ||
132 | |||||
133 | # untaint and detect nasties. The rules are the same as for | ||||
134 | # attachment names. | ||||
135 | 1 | 5µs | 1 | 60µs | $key = Foswiki::Sandbox::untaint( $key, # spent 60µs making 1 call to Foswiki::Sandbox::untaint |
136 | \&Foswiki::Sandbox::validateAttachmentName ); | ||||
137 | 1 | 500ns | throw Error::Simple("Bad work area name $key") unless ($key); | ||
138 | |||||
139 | 1 | 3µs | my $dir = "$Foswiki::cfg{WorkingDir}/work_areas/$key"; | ||
140 | |||||
141 | 1 | 10µs | unless ( -d $dir ) { | ||
142 | mkdir($dir) || throw Error::Simple(<<ERROR); | ||||
143 | Failed to create $key work area. Check your setting of {WorkingDir} | ||||
144 | in =configure=. | ||||
145 | ERROR | ||||
146 | } | ||||
147 | 1 | 9µs | return $dir; | ||
148 | } | ||||
149 | |||||
150 | 1 | 2µs | 1; | ||
151 | __END__ |