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
- Set the PHP version to 7.4.
- Create a poll that allows anonymous votes and allows to view the results before voting.
- As an anonymous user, go to the poll. The poll form gets displayed.
- Click the "View results" button. The poll vote results get displayed.
- 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.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | poll-serialization-error-3178162-10.patch | 1.35 KB | berdir |
| #5 | poll-serialization-error-3178162-4.patch | 3.37 KB | megachriz |
| #2 | poll-serialization-error-3178162-2.patch | 2.23 KB | megachriz |
Comments
Comment #2
megachrizComment #3
megachrizCreated #3178172: Button "View poll" is missing for authenticated users for the other bug that I found while working on the tests for this issue.
Comment #4
megachrizAdding #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.
Comment #5
megachrizI include the fix from #3178178: PHP notice "Trying to access array offset on value of type bool template_preprocess_poll_meter()" when viewing poll results before voting on PHP 7.4 here, because else I cannot demonstrate the issue reported here.
Comment #6
jordiserra commentedI'm still having this issue. Did you finally solved it MegaChriz?
Comment #7
megachrizNo, 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.
Comment #8
jordiserra commentedOk, thanks for your reply. I hope it will be fixed in the future!
Comment #9
ivnishMegaChriz can you fix the tests?
Comment #10
berdirNot 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.
Comment #11
berdirOk, confirmed to be a D8-only problem.
Comment #12
berdirCommitted the extra test coverage.