kartolo / direct_mail

it's an newsletter sending extension for the TYPO3 CMS
40 stars 116 forks source link

PHP Warning: Undefined property: DirectMailTeam\DirectMail\DmQueryGenerator::$settings in Classes/DmQueryGenerator.php line 109 #529

Open format-gmbh opened 1 month ago

format-gmbh commented 1 month ago

When I call up the ‘Recipient list’ module, I receive the following error message: Core: Exception handler (WEB): Uncaught TYPO3 Exception: #1476107295: PHP Warning: Undefined property: DirectMailTeam\DirectMail\DmQueryGenerator::$settings in /var/www/html/vendor/directmailteam/direct-mail/Classes/DmQueryGenerator.php line 109

If I fix this error provisionally, I receive the following error message: TYPO3\CMS\Lowlevel\Controller\DatabaseIntegrityController::makeSelectorTable(): Argument #2 ($request) must be of type Psr\Http\Message\ServerRequestInterface, string given, called in /var/www/html/vendor/directmailteam/direct-mail/Classes/DmQueryGenerator.php on line 113

TYPO3 12.4.22 PHP 8.3 Branch "12.x-dev" composer mode

Patta commented 3 weeks ago

I can confirm this issue.

Environment: TYPO3 12.4.22 PHP 8.2 direct_mail 12.x 500a858 composer mode

warning-log:

Tue, 05 Nov 2024 10:19:15 +0100 [WARNING] request="16b32fb740372" component="TYPO3.CMS.Core.Error.ErrorHandler": Core: Error handler (BE): PHP Warning: Undefined property: DirectMailTeam\DirectMail\DmQueryGenerator::$settings in /var/www/vhosts/REMOVED/typo3_12.4_prod/vendor/directmailteam/direct-mail/Classes/DmQueryGenerator.php line 109 
Tue, 05 Nov 2024 10:19:15 +0100 [CRITICAL] request="16b32fb740372" component="TYPO3.CMS.Core.Error.ProductionExceptionHandler": Core: Exception handler (WEB: BE): TypeError, code #0, file /var/www/vhosts/REMOVED/typo3_12.4_prod/vendor/typo3/cms-lowlevel/Classes/Controller/DatabaseIntegrityController.php, line 2242: TYPO3\CMS\Lowlevel\Controller\DatabaseIntegrityController::init(): Argument #4 ($settings) must be of type array, null given, called in /var/www/vhosts/REMOVED/typo3_12.4_prod/vendor/directmailteam/direct-mail/Classes/DmQueryGenerator.php on line 109 - {"mode":"WEB","application_mode":"BE","exception_class":"TypeError","exception_code":0,"file":"/var/www/vhosts/REMOVED/typo3_12.4_prod/vendor/typo3/cms-lowlevel/Classes/Controller/DatabaseIntegrityController.php","line":2242,"message":"TYPO3\\CMS\\Lowlevel\\Controller\\DatabaseIntegrityController::init(): Argument #4 ($settings) must be of type array, null given, called in /var/www/vhosts/REMOVED/typo3_12.4_prod/vendor/directmailteam/direct-mail/Classes/DmQueryGenerator.php on line 109","request_url":"https://REMOVED/typo3/module/directmail/recipientlist?token=--AnonymizedToken--&id=7439","exception":null}
christophlehmann commented 2 weeks ago

When i remember correctly, this error occurs only when your recipient lists are build from special queries. This is a nice feature, but due xclassing, etc. it tends to break again and again. As an alternative, custom recipient lists are very easy to implement with the cool new events:

    public function __invoke(RecipientListCompileMailGroupEvent $event): void
    {
        $group = $event->getMailGroup();
        $idLists = $event->getIdLists();
        if ($group['type'] === self::MAILGROUP_TYPE) {
            $recipientUids = $this->guildRecipientsRepository->getRecipientUids($group['guild']);
            $idLists[GuildRecipientsRepository::TABLE] = array_merge($idLists[GuildRecipientsRepository::TABLE] ?? [], $recipientUids);
            $event->setIdLists($idLists);
        }
    }

    public function compileMailGroup(DmailCompileMailGroupEvent $event): void
    {
        $groupIds = $event->getMailGroup();
        foreach ($groupIds as $groupId) {
            $group = BackendUtility::getRecord(
                'sys_dmail_group',
                $groupId,
                '*',
                'AND type=' . self::MAILGROUP_TYPE
            );
            if ($group) {
                $recipientUids = $this->guildRecipientsRepository->getRecipientUids($group['guild']);
                $idLists[GuildRecipientsRepository::TABLE] = array_merge(
                    $idLists[GuildRecipientsRepository::TABLE] ?? [],
                    $recipientUids
                );
                $event->setIdLists($idLists);
            }
        }
    }