[php-src] Issue #19349: throwing exception from variable creates clone of object without copying properties
| From: | gregzawadzki | Date: | Fri, 01 Aug 2025 18:48:16 +0000 |
| Subject: | [php-src] Issue #19349: throwing exception from variable creates clone of object without copying properties | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-250550@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/19349
Author: gregzawadzki
### Description
The following code:
```php
<?php
$exception = new Exception('2312');
try {
// throw new Exception('2312'); // this line works OK.
throw new $exception;
} catch (Exception $e){
var_dump(spl_object_id($e));
echo 'Message: '.$e->getMessage();
}
```
Resulted in this output:
```
int(2)
Message:
```
But I expected this output instead:
```
int(1)
Message: 2312
```
PHP Seems to clone $exception and not copy message (tested only message)
### PHP Version
```plain
5.6 to 8.4.10
```
### Operating System
All