From e8462055512dd8a10551502a2329afed02d0daeb Mon Sep 17 00:00:00 2001 From: Christoph Leitgeb <98694299+leitge@users.noreply.github.com> Date: Sat, 24 Feb 2024 16:21:50 +0100 Subject: [PATCH] Update src/GraphQL/DataObjectType/PimcoreObjectType.php --- src/GraphQL/DataObjectType/PimcoreObjectType.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/GraphQL/DataObjectType/PimcoreObjectType.php b/src/GraphQL/DataObjectType/PimcoreObjectType.php index 182eedfb..851afefb 100644 --- a/src/GraphQL/DataObjectType/PimcoreObjectType.php +++ b/src/GraphQL/DataObjectType/PimcoreObjectType.php @@ -88,9 +88,10 @@ public function build($context = []) 'resolve' => function ($value = null, $args = [], $context = [], ResolveInfo $resolveInfo = null) { $object = \Pimcore\Model\DataObject::getById($value['id']); if ($object) { - $version = $object->getVersions()[count($object->getVersions()) - 1]->getId(); - if ($version) { - return $version; + foreach (array_reverse($object->getVersions()) as $version) { + if ($object->getModificationDate() === $version->getDate()) { + return $version->getId(); + } } }