]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
LinkDB: update datastore method names
authorVirtualTam <virtualtam@flibidi.net>
Thu, 20 Oct 2016 19:19:51 +0000 (21:19 +0200)
committerVirtualTam <virtualtam@flibidi.net>
Thu, 20 Oct 2016 19:33:40 +0000 (21:33 +0200)
Relates to https://github.com/shaarli/Shaarli/issues/95

Signed-off-by: VirtualTam <virtualtam@flibidi.net>
application/LinkDB.php
application/NetscapeBookmarkUtils.php
application/Updater.php
index.php
tests/LinkDBTest.php

index 2d42c51420bd015941e3392b724807706c3f5d4c..f5f209f61837a43417e7607a433adf5714e5f0be 100644 (file)
@@ -100,8 +100,8 @@ class LinkDB implements Iterator, Countable, ArrayAccess
         $this->hidePublicLinks = $hidePublicLinks;
         $this->redirector = $redirector;
         $this->redirectorEncode = $redirectorEncode === true;
-        $this->checkDB();
-        $this->readDB();
+        $this->check();
+        $this->read();
     }
 
     /**
@@ -210,7 +210,7 @@ class LinkDB implements Iterator, Countable, ArrayAccess
      *
      * If no DB file is found, creates a dummy DB.
      */
-    private function checkDB()
+    private function check()
     {
         if (file_exists($this->datastore)) {
             return;
@@ -243,13 +243,13 @@ You use the community supported version of the original Shaarli project, by Seba
         $this->links[$link['linkdate']] = $link;
 
         // Write database to disk
-        $this->writeDB();
+        $this->write();
     }
 
     /**
      * Reads database from disk to memory
      */
-    private function readDB()
+    private function read()
     {
 
         // Public links are hidden and user not logged in => nothing to show
@@ -315,7 +315,7 @@ You use the community supported version of the original Shaarli project, by Seba
      *
      * @throws IOException the datastore is not writable
      */
-    private function writeDB()
+    private function write()
     {
         if (is_file($this->datastore) && !is_writeable($this->datastore)) {
             // The datastore exists but is not writeable
@@ -337,14 +337,14 @@ You use the community supported version of the original Shaarli project, by Seba
      *
      * @param string $pageCacheDir page cache directory
      */
-    public function savedb($pageCacheDir)
+    public function save($pageCacheDir)
     {
         if (!$this->loggedIn) {
             // TODO: raise an Exception instead
             die('You are not authorized to change the database.');
         }
 
-        $this->writeDB();
+        $this->write();
 
         invalidateCaches($pageCacheDir);
     }
index d6840d37862d2463f84f54212f5614cdf28385f3..dd21f05b1d9a66f4df53af4576003bc23ae33a35 100644 (file)
@@ -183,7 +183,7 @@ class NetscapeBookmarkUtils
             $importCount++;
         }
 
-        $linkDb->savedb($pagecache);
+        $linkDb->save($pagecache);
         return self::importStatus(
             $filename,
             $filesize,
index 90913235ca8e528d22d8103288971a787fcf08ef..36eddd4f12e100f86b1cc97b66f0844fd9ed643f 100644 (file)
@@ -143,7 +143,7 @@ class Updater
             $link['tags'] = implode(' ', array_unique(LinkFilter::tagsStrToArray($link['tags'], true)));
             $this->linkDB[$link['linkdate']] = $link;
         }
-        $this->linkDB->savedb($this->conf->get('resource.page_cache'));
+        $this->linkDB->save($this->conf->get('resource.page_cache'));
         return true;
     }
 
index 6d712aee08e61601b961dc5e8125b42e544777fe..84282b8dc6c6ecc41dd67cae0eae0e9c3fdf883a 100644 (file)
--- a/index.php
+++ b/index.php
@@ -1211,7 +1211,7 @@ function renderPage($conf, $pluginManager)
                 $value['tags']=trim(implode(' ',$tags));
                 $LINKSDB[$key]=$value;
             }
-            $LINKSDB->savedb($conf->get('resource.page_cache'));
+            $LINKSDB->save($conf->get('resource.page_cache'));
             echo '<script>alert("Tag was removed from '.count($linksToAlter).' links.");document.location=\'?\';</script>';
             exit;
         }
@@ -1228,7 +1228,7 @@ function renderPage($conf, $pluginManager)
                 $value['tags']=trim(implode(' ',$tags));
                 $LINKSDB[$key]=$value;
             }
-            $LINKSDB->savedb($conf->get('resource.page_cache')); // Save to disk.
+            $LINKSDB->save($conf->get('resource.page_cache')); // Save to disk.
             echo '<script>alert("Tag was renamed in '.count($linksToAlter).' links.");document.location=\'?searchtags='.urlencode($_POST['totag']).'\';</script>';
             exit;
         }
@@ -1283,7 +1283,7 @@ function renderPage($conf, $pluginManager)
         $pluginManager->executeHooks('save_link', $link);
 
         $LINKSDB[$linkdate] = $link;
-        $LINKSDB->savedb($conf->get('resource.page_cache'));
+        $LINKSDB->save($conf->get('resource.page_cache'));
         pubsubhub($conf);
 
         // If we are called from the bookmarklet, we must close the popup:
@@ -1325,7 +1325,7 @@ function renderPage($conf, $pluginManager)
         $pluginManager->executeHooks('delete_link', $LINKSDB[$linkdate]);
 
         unset($LINKSDB[$linkdate]);
-        $LINKSDB->savedb('resource.page_cache'); // save to disk
+        $LINKSDB->save('resource.page_cache'); // save to disk
 
         // If we are called from the bookmarklet, we must close the popup:
         if (isset($_GET['source']) && ($_GET['source']=='bookmarklet' || $_GET['source']=='firefoxsocialapi')) { echo '<script>self.close();</script>'; exit; }
index 43652e72c502fbd695e362755a8cc92d53b65c7c..9d79386c0b0b5a76aecdfe8825434722278290d4 100644 (file)
@@ -117,7 +117,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
         unlink(self::$testDatastore);
         $this->assertFileNotExists(self::$testDatastore);
 
-        $checkDB = self::getMethod('checkDB');
+        $checkDB = self::getMethod('check');
         $checkDB->invokeArgs($linkDB, array());
         $this->assertFileExists(self::$testDatastore);
 
@@ -134,7 +134,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
         $datastoreSize = filesize(self::$testDatastore);
         $this->assertGreaterThan(0, $datastoreSize);
 
-        $checkDB = self::getMethod('checkDB');
+        $checkDB = self::getMethod('check');
         $checkDB->invokeArgs($linkDB, array());
 
         // ensure the datastore is left unmodified
@@ -180,7 +180,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
     /**
      * Save the links to the DB
      */
-    public function testSaveDB()
+    public function testSave()
     {
         $testDB = new LinkDB(self::$testDatastore, true, false);
         $dbSize = sizeof($testDB);
@@ -194,7 +194,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
             'tags'=>'unit test'
         );
         $testDB[$link['linkdate']] = $link;
-        $testDB->savedb('tests');
+        $testDB->save('tests');
 
         $testDB = new LinkDB(self::$testDatastore, true, false);
         $this->assertEquals($dbSize + 1, sizeof($testDB));