[php-src] Issue #13871: auto_prepend_file register_shutdown_function TypeError fatal error because function not hoisted
| From: | kkmuffme | Date: | Tue, 02 Apr 2024 21:07:00 +0000 |
| Subject: | [php-src] Issue #13871: auto_prepend_file register_shutdown_function TypeError fatal error because function not hoisted | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-246700@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/13871
Author: kkmuffme
### Description
When using
register_shutdown_function in an auto_prepend_file the
functions aren't hoisted and must be declared before it, otherwise resulting in a fatal error.
In a normal PHP file it works perfectly fine.
Tested with PHP-CLI sapi.
The following code:
```php
<?php
register_shutdown_function('hello');
function hello() {
echo "done";
}
```
Resulted in this output for a normal file:
```
done
```
Resulted in this output for an auto_prepend_file:
```
Uncaught TypeError: register_shutdown_function(): Argument #1 ($callback) must be a valid callback,
function "hello" not found or invalid function name in /path.php:3
```
But I expected this output instead:
```
done
```
### PHP Version
PHP 8.3
### Operating System
CentOS