X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/e731dd71a77ad4ad1e9db22535e89444bb98e5d9..a65cb8428867d92d76bbf051bbd4614966636cf5:/app/models/changeset.rb diff --git a/app/models/changeset.rb b/app/models/changeset.rb index 47f03c795..9db213e77 100644 --- a/app/models/changeset.rb +++ b/app/models/changeset.rb @@ -25,7 +25,7 @@ # changesets_user_id_fkey (user_id => users.id) # -class Changeset < ActiveRecord::Base +class Changeset < ApplicationRecord require "xml/libxml" belongs_to :user, :counter_cache => true @@ -83,11 +83,13 @@ class Changeset < ActiveRecord::Base def self.from_xml(xml, create = false) p = XML::Parser.string(xml, :options => XML::Parser::Options::NOERROR) doc = p.parse + pt = doc.find_first("//osm/changeset") - doc.find("//osm/changeset").each do |pt| - return Changeset.from_xml_node(pt, create) + if pt + Changeset.from_xml_node(pt, create) + else + raise OSM::APIBadXMLError.new("changeset", xml, "XML doesn't contain an osm/changeset element.") end - raise OSM::APIBadXMLError.new("changeset", xml, "XML doesn't contain an osm/changeset element.") rescue LibXML::XML::Error, ArgumentError => e raise OSM::APIBadXMLError.new("changeset", xml, e.message) end