valantic-at / ProcessManager

Manage processes in Pimcore
Other
45 stars 31 forks source link

Error "setMetaData(): Argument #1 ($metaData) must be of type array, null given" after migration to pimcore 11 #203

Open APochmann opened 9 months ago

APochmann commented 9 months ago

Problem reason

With Pimcore 10 and ProcessManager 4.x there might be monitoring objects in the database without metaData which results in an empty string. In my case this was caused by an command executed via cron job where the code segment

        $monitoringId = $input->getOption('monitoring-item-id');
        $options = ['autoCreate' => true];
        $monitoringItem = $this->initProcessManager($monitoringId, $options);

created such an monitoringItem if no monitoring-item-id was passed.

Problem effect

However, when having such objects in database you will find the error

php.CRITICAL: Uncaught Error: Elements\Bundle\ProcessManagerBundle\Model\MonitoringItem::setMetaData(): Argument #1 ($metaData) must be of type array, null given, called in .../vendor/pimcore/pimcore/lib/Model/AbstractModel.php on line 186

in your log files as since ProcessManager 5.x this parameter is mandatory array. ProcessManager will not load the Process Log

Possible solution

You easily can overcome this issue by running

UPDATE bundle_process_manager_monitoring_item SET `metaData` = "[]" WHERE `metaData` = ''

SQL command on the database. This could also be put in a migration script or if it's not worth the effort (seems not to happen frequently on migrations as there was no issue raised up to now) you can close this issue as it's anyhow documented here how to solve the problem

antonio-masotti commented 8 months ago

We're having the same problem after the upgrade to Pimcore 11:

{"message":"Uncaught Error: Elements\Bundle\ProcessManagerBundle\Model\MonitoringItem::setMetaData(): Argument #1 ($metaData) must be of type array, null given, called in /var/www/html/vendor/pimcore/pimcore/lib/Model/AbstractModel.php on line 186","context":{"exception":{"class":"TypeError","message":"Elements\Bundle\ProcessManagerBundle\Model\MonitoringItem::setMetaData(): Argument #1 ($metaData) must be of type array, null given, called in /var/www/html/vendor/pimcore/pimcore/lib/Model/AbstractModel.php on line 186","code":0,"file":"/var/www/html/vendor/elements/process-manager-bundle/src/Model/MonitoringItem.php:209"}},"level":500,"level_name":"CRITICAL","channel":"php","datetime":"2024-03-16T11:23:38.674477+01:00","extra":{"http.url":"","http.method":null,"http.useragent":null,"http.referer":null,"app.env":"int","trace_id":"0","span_id":"0"}} In MonitoringItem.php line 209: Elements\Bundle\ProcessManagerBundle\Model\MonitoringItem::setMetaData(): A rgument #1 ($metaData) must be of type array, null given, called in /var/ww w/html/vendor/pimcore/pimcore/lib/Model/AbstractModel.php on line 186