[openstreetmap-website] Fix bug allowing created elements to reference deleted ones. (#992)

Tom Hughes notifications at github.com
Sat Jun 13 06:42:43 UTC 2015


> @@ -248,6 +248,9 @@ def preconditions_ok?(good_members = [])
>        model = Kernel.const_get(m[0].capitalize)
>        # get the element with that ID
>        element = model.find_by(:id => m[1])
> +      # if found, lock the element to ensure it can't be deleted until
> +      # after the current transaction commits.
> +      element.lock!("for share") unless element.nil?

Should you fold that into the previous line as `model.lock("for share").find_by(:id => m[1])`? Otherwise there is a race between finding it and locking it where a deletion could still happen?

---
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/992/files#r32368451
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20150612/d5405c0c/attachment.html>


More information about the rails-dev mailing list