Skip to content

Commit a910ca1

Browse files
committed
Prevent Move() on new Topic
Currently, `Move()` is called during `Save()` if the `ParentId` has changed prior to the last `Save()` or `Load()`. This is a reasonable assumption for existing topics. For new topics, however, it leads to a `Topic` being moved in the database even though that `Topic` doesn't yet exist. To mitigate this, put in an exception to check the status of the topic.
1 parent 2ab0e8b commit a910ca1

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

Ignia.Topics/Repositories/TopicRepositoryBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public virtual int Save(Topic topic, bool isRecursive = false, bool isDraft = fa
178178
/*----------------------------------------------------------------------------------------------------------------------
179179
| Perform reordering and/or move
180180
\---------------------------------------------------------------------------------------------------------------------*/
181-
if (topic.Parent != null && topic.Attributes.IsDirty("ParentId")) {
181+
if (topic.Parent != null && topic.Attributes.IsDirty("ParentId") && topic.Id >= 0) {
182182
var topicIndex = topic.Parent.Children.IndexOf(topic);
183183
if (topicIndex > 0) {
184184
Move(topic, topic.Parent, topic.Parent.Children[topicIndex - 1]);

0 commit comments

Comments
 (0)