fb-instant-articles
fb-instant-articles copied to clipboard
Too few arguments provided to get_the_excerpt hook
Steps required to reproduce the problem
- Create and activate a small plugin that hooks into the
get_the_excerpthook, using code like this:
add_filter( 'get_the_excerpt', function( $excerpt, $post ) {
return $excerpt;
} );
- Activate and set up the FBIA plugin
- On the site, visit the
/instant-articlesURL to look at the IA feed - Observe this error message:
There has been a critical error on your website
- Check the PHP log and you should find a PHP Fatal Error like this:
PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function, 1 passed in /wordpress/core/5.5.1/wp-includes/class-wp-hook.php on line 287 and exactly 2 expected in /srv/htdocs/wp-content/plugins/custom-plugin.php...
Expected Result
The IA feed should display at /instant-articles without error.
Actual Result
The error mentioned above is shown and there is a PHP Fatal Error triggered.
This is because the get_the_excerpt filter, as per the documentation, requires two parameters to be passed to it. Only one is, however, which means that any plugin correctly hooking into that filter will result in a Fatal Error.
Version Info
- Plugin version: 4.2.1
- WordPress version: 5.5.1
- PHP version: 7.3.23