php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #75268 SplFixedArray doesn't implement __set_state().
Submitted: 2017-09-27 15:07 UTC Modified: 2023-01-15 16:49 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: brad at hallnet dot co dot uk Assigned:
Status: Verified Package: SPL related
PHP Version: 7.0.23 OS: Ubuntu
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: brad at hallnet dot co dot uk
New email:
PHP Version: OS:

 

 [2017-09-27 15:07 UTC] brad at hallnet dot co dot uk
Description:
------------
The SplFixedArray implementation doesn't have a __set_state() function, and as such var_export() creates code which does not function. 

Test script:
---------------
var_export(SplFixedArray::fromArray([1,2,3]));



Expected result:
----------------
The SplFixedArray can be exported and the code functions correctly.

Actual result:
--------------
Syntax error in exported code.

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-02-13 20:43 UTC] carusogabriel34 at gmail dot com
Couldn't reproduce https://3v4l.org/QrqN0
 [2018-02-13 21:07 UTC] nikic@php.net
-Type: Bug +Type: Feature/Change Request
 [2018-02-13 21:07 UTC] nikic@php.net
@carusogabriel34: The code generation works, but running the code doesn't, as SplFixedArray does not implement __set_state(): https://3v4l.org/50QD3
 [2020-10-01 04:10 UTC] levim@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: levim
 [2020-10-01 04:54 UTC] levim@php.net
I'm trying to implement this for Hacktoberfest.
 [2020-10-01 16:49 UTC] levim@php.net
Here's an example that shows existing serialization/unserialization is not quite correct:
https://3v4l.org/IMnI5.

My plan to fix this is to have string keys become properties and for numeric keys to become array values. This same design should work for __set_state.
 [2020-10-02 03:03 UTC] levim@php.net
The following pull request has been associated:

Patch Name: Add SplFixedArray::__set_state
On GitHub:  https://github.com/php/php-src/pull/6261
Patch:      https://github.com/php/php-src/pull/6261.patch
 [2023-01-15 16:49 UTC] levim@php.net
-Status: Assigned +Status: Open -Assigned To: levim +Assigned To:
 [2023-01-15 16:49 UTC] levim@php.net
I wasn't able to complete it in the time I allotted. I hope dynamic properties will probably be forbidden on this class at some point in the future, which will help alleviate if not totally fix the issue.
 [2023-01-15 16:49 UTC] levim@php.net
-Status: Open +Status: Verified
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 17:01:58 2024 UTC