fixes #1456 and #1970 for parent: metatag; fixes #1968

This commit is contained in:
Toks
2013-10-17 00:02:58 -04:00
parent de80981323
commit 7314a843fe

View File

@@ -464,7 +464,7 @@ class Post < ActiveRecord::Base
self.parent_id = nil
when /^parent:(\d+)$/i
if Post.exists?(["id = ? and is_deleted = false", $1.to_i])
if $1.to_i != id && Post.exists?(["id = ?", $1.to_i]) && Post.find($1.to_i).parent_id != id
self.parent_id = $1.to_i
end
@@ -870,7 +870,7 @@ class Post < ActiveRecord::Base
end
def post_is_not_its_own_parent
if parent_id.present? && id == parent_id
if !new_record? && id == parent_id
errors[:base] << "Post cannot have itself as a parent"
false
end