platform
platform copied to clipboard
Commmand oro:cron:integration:cleanup should exclude each connector per channel
Summary
When working with integration, the oro:cron:integration:cleanup delete every old status just by retrieving the latest connector base on the date column of the table oro_integration_channel_status.
The issue is that with multiple channel using the same connector, it will only keep the latest status of the connector where I would expect it to keep the last status of each connector per channel (a connector for a specific channel could fail where the same connector for another could work perfectly)
Here is the fix I propose:
diff --git a/vendor/oro/platform/src/Oro/Bundle/IntegrationBundle/Command/CleanupCommand.php b/vendor/oro/platform/src/Oro/Bundle/IntegrationBundle/Command/CleanupCommand.php
--- a/vendor/oro/platform/src/Oro/Bundle/IntegrationBundle/Command/CleanupCommand.php
+++ b/vendor/oro/platform/src/Oro/Bundle/IntegrationBundle/Command/CleanupCommand.php (date 1660749776329)
@@ -215,15 +215,16 @@
oro_integration_channel_status AS a
INNER JOIN
(
- SELECT connector, MAX(date) AS minDate
+ SELECT channel_id, connector, MAX(date) AS minDate
FROM oro_integration_channel_status AS b
WHERE b.code = '1'
- GROUP BY connector
+ GROUP BY channel_id, connector
) b ON a.connector = b.connector AND
- a.date = b.minDate
+ a.date = b.minDate AND
+ a.channel_id = b.channel_id
WHERE a.code = '1'
GROUP BY
- a.connector
+ a.channel_id, a.connector
SQL;
$selectQuery = sprintf(
$selectQuery,
Details about your environment
- OroPlatform version: 4.2.9
- PHP version: 7.4.29
- Database PostgreSql 12