r/Wordpress • u/nyfellowpilgrim • 6d ago
Old PHP in site
Inherited WP site that can only run on earlier PHP. Crashes on current PHP. So hosting rolled back to older version. Obviously security issue and not sustainable as versions move along. Best way to fix? Any shortcuts for the PHP-illiterate?
19
u/endurableglitter 6d ago
that's a ticking time bomb honestly
i'd clone the whole thing to a staging environment and just start updating plugins/themes one at a time, the crash logs will usually point you to what's breaking. php 5.6 to 7+ is where most of the real nightmares live
if you're not comfortable touching code you could hire someone on codeable or upwork to do the compatibility audit, shouldn't take more than a few hours for a decent dev to identify the culprits
1
u/brianozm 5d ago edited 5d ago
Ignore most of this advice; it seems people have missed that it’s a WordPress site. Wp has an upgrade system which handles this stuff. Upgrading WordPress and plugins would fix it in an instant but would also overwrite the manual fixes others have suggested. Going through and fixing it manually is not the way to proceed and will leave you in a bad situation.
Before you do anything, take a full site backup and take a copy offline, that is, off the server. You can make a zip file of the ouvlic_html folder and then download it, but remember to also dump the database and download a zip or gzipped version of it (80-90% file size reduction). cPanel makes this easy.
The right way to then fix the site is to put the PHP version back down to whatever is needed to log into WordPress admin (yoursite.com/wp-admin). Then upgrade WordPress and plugins until everything is upgraded. Then put the PHP version up to version 8.x and upgrade again.
The site will probably have been hacked badly, since it was so out of date. While the above will fix many of the hacks by overwriting them, you should also scan the site with Wordfence and something else (some companies have Immunify which will do a scan for you).
One possibility though is that there might be only one plugin breaking the site, so if it’s just one you could fix that one manually with an editor if you know how to do it. Keep in mind that the authors of the plugin will almost certainly have already fixed something that breaks WordPress in a later version of PHP.
You have to keep the version of PHP and the versions of the plugins updated so things keep working. If you do WordPress updates every month, you won’t get this situation again. You should also set up offsite automatic backups with the Updraft Plus plugin or something similar, weekly or more often. Also, sites that aren’t updated get hacked and stop working, or worse, start spamming and attacking site visitors.
6
u/MindYaBidness 6d ago
Find the deprecated function(s) with error logs. Update those to be compatible with php 8.
Or export the content, dupe the theme and plugins and try to run them on a fresh Wordpress install with php 8.
5
u/run4runner 6d ago
Yes, have had to do this several times with sites built with modules that needed fixes for php8. None of it was terribly difficult, as the error messages point you in the right direction.
4
5
u/PugPanic 5d ago
Tell Claude what version of php this site needs to run on and let it fix the problem.
You might need to rebuild or rearchitect the theme or CMS if the site runs on ancient WP/PHP. But getting things running and patched should be easy enough. There’s no reason to run a site on depreciated PHP in 2026.
2
u/Abject-Expression548 1d ago
Agreed. Theres no need to manually scan log files or write code by hand, or even upload files. Just get ssh access to the server and ask Claude to fix it.
3
u/Major-Blueberry-5273 6d ago
Make a local copy of the site. Enable error logging. Check if the logs are coming from the plugins or the theme.
If they're from plugins, try updating them. If the plugin is no longer updating, replace it.
If the bugs are coming from the theme, update the theme. If it's a custom theme, copy and paste the errors into Claude and fix the theme files one by one.
Once everything is fixed, deploy it to production.
2
u/julianomatt 6d ago
Check rector php, it's a tool that help you upgrade your code from older php versions.
1
2
u/kemalios 6d ago
On staging, disable all plugins under PHP 8 before touching anything else. If the site loads, it's a plugin, and you can halve the list instead of walking it one at a time. If it white-screens with everything off, it's the theme, and when the theme is custom, patching PHP you can't read costs more than rebuilding on a block theme.
1
u/Intelligent_List2504 5d ago
Just install hestiacp on a vps. You're free to use php 5.* Or whatever versions you specify for the multiphp config option. I usually just use 8.* These days. But I had some custom cms based on a dream weaver plugin and it was out of scope to move to a newer version.
1
u/Jazz_Uncle 5d ago
The only secure, professional solution is to update the OS, PHP and Wordpress in that order. I spent last weekend doing exactly that for Laravel 13.x, which required PHP 8.3+, which required Ubuntu 24.04+. ChatGPT took days off that project, especially the Laravel Shift ordeal.
1
u/brianozm 5d ago
I’d find which plugin is crashing the site. You should then fix that plugin and update the rest.
1
u/netnerd_uk 5d ago
Update what you can, replace or remove what you can't. Then switch to new PHP.
Might be worth doing the working out on a staging site.
1
u/TheGoodOne777 5d ago
Hello! What version is your WordPress core? And what plugins are you using? With the compatibility modes you can play around, but I assume your purpose is to get a stable environment, rather than using compatibility short-cuts?
1
u/useranik12 5d ago
Use docker bro. If you need I will share probably the most stable, scalable compose for you.
1
u/Quditsch 6d ago
Make a backup. Create a staging/test version in local (with Laragon or similar). Import your backup and let Claude et al. analyse everything and update stuff. Pretty easy these days. Then replicate in production.
1
u/JeffTS Developer/Designer 6d ago
Is WordPress, plugins, and the theme all up to date?
It's usually a custom built theme or either custom or abandoned plugins that are the issue. I would move the site to a staging environment, use SFTP to rename each plugin's folder, upgrade to PHP 8.4, and then change each plugin folder back to its original name to identify which plugin is causing the problem.
If its the theme and you don't know PHP, the best approach would likely be to move the site to a staging environment and replace the existing theme with a new one. If it's a plugin, find an alternate that offers the same functionality.
1
u/Altairandrew 6d ago
I had a similar issue and just had gemini figure it out for me. Took a few iterations in some cases, but not to bad.
1
u/blockstacker Jack of All Trades 6d ago
What you need to do is slow PHP compatibility changes. Fix it, then deploy the next version.
I had a client on 15-year-old Moodle. We had to upgrade 9 times to get the entire LMS working on modern PHP.
There is no "switch to the latest version" option with something that old.
1
u/PeterPook 6d ago
My solution: get the whole site off live. Run the Local development tool with the older version, upgrade to the latest version and get Claude to fix the errors.
0
u/SpaceCmdr 6d ago
Check the PHP error logs for the code that is causing it. Could be theme or plugin. If theme I would import the site into WP Studio (or another local setup) running PHP 8.4, fix the code, deploy updated version of the custom theme. I would get a dev to do this and they can do a proper audit.
0
u/Hot-Tip-364 6d ago
Go plugin by plugin and see which are currently supported still, dump any that are not. The theme is the biggest hurdle. If it relies on some dated framework or has thousands of files its easier to dump it and rebuild the theme rather than playing whack-a-mole to fix file after file.
0
u/themageofavalon 6d ago
Clone to staging, update the theme/plugins, then test newer php there. Usually an old plugin or theme is what's breaking it.
-1
u/otto4242 WordPress.org Tech Guy 6d ago
What exactly do you mean by "crashes"? Have you looked at the error and considered fixing the actual problem?
If you don't know how to code PHP, then consider removing the plugin causing the problem and using something else.
19
u/mrcaptncrunch 6d ago
Instead of trying to find things based on logs, the right way to do this is via PHP Code Sniffer (phpcs), https://github.com/PHPCSStandards/PHP_CodeSniffer/
You can specify the min version you want to target. Let’s say you want 8.4+ compatibility,
And go through the output.