]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - application/NetscapeBookmarkUtils.php
Merge pull request #980 from ArthurHoaro/hotfix/textarea-resize-jumpy
[github/shaarli/Shaarli.git] / application / NetscapeBookmarkUtils.php
index f467a074ab01e1398d19f60d35e503685d7a18d8..2a10ff22149f8c89f30458d9e5c907e19847438a 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 
 use Psr\Log\LogLevel;
+use Shaarli\Config\ConfigManager;
 use Shaarli\NetscapeBookmarkParser\NetscapeBookmarkParser;
 use Katzgrau\KLogger\Logger;
 
@@ -94,10 +95,11 @@ class NetscapeBookmarkUtils
      * @param array         $files     Server $_FILES parameters
      * @param LinkDB        $linkDb    Loaded LinkDB instance
      * @param ConfigManager $conf      instance
+     * @param History       $history   History instance
      *
      * @return string Summary of the bookmark import status
      */
-    public static function import($post, $files, $linkDb, $conf)
+    public static function import($post, $files, $linkDb, $conf, $history)
     {
         $filename = $files['filetoupload']['name'];
         $filesize = $files['filetoupload']['size'];
@@ -178,9 +180,11 @@ class NetscapeBookmarkUtils
                 $newLink['id'] = $existingLink['id'];
                 $newLink['created'] = $existingLink['created'];
                 $newLink['updated'] = new DateTime();
+                $newLink['shorturl'] = $existingLink['shorturl'];
                 $linkDb[$existingLink['id']] = $newLink;
                 $importCount++;
                 $overwriteCount++;
+                $history->updateLink($newLink);
                 continue;
             }
 
@@ -192,6 +196,7 @@ class NetscapeBookmarkUtils
             $newLink['shorturl'] = link_small_hash($newLink['created'], $newLink['id']);
             $linkDb[$newLink['id']] = $newLink;
             $importCount++;
+            $history->addLink($newLink);
         }
 
         $linkDb->save($conf->get('resource.page_cache'));