Notice: unserialize(): Error at offset 0 of 4542 bytes in Drupal\user\UserData->get()

Created on 8 March 2024, 8 months ago
Updated 8 April 2024, 7 months ago

Problem/Motivation

After doing a little broader search in the error logs we did notice the following issue:

"Notice: unserialize(): Error at offset 0 of 4542 bytes in Drupal\\\\user\\\\UserData->get() (line 47 of /app/html/core/modules/user/src/UserData.php) #0 /app/html/core/includes/bootstrap.inc(164): _drupal_error_handler_real(8, 'unserialize(): ...', '/app/html/core/...', 47) #1 [internal function]: _drupal_error_handler(8, 'unserialize(): ...', '/app/html/core/...', 47) #2 /app/html/core/modules/user/src/UserData.php(47): unserialize('\\\\x00\\\\x00\\\\x00\\\\x00\\\\x00\\\\x00\\\\x00\\\\x00\\\\x00\\\\x00\\\\x00\\\\x00\\\\x00\\\\x00\\\\x00...') #3 /app/html/modules/contrib/social_pwa/src/WebPushManager.php(63): Drupal\\\\user\\\\UserData->get('social_pwa', '30', 'subscription') #4 /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)) #5 /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)) #6 [internal function]: activity_send_push_activity_insert(Object(Drupal\\\\activity_creator\\\\Entity\\\\Activity)) #7 /app/html/core/lib/Drupal/Core/Extension/ModuleHandler.php(409): call_user_func_array(Object(Closure), Array) #8 /app/html/core/lib/Drupal/Core/Extension/ModuleHandler.php(388): Drupal\\\\Core\\\\Extension\\\\ModuleHandler->Drupal\\\\Core\\\\Extension\\\\{closure}(Object(Closure), 'activity_send_p...') #9 /app/html/core/lib/Drupal/Core/Extension/ModuleHandler.php(416): Drupal\\\\Core\\\\Extension\\\\ModuleHandler->invokeAllWith('activity_insert', Object(Closure)) #10 /app/html/core/lib/Drupal/Core/Entity/EntityStorageBase.php(215): Drupal\\\\Core\\\\Extension\\\\ModuleHandler->invokeAll('activity_insert', Array) #11 /app/html/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(900):

Proposed resolution

Has been discovered that some user data include incorrect records - a serialized string that includes a list of "null":

So, to prevent it, needs to have additional validation of data that can be added, for example for each set() case, we could expect that the data of `subscription` should have only array type

  if (is_array($user_subscriptions) && isset($subscription_data['key'])) {
      \Drupal::service('user.data')->set('social_pwa', $uid, 'subscription', $user_subscriptions);
    }
πŸ› 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