This project is archived and is in readonly mode.
Fix to_xml serialization in some rare cases.
-
Jonathan del Strother
Good idea, but -
a) Why not just always clone the options?
b) It would be much more likely that this gets accepted if you supply in patch form (http://www.tpope.net/rails-git-b...) rather than something that has to be manually cut & pasted, with no way of easily comparing the differences
c) Tests would be nice
-
Adam Sindelar
Ok, so here's a git patch, hope it makes sense. I also ran the full rails test suite and there were no regressions on my machine (rails 2.0.2 with ruby 1.8.6). There is one assertion failure in mysql test, but that happens regardless of whether or not the patch is applied.
As for the reason to not always clone the options hash - the hash contains the XML builder instance and some other data, and all in all, it seemed to me that cloning it under most circumstances would be an unnecessary slowdown. The code can be easily modified to simply always clone the hash, but that'll mean a performance deterioration even in those cases where cloning is not needed. That's just my guess though.
Hope this is better.
-
Adam Sindelar
Hey,
please don't take this the wrong way, I'm not trying to bug anyone... But what are the things I should do in order to have this patch accepted into the rails codebase (or to have it reviewed by someone)? I recognize that there's a lot of other tickets waiting for resolution, but I would hate for this to be forgotten - so what should I do next?
If the delay is normal, fair enough; I'm just trying to make sure there's not something I'm missing.
Thanks.
-
Jonathan del Strother
The delay is pretty normal. You generally need 3 people to vote +1 on your patch before it gets accepted. Best way of doing that is by hopping on the #rails-contrib irc channel and coercing people into taking a look.
Personally, I don't think the overhead of 'clone' is worth the extra code to avoid it. Bear in mind that when you clone a hash, you're cloning the references to the objects in it, rather than the objects themselves. That is, {:xml => Builder::XmlBase.new}.clone will produce two hashes, but both point to the same instance of the xml builder.
-
Pratik
- State changed from new to incomplete
- Title changed from [patch] Fix to_xml serialization in some rare cases. to Fix to_xml serialization in some rare cases.
Hi Adam,
I agree with all suggestions ( only a. and c. are relevant now ) made by Jon.
You need to add tests to rails' existing test suite, which would fail without your patch. That's the general drill for getting the patch accepted.
Marking the ticket as "incomplete" till tests are added.
Thanks.
-
Adam Sindelar
Hi again,
Firstly, sorry that I took this long to get back to this ticket, I needed to work on a different project for the past week or so.
Secondly, I've made the change to always clone the options hash, instead of checking if it's required.
The thing I'm uncertain about are the tests, though, so if I might have a few inquisitive questions (I looked for this information on rails website, but I couldn't find any guidelines):
Am I allowed (encouraged even?) to create a new model class to go with my test, or should I utilize one that already exists?
I'm going to try and fit this test inside the serialization_test.rb, but it's probably going to require changes to that file that go beyond merely adding another assertion (would definitely need another object with data).
Thanks.
-
Pratik
Adam, we don't have a strict set of rules for tests. If you think it's worth creating a new file for tests, go for it. If you think they're a better fit for some of the existing test file, squeeze it in that.
Thanks.
-
Pratik
- Assigned user set to Pratik
-
Rohit Arondekar
- State changed from incomplete to stale
- Tag set to bug, core_ext, patch
- Importance changed from to
Marking ticket as stale. If this is still an issue please leave a comment with suggested changes, creating a patch with tests, rebasing an existing patch or just confirming the issue on a latest release or master/branches.
