framework icon indicating copy to clipboard operation
framework copied to clipboard

-

Open ghost opened this issue 10 years ago • 6 comments

ghost avatar May 19 '16 01:05 ghost

GIF of issue.

kulga avatar May 19 '16 01:05 kulga

Catchable fatal error: Argument 1 passed to Flarum\Tags\Tag::Flarum\Tags\{closure}() must be an instance of Flarum\Tags\Tag, null given, called in /flarum/vendor/flarum/flarum-ext-tags/src/Tag.php on line 147 and defined in /flarum/vendor/flarum/flarum-ext-tags/src/Tag.php on line 139

after deleting a tag its children parent ID stay the same, should we remove children too? or make them root tag?

sijad avatar May 30 '16 20:05 sijad

do you think it's a idea to prevent deleting a tag with children?

sijad avatar Jun 02 '16 14:06 sijad

I think the best thing to do at this point is to fix the code so that tags referencing a non-existent parent are regarded as not having a parent. This will eliminate a crash in the event that someone goes into their database and manually deletes a parent tag.

tobyzerner avatar Jun 03 '16 01:06 tobyzerner

this fixes the error but child tags will be disappear

From e81b75f84a33cded431950e4a3fac42ff4b2fa48 Mon Sep 17 00:00:00 2001
From: Sjjad Hashemian <[email protected]>
Date: Fri, 3 Jun 2016 21:54:49 +0430
Subject: [PATCH] Fix Fatal error

---
 src/Tag.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Tag.php b/src/Tag.php
index fca4636..e98e80e 100644
--- a/src/Tag.php
+++ b/src/Tag.php
@@ -143,7 +143,7 @@ class Tag extends AbstractModel
         foreach ($tags as $tag) {
             $can = $canForTag($tag);

-            if ($can && $tag->parent_id) {
+            if ($can && isset($tags[$tag->parent_id]) && $tag->parent_id) {
                 $can = $canForTag($tag->parent);
             }

-- 
2.6.4 (Apple Git-63)

sijad avatar Jun 03 '16 17:06 sijad

Thanks for looking into that @sijad. I've pushed a commit that incorporates a variation of your fix, and also unsets the parent_id of children when a tag is deleted.

tobyzerner avatar Jun 04 '16 06:06 tobyzerner