aboutsummaryrefslogtreecommitdiff
path: root/app/Controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/Controllers')
-rw-r--r--app/Controllers/tagController.php14
1 files changed, 10 insertions, 4 deletions
diff --git a/app/Controllers/tagController.php b/app/Controllers/tagController.php
index 4f3fe9bf9..0a57c0df2 100644
--- a/app/Controllers/tagController.php
+++ b/app/Controllers/tagController.php
@@ -90,7 +90,7 @@ class FreshRSS_tag_Controller extends Minz_ActionController {
$name = Minz_Request::param('name');
$tagDAO = FreshRSS_Factory::createTagDao();
- if (null === $tagDAO->searchByName($name)) {
+ if (strlen($name) > 0 && null === $tagDAO->searchByName($name)) {
$tagDAO->addTag(['name' => $name]);
Minz_Request::good(_t('feedback.tag.created', $name), ['c' => 'tag', 'a' => 'index'], true);
}
@@ -106,13 +106,19 @@ class FreshRSS_tag_Controller extends Minz_ActionController {
$targetName = Minz_Request::param('name');
$sourceId = Minz_Request::param('id_tag');
- $tagDAO = FreshRSS_Factory::createTagDao();
+ if ($targetName == '' || $sourceId == '') {
+ return Minz_Error::error(400);
+ }
- $sourceName = $tagDAO->searchById($sourceId)->name();
+ $tagDAO = FreshRSS_Factory::createTagDao();
+ $sourceTag = $tagDAO->searchById($sourceId);
+ $sourceName = $sourceTag == null ? null : $sourceTag->name();
$targetTag = $tagDAO->searchByName($targetName);
- if (null === $targetTag) {
+ if ($targetTag == null) {
+ // There is no existing tag with the same target name
$tagDAO->updateTag($sourceId, ['name' => $targetName]);
} else {
+ // There is an existing tag with the same target name
$tagDAO->updateEntryTag($sourceId, $targetTag->id());
$tagDAO->deleteTag($sourceId);
}