Closed
Description
Description
The following code:
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
ini_set('error_reporting', E_ALL);
echo "============" . "<br />";
echo "Testing in " . phpversion() . "<br />";
echo "============";
echo "<br /><br />";
/**
* Create 5 items
*/
$array = new SplFixedArray(5);
/**
* Get size
* EXPECTED: 5
*/
$size = $array->getSize();
echo "Original size before serializing. Expected result is 5." . "<br />";
echo "Actual result: $size";
echo "<br /><br />";
/**
* Serialize SPLFixedArray object
*/
$serialized = serialize($array);
/**
* Unserialize SPLFixedArray object
*/
$array = unserialize($serialized);
/**
* Get size
* EXPECTED: 5
*/
$size = $array->getSize();
echo "Original size after serializing. Expected is still 5." . "<br />";
echo "Actual result is $size";
echo "<br /><br />";
/**
* Resize SPLFixedArray to 6 items
*/
echo "Resizing array to 6 items" . "<br />";
$array->setSize(6);
/**
* Get size after resize
* EXPECTED: 6
*/
$size = $array->getSize();
echo "Updated size after resize. " . "<em>" . "Expected is 6." . "</em>" . "<br />";
echo "<strong>" . "Actual result is $size" . "</strong>";
echo "<br />";
Resulted in this output:
============
Testing in 8.2.15
============
Original size before serializing. Expected result is 5.
Actual result: 5
Original size after serializing. Expected is still 5.
Actual result is 5
Resizing array to 6 items
Updated size after resize. Expected is 6.
Actual result is 5
But I expected this output instead:
============
Testing in 8.2.15
============
Original size before serializing. Expected result is 5.
Actual result: 5
Original size after serializing. Expected is still 5.
Actual result is 5
Resizing array to 6 items
Updated size after resize. Expected is 6.
Actual result is 6
Additional notes:
- This is only reproducible with PHP 8.2.15.
- It works well with PHP 8.1/8.0/7.4.
I've checked the docs on changes with setSize()
method with PHP 8.2. It does not mention that it cannot be used after unserializing. So I open this ticket as it could be a bug. Thank you!
PHP Version
PHP 8.2.15
Operating System
Ubuntu 22.04 LTS