Skip to content

Conversation

Sajid-al-islam
Copy link
Contributor

@Sajid-al-islam Sajid-al-islam commented Oct 19, 2025

Fixes #57357

Fixes serialization errors when using PHP 8.4 property hooks in Eloquent models. When models with property hooks a serialized, Laravel throws: serialize(): "property_name" returned as member variable from __sleep() but does not exist.

Property hooks create virtual properties without actual storage. The current __sleep() uses get_object_vars() which includes these virtual properties, causing serialization to fail.

Solution: Changed get_object_vars($this) to get_mangled_object_vars($this) in Model::__sleep(). This only returns properties with actual storage, excluding virtual property hooks.

Tests: Added comprehensive coverage in EloquentModelPropertyHooksTest.php for getter hooks, setter hooks, multiple hooks, mixed properties, and queue scenarios.

@Sajid-al-islam Sajid-al-islam marked this pull request as draft October 19, 2025 12:10
@Sajid-al-islam Sajid-al-islam marked this pull request as ready for review October 19, 2025 12:39
@crynobone crynobone marked this pull request as draft October 19, 2025 13:15
@Sajid-al-islam
Copy link
Contributor Author

Hello, @crynobone Is there any dependency?
as far as I checked, the failed test case is not related to any code changes

here is the error

Need to get 1481 kB of archives.
After this operation, 7558 kB of additional disk space will be used.
Get:1 file:/etc/apt/apt-mirrors.txt Mirrorlist [144 B]
Get:2 http://azure.archive.ubuntu.com/ubuntu noble/universe amd64 libjemalloc2 amd64 5.3.0-2build1 [256 kB]
Get:3 http://azure.archive.ubuntu.com/ubuntu noble/universe amd64 liblzf1 amd64 3.6-4 [7624 B]
Ign:4 http://azure.archive.ubuntu.com/ubuntu noble-updates/universe amd64 redis-tools amd64 5:7.0.15-1ubuntu0.24.04.1
Ign:5 http://azure.archive.ubuntu.com/ubuntu noble-updates/universe amd64 redis-server amd64 5:7.0.15-1ubuntu0.24.04.1
Ign:4 https://archive.ubuntu.com/ubuntu noble-updates/universe amd64 redis-tools amd64 5:7.0.15-1ubuntu0.24.04.1
Ign:5 https://archive.ubuntu.com/ubuntu noble-updates/universe amd64 redis-server amd64 5:7.0.15-1ubuntu0.24.04.1
Ign:4 https://security.ubuntu.com/ubuntu noble-updates/universe amd64 redis-tools amd64 5:7.0.15-1ubuntu0.24.04.1
Err:4 mirror+file:/etc/apt/apt-mirrors.txt noble-updates/universe amd64 redis-tools amd64 5:7.0.15-1ubuntu0.24.04.1
 404  Not Found [IP: 40.81.13.82 80]
Ign:5 https://security.ubuntu.com/ubuntu noble-updates/universe amd64 redis-server amd64 5:7.0.15-1ubuntu0.24.04.1
Err:5 mirror+file:/etc/apt/apt-mirrors.txt noble-updates/universe amd64 redis-server amd64 5:7.0.15-1ubuntu0.24.04.1
 404  Not Found [IP: 40.81.13.82 80]
E: Failed to fetch mirror+file:/etc/apt/apt-mirrors.txt/pool/universe/r/redis/redis-tools_7.0.15-1ubuntu0.24.04.1_amd64.deb  404  Not Found [IP: 40.81.13.82 80]
Fetched 264 kB in 1s (185 kB/s)
E: Failed to fetch mirror+file:/etc/apt/apt-mirrors.txt/pool/universe/r/redis/redis-server_7.0.15-1ubuntu0.24.04.1_amd64.deb  404  Not Found [IP: 40.81.13.82 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
Error: Process completed with exit code 100.

@Sajid-al-islam Sajid-al-islam marked this pull request as ready for review October 19, 2025 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error serialised with php8. 4 Hooks

2 participants