silvermine/silverstripe-views — pull request #4 by crgwbr (2014-10-21 15:58:36+00:00)
Title: Prevent ViewHost from corrupting SiteTree_Live table

When ViewHost::updateCMSFields() runs the current_stage is normally Live. When
the SiteTree object it was associated with was unpublished, obviously no row
would exist for it in SiteTree_Live. However, because write() saw the Live mode
was active, it would only work with the SiteTree_Live table. This would cause it
to insert an incomplete an invalid row into SiteTree_Live, instead of just
updating the row in SiteTree like we wanted.

This fixes the issue by making sure that if the record isn't published, we
switch to Stage mode before running write.