diff options
author | ArthurHoaro <arthur@hoa.ro> | 2017-01-16 12:39:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-16 12:39:01 +0100 |
commit | d7d240f136125d2b66c4f7c82a1e2e0f98f4bae3 (patch) | |
tree | 2f90d8263f8570a1a853020bf8a9163d471e7eb8 | |
parent | 36dcf997e404e2cd4bc31d132875484d6cf4e667 (diff) | |
parent | d6327389fc5cbb659e7f32fb61b2f1d5c86b02ee (diff) | |
download | Shaarli-d7d240f136125d2b66c4f7c82a1e2e0f98f4bae3.tar.gz Shaarli-d7d240f136125d2b66c4f7c82a1e2e0f98f4bae3.tar.zst Shaarli-d7d240f136125d2b66c4f7c82a1e2e0f98f4bae3.zip |
Merge pull request #759 from ArthurHoaro/hotfix/dup-tags
Prevent tag duplicate when renaming
-rw-r--r-- | index.php | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -1207,15 +1207,15 @@ function renderPage($conf, $pluginManager, $LINKSDB) | |||
1207 | $needle = trim($_POST['fromtag']); | 1207 | $needle = trim($_POST['fromtag']); |
1208 | // True for case-sensitive tag search. | 1208 | // True for case-sensitive tag search. |
1209 | $linksToAlter = $LINKSDB->filterSearch(array('searchtags' => $needle), true); | 1209 | $linksToAlter = $LINKSDB->filterSearch(array('searchtags' => $needle), true); |
1210 | foreach($linksToAlter as $key=>$value) | 1210 | foreach($linksToAlter as $key=>$value) { |
1211 | { | 1211 | $tags = preg_split('/\s+/', trim($value['tags'])); |
1212 | $tags = explode(' ',trim($value['tags'])); | 1212 | // Replace tags value. |
1213 | $tags[array_search($needle,$tags)] = trim($_POST['totag']); // Replace tags value. | 1213 | $tags[array_search($needle, $tags)] = trim($_POST['totag']); |
1214 | $value['tags']=trim(implode(' ',$tags)); | 1214 | $value['tags'] = implode(' ', array_unique($tags)); |
1215 | $LINKSDB[$key]=$value; | 1215 | $LINKSDB[$key] = $value; |
1216 | } | 1216 | } |
1217 | $LINKSDB->save($conf->get('resource.page_cache')); // Save to disk. | 1217 | $LINKSDB->save($conf->get('resource.page_cache')); // Save to disk. |
1218 | echo '<script>alert("Tag was renamed in '.count($linksToAlter).' links.");document.location=\'?searchtags='.urlencode($_POST['totag']).'\';</script>'; | 1218 | echo '<script>alert("Tag was renamed in '.count($linksToAlter).' links.");document.location=\'?searchtags='.urlencode(escape($_POST['totag'])).'\';</script>'; |
1219 | exit; | 1219 | exit; |
1220 | } | 1220 | } |
1221 | } | 1221 | } |