From 4fa9a3c5d83a1024678596a586afe5df14a345b5 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Thu, 16 Aug 2018 17:25:47 +0200 Subject: [PATCH] Fix a JS bug preventing AJAX tag deletion to work Fixes #1214 --- assets/default/js/base.js | 2 +- index.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/assets/default/js/base.js b/assets/default/js/base.js index 8bf79d3e..1b8d8c36 100644 --- a/assets/default/js/base.js +++ b/assets/default/js/base.js @@ -548,7 +548,7 @@ function init(description) { event.preventDefault(); const block = findParent(event.target, 'div', { class: 'tag-list-item' }); const tag = block.getAttribute('data-tag'); - const refreshedToken = document.getElementById('token'); + const refreshedToken = document.getElementById('token').value; if (confirm(`Are you sure you want to delete the tag "${tag}"?`)) { const xhr = new XMLHttpRequest(); diff --git a/index.php b/index.php index 8f6ee50a..eb717536 100644 --- a/index.php +++ b/index.php @@ -1084,7 +1084,8 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager, die(t('Wrong token.')); } - $alteredLinks = $LINKSDB->renameTag(escape($_POST['fromtag']), escape($_POST['totag'])); + $toTag = isset($_POST['totag']) ? escape($_POST['totag']) : null; + $alteredLinks = $LINKSDB->renameTag(escape($_POST['fromtag']), $toTag); $LINKSDB->save($conf->get('resource.page_cache')); foreach ($alteredLinks as $link) { $history->updateLink($link);