ProcessManager icon indicating copy to clipboard operation
ProcessManager copied to clipboard

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

Open APochmann opened this issue 1 year ago • 2 comments

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

APochmann avatar Feb 26 '24 18:02 APochmann

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

antonio-masotti avatar Mar 16 '24 12:03 antonio-masotti

We had the same issue, but after applying the fix for metadata column, it was kept. After some research, for our case we detected some rows in bundle_process_manager_monitoring_item with status = 'initializing' which was the guilty of raising the message.

[2025-04-10T12:24:00.484798+00:00] app.NOTICE: ERROR: Elements\Bundle\ProcessManagerBundle\Model\MonitoringItem::setMessage(): Argument #1 ($message) must be of type string, null given, called in /var/www/html/vendor/pimcore/pimcore/lib/Model/AbstractModel.php on line 189 [2025-04-10T12:24:00.484877+00:00] app.ERROR: Elements\Bundle\ProcessManagerBundle\Model\MonitoringItem::setMessage(): Argument #1 ($message) must be of type string, null given, called in /var/www/html/vendor/pimcore/pimcore/lib/Model/AbstractModel.php on line 189

In MonitoringItem.php line 398:

Elements\Bundle\ProcessManagerBundle\Model\MonitoringItem::setMessage(): Ar gument #1 ($message) must be of type string, null given, called in /var/www /html/vendor/pimcore/pimcore/lib/Model/AbstractModel.php on line 189

process-manager:maintenance [--monitoring-item-id MONITORING-ITEM-ID]

So, we took the decision to remove some rows from the table bundle_process_manager_monitoring_item

DELETE FROM bundle_process_manager_monitoring_item WHERE status IN ('failed','initializing')

carlosgonzalezpdn avatar Apr 11 '25 05:04 carlosgonzalezpdn