aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2017-01-16 12:39:01 +0100
committerGitHub <noreply@github.com>2017-01-16 12:39:01 +0100
commitd7d240f136125d2b66c4f7c82a1e2e0f98f4bae3 (patch)
tree2f90d8263f8570a1a853020bf8a9163d471e7eb8 /index.php
parent36dcf997e404e2cd4bc31d132875484d6cf4e667 (diff)
parentd6327389fc5cbb659e7f32fb61b2f1d5c86b02ee (diff)
downloadShaarli-d7d240f136125d2b66c4f7c82a1e2e0f98f4bae3.tar.gz
Shaarli-d7d240f136125d2b66c4f7c82a1e2e0f98f4bae3.tar.zst
Shaarli-d7d240f136125d2b66c4f7c82a1e2e0f98f4bae3.zip
Merge pull request #759 from ArthurHoaro/hotfix/dup-tags
Prevent tag duplicate when renaming
Diffstat (limited to 'index.php')
-rw-r--r--index.php14
1 files changed, 7 insertions, 7 deletions
diff --git a/index.php b/index.php
index 32f5ca3c..8055a7b7 100644
--- a/index.php
+++ b/index.php
@@ -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 }