Fix for #5755 -- making zaml serialization robust over projected objects
The core problem arose when the fix for #5048 in 31118fe85aca4 introduced a
hook to replace objects dynamically durring serialization so that they could be
projected / rewritten to a different form for backward compatability. The
serialization code assumed that all objects being serialized would remain valid
until the serialization was complete, but nothing retained a copy of the
temporary objects created in the hook.
To resolve this, the serialization layer now maintains a ref to each such object
and clears them (to allow GC) after serialization is complete.
Paired-with: Jesse Wolfe <jesse@puppetlabs.com>
Paired-with: Paul Berry <paul@puppetlabs.com>