BrandOriented / PimcoreCiHubConnector

This bundle adds full integration between Pimcore and CI-HUB Connector. Now you can add, delete and download all assets, lock and unlock, get all versions for specified asset and much more.
https://brandoriented.io/
Other
5 stars 6 forks source link

Argument #1 ($id) must be of type string|int, null given, #44

Closed betterapp closed 7 months ago

betterapp commented 7 months ago

Pimcore version(s) affected

11

Description

Sometimes when we use BlackBit DataDirector it create objects without parentId (it is a known but not unidentified bug)

When we try to modify the Settings of this class image

we got error 500

URL: /admin/rest/config/save
Method: post
Message: Pimcore\Model\DataObject\AbstractObject::getById(): Argument #1 ($id) must be of type string|int, null given, called in /var/www/pimcore.dev/www/vendor/bo-hub/ci-hub-api-bundle/src/Elasticsearch/EndpointAndIndexesConfigurator.php on line 106
Trace: 
in /var/www/pimcore.dev/www/vendor/pimcore/pimcore/models/DataObject/AbstractObject.php:202
#0 /var/www/pimcore.dev/www/vendor/bo-hub/ci-hub-api-bundle/src/Elasticsearch/EndpointAndIndexesConfigurator.php(106): Pimcore\Model\DataObject\AbstractObject::getById()
#1 /var/www/pimcore.dev/www/vendor/bo-hub/ci-hub-api-bundle/src/Elasticsearch/EndpointAndIndexesConfigurator.php(60): CIHub\Bundle\SimpleRESTAdapterBundle\Elasticsearch\EndpointAndIndexesConfigurator->initIndex()
#2 /var/www/pimcore.dev/www/vendor/bo-hub/ci-hub-api-bundle/src/EventListener/ConfigModificationListener.php(55): CIHub\Bundle\SimpleRESTAdapterBundle\Elasticsearch\EndpointAndIndexesConfigurator->createOrUpdate()
#3 /var/www/pimcore.dev/www/vendor/symfony/event-dispatcher/Debug/WrappedListener.php(116): CIHub\Bundle\SimpleRESTAdapterBundle\EventListener\ConfigModificationListener->onPostSave()

How to reproduce

use null value for parentId

Possible Solution

change: $this->enqueueParentFolders(DataObject::getById($object['parentId']), DataObject\Folder::class, 'object', $name);

to:

if (!is_null($object['parentId'])) {
   $this->enqueueParentFolders(DataObject::getById($object['parentId']), DataObject\Folder::class, 'object', $name);
}

Additional Context

No response

github-actions[bot] commented 7 months ago

Thank you for reporting this problem!

This is an open source project, and we rely on the community to help us diagnose and fix issues, as it is not possible to investigate and fix every issue reported to us via GitHub.

If possible, please create a pull request that fixes the problem you describe, along with appropriate tests. All pull requests will be promptly reviewed by the BrandOriented team.

Thank you very much!

labudzinski commented 7 months ago

@betterapp Hey there! I just wanted to let you know that I don't have line 106 in EndpointAndIndexesConfigurator in the repository. It might be the case that the problem exists and the indicated line doesn't exist, so it'd be great if you could check again or type a bundle version.

betterapp commented 7 months ago

does not exist in current version