silverstripe/silverstripe-framework — pull request #3675 by micmania1 (2014-11-24 22:55:39+00:00)
Title: FIX DataDifferencer was trying to compare fields, even if the fields did...

...n't exist causing an error.

Scenario: (save & publish after each step).
* Create a 'Page' in the CMS.
* Change the type to 'MyCustomPage' which has a has_one which 'Page' doesn't.
* Set the has_one.
* Change the page type back to 'Page'

Now when you compare the 'Page' version to the 'MyCustomPage' version it will try to compare $obj->MyHasOne() on both classes which causes an error on 'Page' where it doesn't exist.

This fix addresses this issue by checking that the method exists before calling it.

It also fixes an issue where $obj->Title() is blindly called - this assumes that the has_one relation has a 'Title' method which also causes an error where this isn't the case. This is fixed by checking for a field or method on the DataObject then calling $obj->Title if it exists. This maps to Title(), getTitle() or db['Title'].