[wp-trac] [WordPress Trac] #57522: PHP 8.2 > Backend fatal error: PHP Fatal error: Uncaught TypeError
WordPress Trac
noreply at wordpress.org
Sun Jan 22 02:29:24 UTC 2023
#57522: PHP 8.2 > Backend fatal error: PHP Fatal error: Uncaught TypeError
---------------------------------+------------------------------
Reporter: mackaaij | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 6.1.1
Severity: normal | Resolution:
Keywords: needs-testing php82 | Focuses:
---------------------------------+------------------------------
Comment (by SergeyBiryukov):
Replying to [comment:2 mackaaij]:
> I filed the report over here as the stack trace seems to list only
WordPress files (no plugin / theme).
Right, but it points to [source:tags/6.1.1/src/wp-includes/class-wp-
hook.php?marks=308#L275 WP_Hook::apply_filters()], which only executes
code from plugins or themes and does not itself contain the problematic
`session_start()` call.
> Any idea how to get to the .php causing the fatal error?
Code like this, when run in a plugin or a mu-plugin, should display
information about the current filter, priority, and the attached callbacks
after the fatal error happens:
{{{
register_shutdown_function( 'handle_php_fatal_error' );
function handle_php_fatal_error() {
global $wp_filter;
$last_error = error_get_last();
if ( $last_error['type'] === E_ERROR ) {
$wp_hook = $wp_filter[ current_filter() ];
$priority = $wp_hook->current_priority();
echo '<pre>';
echo 'Current filter: ' . current_filter() . "\n";
echo 'Current priority: ' . $priority . "\n";
echo 'Callbacks: ';
print_r( array_keys( $wp_hook->callbacks[ $priority ] ) );
echo '</pre>';
}
}
}}}
For example, this is what I get after simulating a fatal error with
`add_filter( 'the_content', 'session_start' )`:
{{{
Current filter: the_content
Current priority: 10
Callbacks: Array
(
[0] => wptexturize
[1] => wpautop
[2] => shortcode_unautop
[3] => prepend_attachment
[4] => wp_filter_content_tags
[5] => wp_replace_insecure_home_url
[6] => session_start
)
}}}
The displayed function names could then be used to search for the PHP file
causing the error.
Alternatively, just searching for `session_start` in the installed plugins
and active theme would be a good first step.
> It's not easy for me to disable plugins and switch the theme on this
specific site, so I hope you have another suggestion.
I would suggest creating a copy of the site for testing and
troubleshooting, that way it should be easier to track down the issue than
working with a live site directly.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/57522#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list