aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGravatar Alexis Degrugillier <aledeg@users.noreply.github.com> 2025-09-01 17:29:54 -0400
committerGravatar GitHub <noreply@github.com> 2025-09-01 23:29:54 +0200
commitb2a82b64b5714c66f9e0e291b967bcaa536bf041 (patch)
treebaadc8e4ea103b13c81a6535f7e46d38e394702b /app
parentd31f485973f7e38239b59b17fc43e9f3ab64695f (diff)
fix: add validation when creating a new tag (#7890)
A tag name must be unique and can't be used as a category. There were no error message when creating a tag identical to an existing category. Now, this is addressed. See #7686 Closes #7686 Changes proposed in this pull request: - add validation on tag creation How to test the feature manually: 1. create a new category (ex: `HW`) 2. create a new tag with the same name as the new category (ex: `HW`) 3. validate that the appropriate error message is displayed
Diffstat (limited to 'app')
-rw-r--r--app/Controllers/tagController.php15
1 files changed, 11 insertions, 4 deletions
diff --git a/app/Controllers/tagController.php b/app/Controllers/tagController.php
index da7e0c2da..47301bba0 100644
--- a/app/Controllers/tagController.php
+++ b/app/Controllers/tagController.php
@@ -153,14 +153,21 @@ class FreshRSS_tag_Controller extends FreshRSS_ActionController {
Minz_Error::error(405);
}
+ $url_redirect = ['c' => 'tag', 'a' => 'index'];
$name = Minz_Request::paramString('name');
+
+ $catDAO = FreshRSS_Factory::createCategoryDao();
+ if ($catDAO->searchByName($name) !== null) {
+ Minz_Request::bad(_t('feedback.sub.category.name_exists'), $url_redirect);
+ }
+
$tagDAO = FreshRSS_Factory::createTagDao();
- if (strlen($name) > 0 && null === $tagDAO->searchByName($name)) {
- $tagDAO->addTag(['name' => $name]);
- Minz_Request::good(_t('feedback.tag.created', $name), ['c' => 'tag', 'a' => 'index']);
+ if ($tagDAO->searchByName($name) !== null) {
+ Minz_Request::bad(_t('feedback.tag.name_exists', $name), $url_redirect);
}
- Minz_Request::bad(_t('feedback.tag.name_exists', $name), ['c' => 'tag', 'a' => 'index']);
+ $tagDAO->addTag(['name' => $name]);
+ Minz_Request::good(_t('feedback.tag.created', $name), $url_redirect);
}
/**