|
10 | 10 | namespace Gedmo\Loggable;
|
11 | 11 |
|
12 | 12 | use Doctrine\Common\EventArgs;
|
| 13 | +use Doctrine\ORM\Mapping\ClassMetadata; |
13 | 14 | use Doctrine\Persistence\Event\LoadClassMetadataEventArgs;
|
14 | 15 | use Doctrine\Persistence\ObjectManager;
|
15 | 16 | use Gedmo\Exception\InvalidArgumentException;
|
| 17 | +use Gedmo\Loggable\Entity\LogEntry; |
16 | 18 | use Gedmo\Loggable\Mapping\Event\LoggableAdapter;
|
17 | 19 | use Gedmo\Mapping\MappedEventSubscriber;
|
18 | 20 | use Gedmo\Tool\Wrapper\AbstractWrapper;
|
@@ -150,7 +152,7 @@ public function postPersist(EventArgs $args)
|
150 | 152 | $logEntry = $this->pendingLogEntryInserts[$oid];
|
151 | 153 | $logEntryMeta = $om->getClassMetadata(get_class($logEntry));
|
152 | 154 |
|
153 |
| - $id = $wrapped->getIdentifier(); |
| 155 | + $id = $wrapped->getIdentifier(false, true); |
154 | 156 | $logEntryMeta->getReflectionProperty('objectId')->setValue($logEntry, $id);
|
155 | 157 | $uow->scheduleExtraUpdate($logEntry, [
|
156 | 158 | 'objectId' => [null, $id],
|
@@ -320,10 +322,10 @@ protected function createLogEntry($action, $object, LoggableAdapter $ea)
|
320 | 322 |
|
321 | 323 | // check for the availability of the primary key
|
322 | 324 | $uow = $om->getUnitOfWork();
|
323 |
| - if (LogEntryInterface::ACTION_CREATE === $action && $ea->isPostInsertGenerator($meta)) { |
| 325 | + if (LogEntryInterface::ACTION_CREATE === $action && ($ea->isPostInsertGenerator($meta) || ($meta instanceof ClassMetadata && $meta->isIdentifierComposite))) { |
324 | 326 | $this->pendingLogEntryInserts[spl_object_id($object)] = $logEntry;
|
325 | 327 | } else {
|
326 |
| - $logEntry->setObjectId($wrapped->getIdentifier()); |
| 328 | + $logEntry->setObjectId($wrapped->getIdentifier(false, true)); |
327 | 329 | }
|
328 | 330 | $newValues = [];
|
329 | 331 | if (LogEntryInterface::ACTION_REMOVE !== $action && isset($config['versioned'])) {
|
|
0 commit comments