PHP Warning if unserialize fails

Created on 23 June 2022, over 2 years ago
Updated 3 September 2024, 4 months ago

Problem/Motivation

The PHP unserialize function issues an E_NOTICE error if it fails, as well as returning false. This is not strictly a problem and the next line of code checks to ensure that there's a valid result before trying to actually decrypt the value.

However, the result is the display (and subsequent logging) of a PHP notice about the reason the unserialize failed. This is undesirable, and while notices can be disabled from display in production sites it will populate the log with unnecessary notices.

Steps to reproduce

Create a form that has some sort of data stored that can't be unserialized. In my case I think it's a computed field that is responsible for the error, but I'm having a hard time pinning down exactly which field it is and why.

Proposed resolution

Change the call to unserialize to use '@unserialize' to suppress any errors throw if it fails.

Please note that the attached patch will only work properly after applying the D9 readiness patch here: https://www.drupal.org/project/webform_encrypt/issues/3142997#comment-13... πŸ“Œ Webform Encrypt D9 readiness Fixed .

πŸ› Bug report
Status

Needs work

Version

2.0

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada teknocat

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024