فهرست منبع

[Loggable] Checks if there were any changes in versioned fields, otherwise don't log LogEntry with empty data.

Antoni Orfin 12 سال پیش
والد
کامیت
d92c1d15bd
1فایلهای تغییر یافته به همراه14 افزوده شده و 11 حذف شده
  1. 14 11
      lib/Gedmo/Loggable/LoggableListener.php

+ 14 - 11
lib/Gedmo/Loggable/LoggableListener.php

@@ -260,20 +260,23 @@ class LoggableListener extends MappedEventSubscriber
                 }
                 }
                 $logEntry->setData($newValues);
                 $logEntry->setData($newValues);
             }
             }
-            $version = 1;
-            if ($action !== self::ACTION_CREATE) {
-                $version = $ea->getNewVersion($logEntryMeta, $object);
-                if (empty($version)) {
-                    // was versioned later
-                    $version = 1;
+            
+            if(0 !== count($newValues)) {
+                $version = 1;
+                if ($action !== self::ACTION_CREATE) {
+                    $version = $ea->getNewVersion($logEntryMeta, $object);
+                    if (empty($version)) {
+                        // was versioned later
+                        $version = 1;
+                    }
                 }
                 }
-            }
-            $logEntry->setVersion($version);
+                $logEntry->setVersion($version);
 
 
-            $this->prePersistLogEntry($logEntry, $object);
+                $this->prePersistLogEntry($logEntry, $object);
 
 
-            $om->persist($logEntry);
-            $uow->computeChangeSet($logEntryMeta, $logEntry);
+                $om->persist($logEntry);
+                $uow->computeChangeSet($logEntryMeta, $logEntry);
+            }
         }
         }
     }
     }
 }
 }