diff options
Diffstat (limited to 'application/NetscapeBookmarkUtils.php')
-rw-r--r-- | application/NetscapeBookmarkUtils.php | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/application/NetscapeBookmarkUtils.php b/application/NetscapeBookmarkUtils.php index dd21f05b..8a939adb 100644 --- a/application/NetscapeBookmarkUtils.php +++ b/application/NetscapeBookmarkUtils.php | |||
@@ -38,7 +38,7 @@ class NetscapeBookmarkUtils | |||
38 | if ($link['private'] == 0 && $selection == 'private') { | 38 | if ($link['private'] == 0 && $selection == 'private') { |
39 | continue; | 39 | continue; |
40 | } | 40 | } |
41 | $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']); | 41 | $date = $link['created']; |
42 | $link['timestamp'] = $date->getTimestamp(); | 42 | $link['timestamp'] = $date->getTimestamp(); |
43 | $link['taglist'] = str_replace(' ', ',', $link['tags']); | 43 | $link['taglist'] = str_replace(' ', ',', $link['tags']); |
44 | 44 | ||
@@ -147,7 +147,6 @@ class NetscapeBookmarkUtils | |||
147 | 'url' => $bkm['uri'], | 147 | 'url' => $bkm['uri'], |
148 | 'description' => $bkm['note'], | 148 | 'description' => $bkm['note'], |
149 | 'private' => $private, | 149 | 'private' => $private, |
150 | 'linkdate'=> '', | ||
151 | 'tags' => $bkm['tags'] | 150 | 'tags' => $bkm['tags'] |
152 | ); | 151 | ); |
153 | 152 | ||
@@ -161,25 +160,21 @@ class NetscapeBookmarkUtils | |||
161 | } | 160 | } |
162 | 161 | ||
163 | // Overwrite an existing link, keep its date | 162 | // Overwrite an existing link, keep its date |
164 | $newLink['linkdate'] = $existingLink['linkdate']; | 163 | $newLink['id'] = $existingLink['id']; |
165 | $linkDb[$existingLink['linkdate']] = $newLink; | 164 | $newLink['created'] = $existingLink['created']; |
165 | $newLink['updated'] = new DateTime(); | ||
166 | $linkDb[$existingLink['id']] = $newLink; | ||
166 | $importCount++; | 167 | $importCount++; |
167 | $overwriteCount++; | 168 | $overwriteCount++; |
168 | continue; | 169 | continue; |
169 | } | 170 | } |
170 | 171 | ||
171 | // Add a new link | 172 | // Add a new link - @ used for UNIX timestamps |
172 | $newLinkDate = new DateTime('@'.strval($bkm['time'])); | 173 | $newLinkDate = new DateTime('@'.strval($bkm['time'])); |
173 | while (!empty($linkDb[$newLinkDate->format(LinkDB::LINK_DATE_FORMAT)])) { | 174 | $newLinkDate->setTimezone(new DateTimeZone(date_default_timezone_get())); |
174 | // Ensure the date/time is not already used | 175 | $newLink['created'] = $newLinkDate; |
175 | // - this hack is necessary as the date/time acts as a primary key | 176 | $newLink['id'] = $linkDb->getNextId(); |
176 | // - apply 1 second increments until an unused index is found | 177 | $linkDb[$newLink['id']] = $newLink; |
177 | // See https://github.com/shaarli/Shaarli/issues/351 | ||
178 | $newLinkDate->add(new DateInterval('PT1S')); | ||
179 | } | ||
180 | $linkDbDate = $newLinkDate->format(LinkDB::LINK_DATE_FORMAT); | ||
181 | $newLink['linkdate'] = $linkDbDate; | ||
182 | $linkDb[$linkDbDate] = $newLink; | ||
183 | $importCount++; | 178 | $importCount++; |
184 | } | 179 | } |
185 | 180 | ||