From 8d5a3b5a8bac3306b9cf46bb4b579ff1c006c548 Mon Sep 17 00:00:00 2001 From: Geoff Beaumont Date: Thu, 6 Oct 2016 11:49:23 +0100 Subject: [PATCH] Fix new version when touched by related model #11 Fixes: When ModelA is be updated and touches ModelB the VersionableTrait also creates a version for ModelB, even if it is not modified. Fix by mk-conn, just packaged up into a pull request by geoffbeaumont. --- src/Mpociot/Versionable/VersionableTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mpociot/Versionable/VersionableTrait.php b/src/Mpociot/Versionable/VersionableTrait.php index c9f1acc..0d61004 100644 --- a/src/Mpociot/Versionable/VersionableTrait.php +++ b/src/Mpociot/Versionable/VersionableTrait.php @@ -148,7 +148,7 @@ protected function versionablePostSave() */ if ( ( $this->versioningEnabled === true && $this->updating && $this->isValidForVersioning() ) || - ( $this->versioningEnabled === true && !$this->updating ) + ( $this->versioningEnabled === true && !$this->updating && count($this->versionableDirtyData)) ) { // Save a new version $version = new Version();