Skip to content

Commit 31e55bb

Browse files
committed
ACP2E-4309: Update for MDVA-19640 for 2.4.8 compatibility
1 parent 8a28bd6 commit 31e55bb

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Analytics\Setup\Patch\Data;
10+
11+
use Magento\Framework\App\ResourceConnection;
12+
use Magento\Framework\Setup\Patch\DataPatchInterface;
13+
14+
/**
15+
* Migrate legacy cron config paths for analytics jobs from the "default" group to the "analytics" group.
16+
*/
17+
class MoveCronConfigToAnalyticsGroup implements DataPatchInterface
18+
{
19+
/**
20+
* @var ResourceConnection
21+
*/
22+
private $resourceConnection;
23+
24+
/**
25+
* @param ResourceConnection $resourceConnection
26+
*/
27+
public function __construct(
28+
ResourceConnection $resourceConnection
29+
) {
30+
$this->resourceConnection = $resourceConnection;
31+
}
32+
33+
/**
34+
* @inheritDoc
35+
*/
36+
public function apply()
37+
{
38+
$connection = $this->resourceConnection->getConnection();
39+
$table = $this->resourceConnection->getTableName('core_config_data');
40+
41+
// Find all analytics cron rows under the "default" cron group
42+
$select = $connection->select()
43+
->from($table, ['config_id', 'scope', 'scope_id', 'path', 'value'])
44+
->where('path LIKE ?', 'crontab/default/jobs/analytics_%');
45+
$rows = (array)$connection->fetchAll($select);
46+
47+
foreach ($rows as $row) {
48+
$oldPath = (string)$row['path'];
49+
$newPath = (string)preg_replace('#^crontab/default/#', 'crontab/analytics/', $oldPath);
50+
51+
$connection->update(
52+
$table,
53+
['path' => $newPath],
54+
['config_id = ?' => (int)$row['config_id']]
55+
);
56+
}
57+
58+
return $this;
59+
}
60+
61+
/**
62+
* @inheritDoc
63+
*/
64+
public static function getDependencies()
65+
{
66+
return [];
67+
}
68+
69+
/**
70+
* @inheritDoc
71+
*/
72+
public function getAliases()
73+
{
74+
return [];
75+
}
76+
}

0 commit comments

Comments
 (0)