Skip to content

Instantly share code, notes, and snippets.

@svandragt
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save svandragt/42863fdc18e7062955c0 to your computer and use it in GitHub Desktop.
Save svandragt/42863fdc18e7062955c0 to your computer and use it in GitHub Desktop.
BUG isChanged is not comparing to the databasefields
<?php
/**
*/
class TempTask extends BuildTask {
protected $title = 'TempTask';
protected $description = '';
public function run($request) {
# correct behaviour: title hasn't changed as it is set to the original value
$MyDataObject = Page::get_by_link('/');
$title = $MyDataObject->Title;
$MyDataObject->Title = $title;
Debug::show($MyDataObject->getChangedFields(false, 2));
# BUG isChanged is not comparing to the databasefields but to the last value of the property
# expected behaviour: not changed. actual behaviour: changed
$title = $MyDataObject->Title;
$MyDataObject->Title = null;
$MyDataObject->Title = $title;
Debug::show($MyDataObject->getChangedFields(false, 2));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment