aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--application/LinkDB.php154
-rw-r--r--application/NetscapeBookmarkUtils.php2
-rw-r--r--application/Updater.php2
-rw-r--r--index.php8
-rw-r--r--tests/LinkDBTest.php8
-rw-r--r--tests/utils/ReferenceLinkDB.php2
6 files changed, 88 insertions, 88 deletions
diff --git a/application/LinkDB.php b/application/LinkDB.php
index de9e73b0..c8b162b6 100644
--- a/application/LinkDB.php
+++ b/application/LinkDB.php
@@ -31,7 +31,7 @@
31class LinkDB implements Iterator, Countable, ArrayAccess 31class LinkDB implements Iterator, Countable, ArrayAccess
32{ 32{
33 // Links are stored as a PHP serialized string 33 // Links are stored as a PHP serialized string
34 private $_datastore; 34 private $datastore;
35 35
36 // Link date storage format 36 // Link date storage format
37 const LINK_DATE_FORMAT = 'Ymd_His'; 37 const LINK_DATE_FORMAT = 'Ymd_His';
@@ -45,26 +45,26 @@ class LinkDB implements Iterator, Countable, ArrayAccess
45 // List of links (associative array) 45 // List of links (associative array)
46 // - key: link date (e.g. "20110823_124546"), 46 // - key: link date (e.g. "20110823_124546"),
47 // - value: associative array (keys: title, description...) 47 // - value: associative array (keys: title, description...)
48 private $_links; 48 private $links;
49 49
50 // List of all recorded URLs (key=url, value=linkdate) 50 // List of all recorded URLs (key=url, value=linkdate)
51 // for fast reserve search (url-->linkdate) 51 // for fast reserve search (url-->linkdate)
52 private $_urls; 52 private $urls;
53 53
54 // List of linkdate keys (for the Iterator interface implementation) 54 // List of linkdate keys (for the Iterator interface implementation)
55 private $_keys; 55 private $keys;
56 56
57 // Position in the $this->_keys array (for the Iterator interface) 57 // Position in the $this->keys array (for the Iterator interface)
58 private $_position; 58 private $position;
59 59
60 // Is the user logged in? (used to filter private links) 60 // Is the user logged in? (used to filter private links)
61 private $_loggedIn; 61 private $loggedIn;
62 62
63 // Hide public links 63 // Hide public links
64 private $_hidePublicLinks; 64 private $hidePublicLinks;
65 65
66 // link redirector set in user settings. 66 // link redirector set in user settings.
67 private $_redirector; 67 private $redirector;
68 68
69 /** 69 /**
70 * Set this to `true` to urlencode link behind redirector link, `false` to leave it untouched. 70 * Set this to `true` to urlencode link behind redirector link, `false` to leave it untouched.
@@ -87,7 +87,7 @@ class LinkDB implements Iterator, Countable, ArrayAccess
87 * @param string $redirector link redirector set in user settings. 87 * @param string $redirector link redirector set in user settings.
88 * @param boolean $redirectorEncode Enable urlencode on redirected urls (default: true). 88 * @param boolean $redirectorEncode Enable urlencode on redirected urls (default: true).
89 */ 89 */
90 function __construct( 90 public function __construct(
91 $datastore, 91 $datastore,
92 $isLoggedIn, 92 $isLoggedIn,
93 $hidePublicLinks, 93 $hidePublicLinks,
@@ -95,13 +95,13 @@ class LinkDB implements Iterator, Countable, ArrayAccess
95 $redirectorEncode = true 95 $redirectorEncode = true
96 ) 96 )
97 { 97 {
98 $this->_datastore = $datastore; 98 $this->datastore = $datastore;
99 $this->_loggedIn = $isLoggedIn; 99 $this->loggedIn = $isLoggedIn;
100 $this->_hidePublicLinks = $hidePublicLinks; 100 $this->hidePublicLinks = $hidePublicLinks;
101 $this->_redirector = $redirector; 101 $this->redirector = $redirector;
102 $this->redirectorEncode = $redirectorEncode === true; 102 $this->redirectorEncode = $redirectorEncode === true;
103 $this->_checkDB(); 103 $this->check();
104 $this->_readDB(); 104 $this->read();
105 } 105 }
106 106
107 /** 107 /**
@@ -109,7 +109,7 @@ class LinkDB implements Iterator, Countable, ArrayAccess
109 */ 109 */
110 public function count() 110 public function count()
111 { 111 {
112 return count($this->_links); 112 return count($this->links);
113 } 113 }
114 114
115 /** 115 /**
@@ -118,7 +118,7 @@ class LinkDB implements Iterator, Countable, ArrayAccess
118 public function offsetSet($offset, $value) 118 public function offsetSet($offset, $value)
119 { 119 {
120 // TODO: use exceptions instead of "die" 120 // TODO: use exceptions instead of "die"
121 if (!$this->_loggedIn) { 121 if (!$this->loggedIn) {
122 die('You are not authorized to add a link.'); 122 die('You are not authorized to add a link.');
123 } 123 }
124 if (empty($value['linkdate']) || empty($value['url'])) { 124 if (empty($value['linkdate']) || empty($value['url'])) {
@@ -127,8 +127,8 @@ class LinkDB implements Iterator, Countable, ArrayAccess
127 if (empty($offset)) { 127 if (empty($offset)) {
128 die('You must specify a key.'); 128 die('You must specify a key.');
129 } 129 }
130 $this->_links[$offset] = $value; 130 $this->links[$offset] = $value;
131 $this->_urls[$value['url']]=$offset; 131 $this->urls[$value['url']]=$offset;
132 } 132 }
133 133
134 /** 134 /**
@@ -136,7 +136,7 @@ class LinkDB implements Iterator, Countable, ArrayAccess
136 */ 136 */
137 public function offsetExists($offset) 137 public function offsetExists($offset)
138 { 138 {
139 return array_key_exists($offset, $this->_links); 139 return array_key_exists($offset, $this->links);
140 } 140 }
141 141
142 /** 142 /**
@@ -144,13 +144,13 @@ class LinkDB implements Iterator, Countable, ArrayAccess
144 */ 144 */
145 public function offsetUnset($offset) 145 public function offsetUnset($offset)
146 { 146 {
147 if (!$this->_loggedIn) { 147 if (!$this->loggedIn) {
148 // TODO: raise an exception 148 // TODO: raise an exception
149 die('You are not authorized to delete a link.'); 149 die('You are not authorized to delete a link.');
150 } 150 }
151 $url = $this->_links[$offset]['url']; 151 $url = $this->links[$offset]['url'];
152 unset($this->_urls[$url]); 152 unset($this->urls[$url]);
153 unset($this->_links[$offset]); 153 unset($this->links[$offset]);
154 } 154 }
155 155
156 /** 156 /**
@@ -158,31 +158,31 @@ class LinkDB implements Iterator, Countable, ArrayAccess
158 */ 158 */
159 public function offsetGet($offset) 159 public function offsetGet($offset)
160 { 160 {
161 return isset($this->_links[$offset]) ? $this->_links[$offset] : null; 161 return isset($this->links[$offset]) ? $this->links[$offset] : null;
162 } 162 }
163 163
164 /** 164 /**
165 * Iterator - Returns the current element 165 * Iterator - Returns the current element
166 */ 166 */
167 function current() 167 public function current()
168 { 168 {
169 return $this->_links[$this->_keys[$this->_position]]; 169 return $this->links[$this->keys[$this->position]];
170 } 170 }
171 171
172 /** 172 /**
173 * Iterator - Returns the key of the current element 173 * Iterator - Returns the key of the current element
174 */ 174 */
175 function key() 175 public function key()
176 { 176 {
177 return $this->_keys[$this->_position]; 177 return $this->keys[$this->position];
178 } 178 }
179 179
180 /** 180 /**
181 * Iterator - Moves forward to next element 181 * Iterator - Moves forward to next element
182 */ 182 */
183 function next() 183 public function next()
184 { 184 {
185 ++$this->_position; 185 ++$this->position;
186 } 186 }
187 187
188 /** 188 /**
@@ -190,19 +190,19 @@ class LinkDB implements Iterator, Countable, ArrayAccess
190 * 190 *
191 * Entries are sorted by date (latest first) 191 * Entries are sorted by date (latest first)
192 */ 192 */
193 function rewind() 193 public function rewind()
194 { 194 {
195 $this->_keys = array_keys($this->_links); 195 $this->keys = array_keys($this->links);
196 rsort($this->_keys); 196 rsort($this->keys);
197 $this->_position = 0; 197 $this->position = 0;
198 } 198 }
199 199
200 /** 200 /**
201 * Iterator - Checks if current position is valid 201 * Iterator - Checks if current position is valid
202 */ 202 */
203 function valid() 203 public function valid()
204 { 204 {
205 return isset($this->_keys[$this->_position]); 205 return isset($this->keys[$this->position]);
206 } 206 }
207 207
208 /** 208 /**
@@ -210,14 +210,14 @@ class LinkDB implements Iterator, Countable, ArrayAccess
210 * 210 *
211 * If no DB file is found, creates a dummy DB. 211 * If no DB file is found, creates a dummy DB.
212 */ 212 */
213 private function _checkDB() 213 private function check()
214 { 214 {
215 if (file_exists($this->_datastore)) { 215 if (file_exists($this->datastore)) {
216 return; 216 return;
217 } 217 }
218 218
219 // Create a dummy database for example 219 // Create a dummy database for example
220 $this->_links = array(); 220 $this->links = array();
221 $link = array( 221 $link = array(
222 'title'=>' Shaarli: the personal, minimalist, super-fast, no-database delicious clone', 222 'title'=>' Shaarli: the personal, minimalist, super-fast, no-database delicious clone',
223 'url'=>'https://github.com/shaarli/Shaarli/wiki', 223 'url'=>'https://github.com/shaarli/Shaarli/wiki',
@@ -230,7 +230,7 @@ You use the community supported version of the original Shaarli project, by Seba
230 'linkdate'=> date('Ymd_His'), 230 'linkdate'=> date('Ymd_His'),
231 'tags'=>'opensource software' 231 'tags'=>'opensource software'
232 ); 232 );
233 $this->_links[$link['linkdate']] = $link; 233 $this->links[$link['linkdate']] = $link;
234 234
235 $link = array( 235 $link = array(
236 'title'=>'My secret stuff... - Pastebin.com', 236 'title'=>'My secret stuff... - Pastebin.com',
@@ -240,64 +240,64 @@ You use the community supported version of the original Shaarli project, by Seba
240 'linkdate'=> date('Ymd_His', strtotime('-1 minute')), 240 'linkdate'=> date('Ymd_His', strtotime('-1 minute')),
241 'tags'=>'secretstuff' 241 'tags'=>'secretstuff'
242 ); 242 );
243 $this->_links[$link['linkdate']] = $link; 243 $this->links[$link['linkdate']] = $link;
244 244
245 // Write database to disk 245 // Write database to disk
246 $this->writeDB(); 246 $this->write();
247 } 247 }
248 248
249 /** 249 /**
250 * Reads database from disk to memory 250 * Reads database from disk to memory
251 */ 251 */
252 private function _readDB() 252 private function read()
253 { 253 {
254 254
255 // Public links are hidden and user not logged in => nothing to show 255 // Public links are hidden and user not logged in => nothing to show
256 if ($this->_hidePublicLinks && !$this->_loggedIn) { 256 if ($this->hidePublicLinks && !$this->loggedIn) {
257 $this->_links = array(); 257 $this->links = array();
258 return; 258 return;
259 } 259 }
260 260
261 // Read data 261 // Read data
262 // Note that gzinflate is faster than gzuncompress. 262 // Note that gzinflate is faster than gzuncompress.
263 // See: http://www.php.net/manual/en/function.gzdeflate.php#96439 263 // See: http://www.php.net/manual/en/function.gzdeflate.php#96439
264 $this->_links = array(); 264 $this->links = array();
265 265
266 if (file_exists($this->_datastore)) { 266 if (file_exists($this->datastore)) {
267 $this->_links = unserialize(gzinflate(base64_decode( 267 $this->links = unserialize(gzinflate(base64_decode(
268 substr(file_get_contents($this->_datastore), 268 substr(file_get_contents($this->datastore),
269 strlen(self::$phpPrefix), -strlen(self::$phpSuffix))))); 269 strlen(self::$phpPrefix), -strlen(self::$phpSuffix)))));
270 } 270 }
271 271
272 // If user is not logged in, filter private links. 272 // If user is not logged in, filter private links.
273 if (!$this->_loggedIn) { 273 if (!$this->loggedIn) {
274 $toremove = array(); 274 $toremove = array();
275 foreach ($this->_links as $link) { 275 foreach ($this->links as $link) {
276 if ($link['private'] != 0) { 276 if ($link['private'] != 0) {
277 $toremove[] = $link['linkdate']; 277 $toremove[] = $link['linkdate'];
278 } 278 }
279 } 279 }
280 foreach ($toremove as $linkdate) { 280 foreach ($toremove as $linkdate) {
281 unset($this->_links[$linkdate]); 281 unset($this->links[$linkdate]);
282 } 282 }
283 } 283 }
284 284
285 $this->_urls = array(); 285 $this->urls = array();
286 foreach ($this->_links as &$link) { 286 foreach ($this->links as &$link) {
287 // Keep the list of the mapping URLs-->linkdate up-to-date. 287 // Keep the list of the mapping URLs-->linkdate up-to-date.
288 $this->_urls[$link['url']] = $link['linkdate']; 288 $this->urls[$link['url']] = $link['linkdate'];
289 289
290 // Sanitize data fields. 290 // Sanitize data fields.
291 sanitizeLink($link); 291 sanitizeLink($link);
292 292
293 // Remove private tags if the user is not logged in. 293 // Remove private tags if the user is not logged in.
294 if (! $this->_loggedIn) { 294 if (! $this->loggedIn) {
295 $link['tags'] = preg_replace('/(^|\s+)\.[^($|\s)]+\s*/', ' ', $link['tags']); 295 $link['tags'] = preg_replace('/(^|\s+)\.[^($|\s)]+\s*/', ' ', $link['tags']);
296 } 296 }
297 297
298 // Do not use the redirector for internal links (Shaarli note URL starting with a '?'). 298 // Do not use the redirector for internal links (Shaarli note URL starting with a '?').
299 if (!empty($this->_redirector) && !startsWith($link['url'], '?')) { 299 if (!empty($this->redirector) && !startsWith($link['url'], '?')) {
300 $link['real_url'] = $this->_redirector; 300 $link['real_url'] = $this->redirector;
301 if ($this->redirectorEncode) { 301 if ($this->redirectorEncode) {
302 $link['real_url'] .= urlencode(unescape($link['url'])); 302 $link['real_url'] .= urlencode(unescape($link['url']));
303 } else { 303 } else {
@@ -315,19 +315,19 @@ You use the community supported version of the original Shaarli project, by Seba
315 * 315 *
316 * @throws IOException the datastore is not writable 316 * @throws IOException the datastore is not writable
317 */ 317 */
318 private function writeDB() 318 private function write()
319 { 319 {
320 if (is_file($this->_datastore) && !is_writeable($this->_datastore)) { 320 if (is_file($this->datastore) && !is_writeable($this->datastore)) {
321 // The datastore exists but is not writeable 321 // The datastore exists but is not writeable
322 throw new IOException($this->_datastore); 322 throw new IOException($this->datastore);
323 } else if (!is_file($this->_datastore) && !is_writeable(dirname($this->_datastore))) { 323 } else if (!is_file($this->datastore) && !is_writeable(dirname($this->datastore))) {
324 // The datastore does not exist and its parent directory is not writeable 324 // The datastore does not exist and its parent directory is not writeable
325 throw new IOException(dirname($this->_datastore)); 325 throw new IOException(dirname($this->datastore));
326 } 326 }
327 327
328 file_put_contents( 328 file_put_contents(
329 $this->_datastore, 329 $this->datastore,
330 self::$phpPrefix.base64_encode(gzdeflate(serialize($this->_links))).self::$phpSuffix 330 self::$phpPrefix.base64_encode(gzdeflate(serialize($this->links))).self::$phpSuffix
331 ); 331 );
332 332
333 } 333 }
@@ -337,14 +337,14 @@ You use the community supported version of the original Shaarli project, by Seba
337 * 337 *
338 * @param string $pageCacheDir page cache directory 338 * @param string $pageCacheDir page cache directory
339 */ 339 */
340 public function savedb($pageCacheDir) 340 public function save($pageCacheDir)
341 { 341 {
342 if (!$this->_loggedIn) { 342 if (!$this->loggedIn) {
343 // TODO: raise an Exception instead 343 // TODO: raise an Exception instead
344 die('You are not authorized to change the database.'); 344 die('You are not authorized to change the database.');
345 } 345 }
346 346
347 $this->writeDB(); 347 $this->write();
348 348
349 invalidateCaches($pageCacheDir); 349 invalidateCaches($pageCacheDir);
350 } 350 }
@@ -358,8 +358,8 @@ You use the community supported version of the original Shaarli project, by Seba
358 */ 358 */
359 public function getLinkFromUrl($url) 359 public function getLinkFromUrl($url)
360 { 360 {
361 if (isset($this->_urls[$url])) { 361 if (isset($this->urls[$url])) {
362 return $this->_links[$this->_urls[$url]]; 362 return $this->links[$this->urls[$url]];
363 } 363 }
364 return false; 364 return false;
365 } 365 }
@@ -376,7 +376,7 @@ You use the community supported version of the original Shaarli project, by Seba
376 public function filterHash($request) 376 public function filterHash($request)
377 { 377 {
378 $request = substr($request, 0, 6); 378 $request = substr($request, 0, 6);
379 $linkFilter = new LinkFilter($this->_links); 379 $linkFilter = new LinkFilter($this->links);
380 return $linkFilter->filter(LinkFilter::$FILTER_HASH, $request); 380 return $linkFilter->filter(LinkFilter::$FILTER_HASH, $request);
381 } 381 }
382 382
@@ -388,7 +388,7 @@ You use the community supported version of the original Shaarli project, by Seba
388 * @return array list of shaare found. 388 * @return array list of shaare found.
389 */ 389 */
390 public function filterDay($request) { 390 public function filterDay($request) {
391 $linkFilter = new LinkFilter($this->_links); 391 $linkFilter = new LinkFilter($this->links);
392 return $linkFilter->filter(LinkFilter::$FILTER_DAY, $request); 392 return $linkFilter->filter(LinkFilter::$FILTER_DAY, $request);
393 } 393 }
394 394
@@ -430,7 +430,7 @@ You use the community supported version of the original Shaarli project, by Seba
430 $request = ''; 430 $request = '';
431 } 431 }
432 432
433 $linkFilter = new LinkFilter($this->_links); 433 $linkFilter = new LinkFilter($this->links);
434 return $linkFilter->filter($type, $request, $casesensitive, $privateonly); 434 return $linkFilter->filter($type, $request, $casesensitive, $privateonly);
435 } 435 }
436 436
@@ -442,7 +442,7 @@ You use the community supported version of the original Shaarli project, by Seba
442 { 442 {
443 $tags = array(); 443 $tags = array();
444 $caseMapping = array(); 444 $caseMapping = array();
445 foreach ($this->_links as $link) { 445 foreach ($this->links as $link) {
446 foreach (preg_split('/\s+/', $link['tags'], 0, PREG_SPLIT_NO_EMPTY) as $tag) { 446 foreach (preg_split('/\s+/', $link['tags'], 0, PREG_SPLIT_NO_EMPTY) as $tag) {
447 if (empty($tag)) { 447 if (empty($tag)) {
448 continue; 448 continue;
@@ -467,7 +467,7 @@ You use the community supported version of the original Shaarli project, by Seba
467 public function days() 467 public function days()
468 { 468 {
469 $linkDays = array(); 469 $linkDays = array();
470 foreach (array_keys($this->_links) as $day) { 470 foreach (array_keys($this->links) as $day) {
471 $linkDays[substr($day, 0, 8)] = 0; 471 $linkDays[substr($day, 0, 8)] = 0;
472 } 472 }
473 $linkDays = array_keys($linkDays); 473 $linkDays = array_keys($linkDays);
diff --git a/application/NetscapeBookmarkUtils.php b/application/NetscapeBookmarkUtils.php
index d6840d37..dd21f05b 100644
--- a/application/NetscapeBookmarkUtils.php
+++ b/application/NetscapeBookmarkUtils.php
@@ -183,7 +183,7 @@ class NetscapeBookmarkUtils
183 $importCount++; 183 $importCount++;
184 } 184 }
185 185
186 $linkDb->savedb($pagecache); 186 $linkDb->save($pagecache);
187 return self::importStatus( 187 return self::importStatus(
188 $filename, 188 $filename,
189 $filesize, 189 $filesize,
diff --git a/application/Updater.php b/application/Updater.php
index 90913235..36eddd4f 100644
--- a/application/Updater.php
+++ b/application/Updater.php
@@ -143,7 +143,7 @@ class Updater
143 $link['tags'] = implode(' ', array_unique(LinkFilter::tagsStrToArray($link['tags'], true))); 143 $link['tags'] = implode(' ', array_unique(LinkFilter::tagsStrToArray($link['tags'], true)));
144 $this->linkDB[$link['linkdate']] = $link; 144 $this->linkDB[$link['linkdate']] = $link;
145 } 145 }
146 $this->linkDB->savedb($this->conf->get('resource.page_cache')); 146 $this->linkDB->save($this->conf->get('resource.page_cache'));
147 return true; 147 return true;
148 } 148 }
149 149
diff --git a/index.php b/index.php
index 6d712aee..84282b8d 100644
--- a/index.php
+++ b/index.php
@@ -1211,7 +1211,7 @@ function renderPage($conf, $pluginManager)
1211 $value['tags']=trim(implode(' ',$tags)); 1211 $value['tags']=trim(implode(' ',$tags));
1212 $LINKSDB[$key]=$value; 1212 $LINKSDB[$key]=$value;
1213 } 1213 }
1214 $LINKSDB->savedb($conf->get('resource.page_cache')); 1214 $LINKSDB->save($conf->get('resource.page_cache'));
1215 echo '<script>alert("Tag was removed from '.count($linksToAlter).' links.");document.location=\'?\';</script>'; 1215 echo '<script>alert("Tag was removed from '.count($linksToAlter).' links.");document.location=\'?\';</script>';
1216 exit; 1216 exit;
1217 } 1217 }
@@ -1228,7 +1228,7 @@ function renderPage($conf, $pluginManager)
1228 $value['tags']=trim(implode(' ',$tags)); 1228 $value['tags']=trim(implode(' ',$tags));
1229 $LINKSDB[$key]=$value; 1229 $LINKSDB[$key]=$value;
1230 } 1230 }
1231 $LINKSDB->savedb($conf->get('resource.page_cache')); // Save to disk. 1231 $LINKSDB->save($conf->get('resource.page_cache')); // Save to disk.
1232 echo '<script>alert("Tag was renamed in '.count($linksToAlter).' links.");document.location=\'?searchtags='.urlencode($_POST['totag']).'\';</script>'; 1232 echo '<script>alert("Tag was renamed in '.count($linksToAlter).' links.");document.location=\'?searchtags='.urlencode($_POST['totag']).'\';</script>';
1233 exit; 1233 exit;
1234 } 1234 }
@@ -1283,7 +1283,7 @@ function renderPage($conf, $pluginManager)
1283 $pluginManager->executeHooks('save_link', $link); 1283 $pluginManager->executeHooks('save_link', $link);
1284 1284
1285 $LINKSDB[$linkdate] = $link; 1285 $LINKSDB[$linkdate] = $link;
1286 $LINKSDB->savedb($conf->get('resource.page_cache')); 1286 $LINKSDB->save($conf->get('resource.page_cache'));
1287 pubsubhub($conf); 1287 pubsubhub($conf);
1288 1288
1289 // If we are called from the bookmarklet, we must close the popup: 1289 // If we are called from the bookmarklet, we must close the popup:
@@ -1325,7 +1325,7 @@ function renderPage($conf, $pluginManager)
1325 $pluginManager->executeHooks('delete_link', $LINKSDB[$linkdate]); 1325 $pluginManager->executeHooks('delete_link', $LINKSDB[$linkdate]);
1326 1326
1327 unset($LINKSDB[$linkdate]); 1327 unset($LINKSDB[$linkdate]);
1328 $LINKSDB->savedb('resource.page_cache'); // save to disk 1328 $LINKSDB->save('resource.page_cache'); // save to disk
1329 1329
1330 // If we are called from the bookmarklet, we must close the popup: 1330 // If we are called from the bookmarklet, we must close the popup:
1331 if (isset($_GET['source']) && ($_GET['source']=='bookmarklet' || $_GET['source']=='firefoxsocialapi')) { echo '<script>self.close();</script>'; exit; } 1331 if (isset($_GET['source']) && ($_GET['source']=='bookmarklet' || $_GET['source']=='firefoxsocialapi')) { echo '<script>self.close();</script>'; exit; }
diff --git a/tests/LinkDBTest.php b/tests/LinkDBTest.php
index 31306069..9d79386c 100644
--- a/tests/LinkDBTest.php
+++ b/tests/LinkDBTest.php
@@ -117,7 +117,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
117 unlink(self::$testDatastore); 117 unlink(self::$testDatastore);
118 $this->assertFileNotExists(self::$testDatastore); 118 $this->assertFileNotExists(self::$testDatastore);
119 119
120 $checkDB = self::getMethod('_checkDB'); 120 $checkDB = self::getMethod('check');
121 $checkDB->invokeArgs($linkDB, array()); 121 $checkDB->invokeArgs($linkDB, array());
122 $this->assertFileExists(self::$testDatastore); 122 $this->assertFileExists(self::$testDatastore);
123 123
@@ -134,7 +134,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
134 $datastoreSize = filesize(self::$testDatastore); 134 $datastoreSize = filesize(self::$testDatastore);
135 $this->assertGreaterThan(0, $datastoreSize); 135 $this->assertGreaterThan(0, $datastoreSize);
136 136
137 $checkDB = self::getMethod('_checkDB'); 137 $checkDB = self::getMethod('check');
138 $checkDB->invokeArgs($linkDB, array()); 138 $checkDB->invokeArgs($linkDB, array());
139 139
140 // ensure the datastore is left unmodified 140 // ensure the datastore is left unmodified
@@ -180,7 +180,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
180 /** 180 /**
181 * Save the links to the DB 181 * Save the links to the DB
182 */ 182 */
183 public function testSaveDB() 183 public function testSave()
184 { 184 {
185 $testDB = new LinkDB(self::$testDatastore, true, false); 185 $testDB = new LinkDB(self::$testDatastore, true, false);
186 $dbSize = sizeof($testDB); 186 $dbSize = sizeof($testDB);
@@ -194,7 +194,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
194 'tags'=>'unit test' 194 'tags'=>'unit test'
195 ); 195 );
196 $testDB[$link['linkdate']] = $link; 196 $testDB[$link['linkdate']] = $link;
197 $testDB->savedb('tests'); 197 $testDB->save('tests');
198 198
199 $testDB = new LinkDB(self::$testDatastore, true, false); 199 $testDB = new LinkDB(self::$testDatastore, true, false);
200 $this->assertEquals($dbSize + 1, sizeof($testDB)); 200 $this->assertEquals($dbSize + 1, sizeof($testDB));
diff --git a/tests/utils/ReferenceLinkDB.php b/tests/utils/ReferenceLinkDB.php
index 937961c8..abca4656 100644
--- a/tests/utils/ReferenceLinkDB.php
+++ b/tests/utils/ReferenceLinkDB.php
@@ -13,7 +13,7 @@ class ReferenceLinkDB
13 /** 13 /**
14 * Populates the test DB with reference data 14 * Populates the test DB with reference data
15 */ 15 */
16 function __construct() 16 public function __construct()
17 { 17 {
18 $this->addLink( 18 $this->addLink(
19 'Link title: @website', 19 'Link title: @website',