Entity->modified() dosn't take care of non modified fields #423

merged 2 commits into from Apr 12, 2012


None yet

2 participants


Sorry for duplicate request, did not find a way to change previous to /dev/ :(

I'm using some time expensive validators, which should only be executed if the underlying field really was changed.
So I tried to use modified(), but it always says that all fields of my entity are changed. Not surprising since the docblock says it always return true for all fields. But in combination with sync() it shouldn't do that.

So changed the behavior of Entity->modified() to take care about real changes.


public function testSyncModified() {
    $doc = new Document();
    $doc->id = 4;
    $doc->name = 'Four';
    $doc->content = 'Lorem ipsum four';

    $expected = array(
        'id' => true,
        'name' => true,
        'content' => true,

    $this->assertEqual($expected, $doc->modified());

    $this->assertEqual(array_fill_keys(array_keys($expected), false), $doc->modified());

    $doc->id = 5;
    $doc->content = null;
    $doc->new = null;
    $expected = array(
        'id' => true,
        'name' => false,
        'content' => true,
        'new' => true,

    $this->assertEqual($expected, $doc->modified());
@nateabele nateabele merged commit b9dcd06 into UnionOfRAD:dev Apr 12, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment