PHP 8.0 issue: deprecated create_function() throws Fatal error
-
Just a friendly reminder to the developers of this cool plugin that you guys still have a pending pull request on GitHub which has been ‘sleeping’ over there since May 2020; this hasn’t made into the WordPress plugin repository yet, even though it seems to have been ‘fixed’ on GitHub.
It’s now January 2021, PHP 8.0, and the dangerous, vulnerability-prone
create_function()
has been removed — not merely deprecated — and now throws a Fatal Error.For those having found this issue via Google, and assuming it hasn’t been fixed yet, do the following: Open the plugin’s
addons/auto-pagination/auto-pagination-functions.php
file, go to line 29 and replace
add_filter('generate_pagination', create_function('$output,$page,$pages,$args', 'return $output;'), 10, 4);
with
add_filter( 'generate_pagination', function( $output, $page, $pages, $args ) { return $output; }, 10, 4 );
It’s that simple to get WPP: PLP working again.While you’re at it, to make it future-proof, on the same file, go to line 64 (66 if you have upgraded to the version on GitHub), and replace
if (!$post->post_content || $post->post_content == '')
with
if (empty($post) || empty($post->post_content))
PHP 8.0 will throw a warning with the above line when$post
is null, complaining with:Attempt to read property "post_content" on null
. There are a few alternative possible ‘fixes’, but I’m a fan ofempty()
since it does a lot of stuff ‘in the background’…
- The topic ‘PHP 8.0 issue: deprecated create_function() throws Fatal error’ is closed to new replies.