PHP 7.4 vs PHP 8.0

I have the latest V2 nightly installed on my test site, using PHP 7.4. As soon as I switch the PHP version to 8.0, I receive the following error:

There has been a critical error on this website. Please check your site admin email inbox for instructions.

Learn more about troubleshooting ClassicPress.

I then switched it back to 7.4, and it all went well. IS there a problem with using PHP 8.0 with CP V2 nightly?

MORE on using PHP 8.0. When I used the “recovery mode”, based on the email received (apparently) from ClassicPress, it told me there was something wrong with the THEME. Can anyone tell me what to do based on the following message…

Error Details

An error of type E_ERROR was caused in line 7 of the file /home/www/ Error message: Uncaught Error: Call to undefined function create_function() in /home/www/
Stack trace:
#0 /home/www/ require_once()
#1 /home/www/ include(‘/home/www/cptes…’)
#2 /home/www/ require_once(‘/home/www/cptes…’)
#3 /home/www/ require_once(‘/home/www/cptes…’)
#4 /home/www/ require_once(‘/home/www/cptes…’)
#5 /home/www/ require_once(‘/home/www/cptes…’)
#6 {main}

Yeah, its indeed caused by the theme, which uses ancient PHP code, which has been deprecated in PHP 7.2 and removed in PHP 8. The PHP documentation (to which I linked) tells one to replace it with an anonymous function at best, or use eval (with potential security issues, as its parsing and executing code without further tests).

The reason why its still “ok” with PHP 7.4 is because that its “only” deprecated, but still existing. Probably throws a DEPRECATED error if you enable WP_DEBUG or general PHP debug, too.

So its not CP v2 which is at fault, but the theme code. As I dont know the theme, and also your level of programming experience, I can only speculate on how to fix this issue.

If you dont want to replace the theme, and have got a bit of programming experience (advanced level), then you might be able to replace the code with an anonymous function. My guess is, that its using a very very old method to initialize widgets.

Edit: A bit of searching on the interwebs suggests that its the tagDiv Newspaper theme, and not available in the WP Theme Repository, so I sadly cannot tell you more.

cu, w0lf.

1 Like

Thanks! You’re right, it’s the tagDiv Newspaper theme - and any other NEWSPAPER-like theme, so far. I believe tagDiv has an updated version of this theme, and I’ve reached out to them to find out if the new version will work with PHP 8.0. Again, thanks for taking the time to look at my issue.

There are a lot of plugins and themes that haven’t been made compatible yet with PHP8.x, unfortunately.

Those copy/paste kitchen sink themes on theme forest are keeping php4 code alive.

1 Like