silverstripe/sapphire — pull request #308 by mateusz (2012-04-12 05:10:36+00:00)
Title: Re: has_one component cache can't be cleared.

Ref: http://open.silverstripe.org/ticket/6175

Can you review this please and let me know if this is helpful?

I've attempted to clean up the multitude of the caches on the DataObject, and make them at least more consistent and more visible - although I didn't try to merge them or refactor the code to eliminate them.

Have also explicitly deprecated setComponent - it manipulates "componentCache" which to my eye is no longer used anywhere, and can cause some hidden surprises for people out there. Fixed related CsvBulkLoader problem which was still using setComponent.

Removed $cache_buildSQL_query, which was not used.

Fixed DataObject::reset to clean all global caches, and DataObject::flushCache to flush the component cache. Both now are doing what it says on the box.

The problem reported in ticket 6175 can now be fixed by doing $this->flushCache(); after the setting the has_one and writing.

Comments welcome :)