Skip to content
This repository was archived by the owner on Dec 16, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions tests/Api/PostsAddTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,12 @@ public function testReplaceYes()
//all should be well
$this->assertEquals(200, $res->getStatus());

//get date
$data = $this->bs->getBookmarks(0, null, $uId);
$creationDate = $data['bookmarks'][0]['bDatetime'];
$modificationDate = $data['bookmarks'][0]['bModified'];
sleep(1); //wait 1 second to detect change in modification time

//send it a second time, with different title
list($req, $dummy) = $this->getAuthRequest();
$req->setMethod(HTTP_Request2::METHOD_POST);
Expand Down Expand Up @@ -405,6 +411,9 @@ public function testReplaceYes()
$data = $this->bs->getBookmarks(0, null, $uId);
$this->assertEquals(1, $data['total']);
$this->assertEquals($title2, $data['bookmarks'][0]['bTitle']);
// creation date should be unchanged and modification date should be newer
$this->assertEquals($creationDate, $data['bookmarks'][0]['bDatetime'], "Creation date must not be updated, when replacing a bookmark.");
$this->assertGreaterThan($modificationDate, $data['bookmarks'][0]['bModified'], "Modification date must be updated, when replacing a bookmark.");
}


Expand Down
15 changes: 8 additions & 7 deletions www/api/posts_add.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
if (isset($_REQUEST['tags']) && (trim($_REQUEST['tags']) != '')
&& (trim($_REQUEST['tags']) != ',')
) {
$tags = trim($_REQUEST['tags']);
$tags = trim(urldecode($_REQUEST['tags']));
} else {
$tags = null;
}
Expand Down Expand Up @@ -123,12 +123,13 @@
header('HTTP/1.0 409 Conflict');
$msg = 'bookmark does already exist';
} else {
//delete it before we re-add it
//edit bookmark instead
$bookmark = $bs->getBookmarkByAddress($url, false);
$bId = $bookmark['bId'];
$bs->deleteBookmark($bId);

$exists = false;
$bId = intval($bookmark['bId']);
$updated = $bs->updateBookmark(
$bId, $url, $description, $extended, '', $status, $tags, null, null, true
);
$msg = 'done';
}
}

Expand All @@ -143,4 +144,4 @@
// Set up the XML file and output the result.
echo '<?xml version="1.0" standalone="yes" ?' . ">\r\n";
echo '<result code="' . $msg .'" />';
?>
?>