owen-it / laravel-auditing

Record the change log from models in Laravel
https://laravel-auditing.com
MIT License
3.05k stars 390 forks source link

fix: datetime values are shifted by the timezone modifier #775

Closed erikn69 closed 1 year ago

erikn69 commented 1 year ago

Closes #709 UPDATE: Test added, rebased

erikn69 commented 1 year ago

I think I found another different bug, on PHP <=8.0 gettype($audit->auditable_id) is always a string, I don't know if it's a sqlite problem, I did make a PR showing this behaivor https://github.com/owen-it/laravel-auditing/pull/776

1) OwenIt\Auditing\Tests\AuditableTest::itFailsToTransitionWhenTheAuditAuditableIdDoesNotMatchTheModelId
Failed asserting that exception message 
    'Expected Auditable id (integer)2, got (string)1 instead' 
contains 
    'Expected Auditable id (integer)2, got (integer)1 instead'.

So, i add a fix to test this

$audit = $model->audits->last();
$audit->auditable_id = $model->id;

UPDATE: It was a memory sqlite issue on PHP <=8, i rebased this PR, https://github.com/owen-it/laravel-auditing/issues/709#issuecomment-1463975547

MortenDHansen commented 1 year ago

Right! - This patches the problem. I'm in favour