Make sure that user data is always array to prevent fatal error

Created on 4 March 2024, 10 months ago
Updated 19 March 2024, 9 months ago

When user send bulk messages for example to all group members in a group, the message does not deliver. Furthermore, we do not receive any form of error notification or feedback regarding the delivery failure.

After an investigation has been discovered that during this activity it generates the following error:

TypeError: array_map(): Argument #2 ($array) must be of type array, bool given in /app/html/modules/contrib/social_pwa/src/WebPushManager.php on line 71 #0 /app/html/modules/contrib/social_pwa/src/WebPushManager.php(71): array_map(Object(Closure), false)
#1 /app/html/modules/contrib/social_pwa/modules/activity_send_push/src/Plugin/ActivitySend/PushActivitySend.php(98): Drupal\social_pwa\WebPushManager->getSubscriptionsForUser(Object(Drupal\social_user\Entity\User))
#2 /app/html/modules/contrib/social_pwa/modules/activity_send_push/activity_send_push.module(24): Drupal\activity_send_push\Plugin\ActivitySend\PushActivitySend->process(Object(Drupal\activity_creator\Entity\Activity))
#3 [internal function]: activity_send_push_activity_insert(Object(Drupal\activity_creator\Entity\Activity))
#4 /app/html/core/lib/Drupal/Core/Extension/ModuleHandler.php(409): call_user_func_array(Object(Closure), Array)
#5 /app/html/core/lib/Drupal/Core/Extension/ModuleHandler.php(388): Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object(Closure), 'activity_send_p...')
#6 /app/html/core/lib/Drupal/Core/Extension/ModuleHandler.php(416): Drupal\Core\Extension\ModuleHandler->invokeAllWith('activity_insert', Object(Closure))

Proposed resolution

Add a check to make sure that user data is always as an array because get() has a mixed type of return value: array, null, bool.

πŸ› Bug report
Status

Fixed

Version

2.1

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine SV

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024