pimcore / admin-ui-classic-bundle

Other
11 stars 99 forks source link

[Bug]: Fix deletion of context.objectId #738

Closed alexmarkop closed 19 hours ago

alexmarkop commented 3 weeks ago

This code change fixes the mistaken deletion of "objectId" from "this.context".

Without this, the following example is broken: https://pimcore.com/docs/platform/Pimcore/Extending_Pimcore/Event_API_and_Event_Manager/#asset-upload-path

github-actions[bot] commented 3 weeks ago

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

sonarcloud[bot] commented 3 weeks ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

alexmarkop commented 3 weeks ago

I have read the CLA Document and I hereby sign the CLA

mcop1 commented 1 week ago

Hello @alexmarkop ,

could you please provide steps to reproduce the problem?

What I did was:

Seems to be working for me. Did I miss something?

alexmarkop commented 1 week ago

Hi @mcop1 , The issue was introduced by this commit: https://github.com/pimcore/admin-ui-classic-bundle/commit/80498edfb3474802da12834c871e0898bfccca81 file public/js/pimcore/object/tags/abstractRelations.js line 212:

delete context.objectId;

Take a look at the code snippet in the following example (Asset Upload Path): https://pimcore.com/docs/platform/Pimcore/Extending_Pimcore/Event_API_and_Event_Manager/#asset-upload-path

\Pimcore::getEventDispatcher()->addListener(AssetEvents::RESOLVE_UPLOAD_TARGET,
            function(\Pimcore\Event\Model\Asset\ResolveUploadTargetEvent $event) {
                $context = $event->getContext();
                if ($context["containerType"] == "object") {
                    $objectId = $context["objectId"];
                    $newsObject = News::getById($objectId);
                    if ($newsObject) {
                        $fieldname = $context["fieldname"];
                        $targetPath = $newsObject->getPath() . $newsObject->getKey() . "/" . $fieldname;
                        $parent = \Pimcore\Model\Asset\Service::createFolderByPath($targetPath);
                        if ($parent) {
                            $event->setParentId($parent->getId());
                        }
                    }

                }
        });

now $context["objectId"] is not available anymore causing the example above to throw an error.

mcop1 commented 19 hours ago

Thanks again for the fix!

Cherry picked to 1.6 with 77e046ab209a7273e1988b57e0902560837000af