Problem/Motivation

When an anonymous user navigates to a poll, clicks the "View results" button and then goes back to the poll form by clicking the "View poll" button, a serialization error occurs on PHP 7.4.

Notice: unserialize(): Error at offset 4261 of 12438 bytes in Drupal\Component\Serialization\PhpSerialize::decode() (line 21 of core/lib/Drupal/Component/Serialization/PhpSerialize.php).

The error only occurs as an anonymous user, because when logged in as an authenticated user, the "View poll" button doesn't appear, which is a different bug: #3178172: Button "View poll" is missing for authenticated users. But even when changing code to make the button appear for authenticated users, there is still no serialization error for them.

I noticed this error while I was working on #2909811: Anonymous users - Multiple voting from one IP and there it prevents the tests from passing on PHP 7.4.

Steps to reproduce

  1. Set the PHP version to 7.4.
  2. Create a poll that allows anonymous votes and allows to view the results before voting.
  3. As an anonymous user, go to the poll. The poll form gets displayed.
  4. Click the "View results" button. The poll vote results get displayed.
  5. Click the "View poll" button.

The poll form gets displayed again, but there also gets a serialization error logged. When the user has javascript disabled and the site is configured to display errors, the error is also displayed on the page.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

A patch with tests to demonstrate the issue, will follow.

Comments

MegaChriz created an issue. See original summary.

megachriz’s picture

Status: Active » Needs work
StatusFileSize
new2.23 KB
megachriz’s picture

Issue summary: View changes

Created #3178172: Button "View poll" is missing for authenticated users for the other bug that I found while working on the tests for this issue.

megachriz’s picture

Adding #2909811: Anonymous users - Multiple voting from one IP as a related issue, this issue blocks that issue because their tests don't pass on PHP 7.4 now.

megachriz’s picture

jordiserra’s picture

I'm still having this issue. Did you finally solved it MegaChriz?

megachriz’s picture

No, I no longer looked into it. The site that I installed the poll module on also hasn't been updated to PHP 7.4 yet.

jordiserra’s picture

Ok, thanks for your reply. I hope it will be fixed in the future!

ivnish’s picture

MegaChriz can you fix the tests?

berdir’s picture

Status: Needs work » Needs review
StatusFileSize
new1.35 KB

Not 100% sure I rerolled correctly, but I can't reproduce this locally on D9 with 7.4, maybe it only happens with D8? Lets ask testbot. If it's D8 only I'm going to just commit the tests, I've already switched test configuration to D9 only.

berdir’s picture

Ok, confirmed to be a D8-only problem.

berdir’s picture

Status: Needs review » Fixed

Committed the extra test coverage.

  • Berdir committed 79a3304 on 8.x-1.x authored by MegaChriz
    Issue #3178162 by MegaChriz, Berdir: Serialization error when switching...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.