Fix segment selections

PHP8.1 fixed a PDO bug (https://bugs.php.net/bug.php?id=80808) that was causing
that integer columns were fetched as strings.
[MAILPOET-3980]
This commit is contained in:
Rostislav Wolny
2021-12-02 16:36:26 +01:00
committed by Veljko V
parent fc4a11a6a7
commit 2b4f8de61a

View File

@@ -114,6 +114,8 @@ class SegmentsSimpleListRepository {
// Fetch subscribers counts for dynamic segments and correct data types // Fetch subscribers counts for dynamic segments and correct data types
foreach ($segments as $key => $segment) { foreach ($segments as $key => $segment) {
// BC compatibility fix. PHP8.1+ returns integer but JS apps expect string
$segments[$key]['id'] = (string)$segment['id'];
if ($segment['type'] === SegmentEntity::TYPE_DYNAMIC) { if ($segment['type'] === SegmentEntity::TYPE_DYNAMIC) {
$statisticsKey = $subscriberGlobalStatus ?: 'all'; $statisticsKey = $subscriberGlobalStatus ?: 'all';
$segments[$key]['subscribers'] = (int)$this->subscribersCountsController->getSegmentStatisticsCountById($segment['id'])[$statisticsKey]; $segments[$key]['subscribers'] = (int)$this->subscribersCountsController->getSegmentStatisticsCountById($segment['id'])[$statisticsKey];