patch inspired from the issue described in the pull request #72: the method to retrieve direct template descendants was wrong

This commit is contained in:
did 2011-05-04 14:53:09 +02:00
parent 6dd810b44e
commit b4c86e39dc

View File

@ -80,9 +80,7 @@ module Extensions
# group them by fullpath for better performance # group them by fullpath for better performance
cached = template_descendants.inject({}) { |memo, page| memo[page.fullpath] = page; memo } cached = template_descendants.inject({}) { |memo, page| memo[page.fullpath] = page; memo }
template_descendants.each do |page| self._update_direct_template_descendants(template_descendants.clone, cached)
page.send(:_parse_and_serialize_template, { :cached_parent => self, :cached_pages => cached })
end
# finally save them all # finally save them all
::Page.without_callback(:save, :after, :update_template_descendants) do ::Page.without_callback(:save, :after, :update_template_descendants) do
@ -92,6 +90,20 @@ module Extensions
end end
end end
def _update_direct_template_descendants(template_descendants, cached)
direct_descendants = template_descendants.select do |page|
((self.template_dependencies || []) + [self._id]) == (page.template_dependencies || [])
end
direct_descendants.each do |page|
page.send(:_parse_and_serialize_template, { :cached_parent => self, :cached_pages => cached })
template_descendants.delete(page) # no need to loop over it next time
page.send(:_update_direct_template_descendants, template_descendants, cached) # move down
end
end
end end
end end