The error of email notification for a new task

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dmytro_s
    Junior Member
    • Mar 2023
    • 4

    The error of email notification for a new task

    Hello. After tonight's upgrade to version 7.5.0, we got an error when the user creates a new task.

    Steps to reproduce:
    1. Email notifications of assigned tasks are enabled.
    2. User creates a new task with assigned other users. If it's important, we use the field "Assigned Users", not the default single "Assigned User".
    3. User gets "error 500" in a web browser. The task form is still open, but the task has been created.
    4. The assigned users haven't received any notifications about this task (nor email, or in-app).

    If we disable email notifications about the task assignment, in-app notifications work well and there are no any errors.
    Also, email notifications about case assignments and mentions work well.

    The error in logs:
    Code:
    [2023-06-13 09:04:46] ERROR: Slim Application Error Type: TypeError Code: 0 Message: in_array(): Argument #2 ($haystack) must be of type array, null given File: /var/www/espocrm/application/Espo/Tools/EmailNotification/HookProcessor.php Line: 96 Trace: #0 /var/www/espocrm/application/Espo/Tools/EmailNotification/HookProcessor.php(96): in_array() #1 /var/www/espocrm/application/Espo/Tools/EmailNotification/HookProcessor.php(71): Espo\Tools\EmailNotification\HookProcessor->processMultiple() #2 /var/www/espocrm/application/Espo/Hooks/Common/AssignmentEmailNotification.php(57): Espo\Tools\EmailNotification\HookProcessor->afterSave() #3 /var/www/espocrm/application/Espo/Core/Hook/GeneralInvoker.php(186): Espo\Hooks\Common\AssignmentEmailNotification->afterSave() #4 /var/www/espocrm/application/Espo/Core/HookManager.php(119): Espo\Core\Hook\GeneralInvoker->invoke() #5 /var/www/espocrm/application/Espo/Core/Repositories/Database.php(318): Espo\Core\HookManager->process() #6 /var/www/espocrm/application/Espo/ORM/Repository/RDBRepository.php(163): Espo\Core\Repositories\Database->afterSave() #7 /var/www/espocrm/application/Espo/Core/Repositories/Database.php(136): Espo\ORM\Repository\RDBRepository->save() #8 /var/www/espocrm/application/Espo/ORM/EntityManager.php(247): Espo\Core\Repositories\Database->save() #9 /var/www/espocrm/application/Espo/Core/Record/Service.php(678): Espo\ORM\EntityManager->saveEntity() #10 /var/www/espocrm/application/Espo/Core/Controllers/RecordBase.php(181): Espo\Core\Record\Service->create() #11 /var/www/espocrm/application/Espo/Core/Api/ControllerActionProcessor.php(87): Espo\Core\Controllers\RecordBase->postActionCreate() #12 /var/www/espocrm/application/Espo/Core/Api/ControllerActionHandler.php(69): Espo\Core\Api\ControllerActionProcessor->process() #13 /var/www/espocrm/vendor/slim/slim/Slim/MiddlewareDispatcher.php(65): Espo\Core\Api\ControllerActionHandler->handle() #14 /var/www/espocrm/application/Espo/Core/Api/RouteProcessor.php(222): Slim\MiddlewareDispatcher->handle() #15 /var/www/espocrm/application/Espo/Core/Api/RouteProcessor.php(149): Espo\Core\Api\RouteProcessor->processControllerAction() #16 /var/www/espocrm/application/Espo/Core/Api/RouteProcessor.php(127): Espo\Core\Api\RouteProcessor->processAfterAuth() #17 /var/www/espocrm/application/Espo/Core/Api/RouteProcessor.php(79): Espo\Core\Api\RouteProcessor->processInternal() #18 /var/www/espocrm/application/Espo/Core/Api/Starter.php(109): Espo\Core\Api\RouteProcessor->process() #19 /var/www/espocrm/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php(38): Espo\Core\Api\Starter->Espo\Core\Api\{closure}() #20 /var/www/espocrm/vendor/slim/slim/Slim/Routing/Route.php(358): Slim\Handlers\Strategies\RequestResponse->__invoke() #21 /var/www/espocrm/vendor/slim/slim/Slim/MiddlewareDispatcher.php(65): Slim\Routing\Route->handle() #22 /var/www/espocrm/vendor/slim/slim/Slim/MiddlewareDispatcher.php(65): Slim\MiddlewareDispatcher->handle() #23 /var/www/espocrm/vendor/slim/slim/Slim/Routing/Route.php(315): Slim\MiddlewareDispatcher->handle() #24 /var/www/espocrm/vendor/slim/slim/Slim/Routing/RouteRunner.php(68): Slim\Routing\Route->run() #25 /var/www/espocrm/vendor/slim/slim/Slim/Middleware/RoutingMiddleware.php(45): Slim\Routing\RouteRunner->handle() #26 /var/www/espocrm/vendor/slim/slim/Slim/MiddlewareDispatcher.php(121): Slim\Middleware\RoutingMiddleware->process() #27 /var/www/espocrm/vendor/slim/slim/Slim/Middleware/ErrorMiddleware.php(76): Psr\Http\Server\RequestHandlerInterface@anonymous->handle() #28 /var/www/espocrm/vendor/slim/slim/Slim/MiddlewareDispatcher.php(121): Slim\Middleware\ErrorMiddleware->process() #29 /var/www/espocrm/vendor/slim/slim/Slim/MiddlewareDispatcher.php(65): Psr\Http\Server\RequestHandlerInterface@anonymous->handle() #30 /var/www/espocrm/vendor/slim/slim/Slim/App.php(199): Slim\MiddlewareDispatcher->handle() #31 /var/www/espocrm/vendor/slim/slim/Slim/App.php(183): Slim\App->handle() #32 /var/www/espocrm/application/Espo/Core/Api/Starter.php(76): Slim\App->run() #33 /var/www/espocrm/application/Espo/Core/ApplicationRunners/Api.php(45): Espo\Core\Api\Starter->start() #34 /var/www/espocrm/application/Espo/Core/Application/RunnerRunner.php(84): Espo\Core\ApplicationRunners\Api->run() #35 /var/www/espocrm/application/Espo/Core/Application.php(78): Espo\Core\Application\RunnerRunner->run() #36 /var/www/espocrm/public/api/v1/index.php(35): Espo\Core\Application->run() #37 {main} Tips: To display error details in HTTP response set "displayErrorDetails" to true in the ErrorHandler constructor.
  • yuri
    Member
    • Mar 2014
    • 8440

    #2
    Hi,

    As a quick fix, try changing in application/Espo/Tools/EmailNotification/HookProcessor.php (line 96)

    Code:
    $fetchedAssignedUserIdList = $entity->getFetched('assignedUsersIds');
    to

    Code:
    $fetchedAssignedUserIdList = $entity->getFetched('assignedUsersIds') ?? [];
    ​
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    Working...