-
GIF of issue.

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?
do you think it's a idea to prevent deleting a tag with children?
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.
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)
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.