How to Fix Common Errors After a PHP Upgrade
In this article15 sections
You upgraded PHP and something broke. The page is blank, an image upload fails, a plugin shows an error, or the log fills with lines you have never seen. After a version change, almost every problem falls into a short list of known causes: an extension that did not come across, a function or behaviour that was removed, a setting that reverted to a default, a file with the wrong owner, or a service that is still running the old code. This guide lists the errors in the order you are most likely to see them, explains what each one means, and gives the fix, with checks for any platform: cPanel, Plesk, Ubuntu, AlmaLinux, Windows or Docker.
If you are not sure the fault is the PHP version, the quickest test is to roll back. Every platform guide ends with a rollback that takes seconds. A site that works again on the old version confirms the cause, and gives you time to find the fix without pressure. Sites on a SiteHarbour cPanel plan or WordPress plan can switch back in the control panel at once.
Step 1: Read the actual error
A blank page or a generic 500 error tells you nothing, but the log does. Find the log for your platform and read the newest lines:
- cPanel: Metrics > Errors, or
~/logs/. - Plesk: the website’s Logs page.
- Nginx with PHP-FPM:
/var/log/nginx/error.logand/var/log/php8.4-fpm.log. - Apache:
/var/log/apache2/error.logor/var/log/httpd/error_log. - Windows with IIS: the PHP
error_logfile named inphp.iniand the Event Viewer. - Docker:
docker compose logs php.
For WordPress, turn on WP_DEBUG_LOG and read wp-content/debug.log, as shown in how to fix the WordPress white screen of death. The error message, with its file and line, names the fix in the sections below.
Error 1: Call to undefined function (a missing extension)
Messages: Call to undefined function mysqli_connect(), mb_strlen(), curl_init(), imagecreatefromjpeg().
Cause: the new PHP version does not have the extension enabled. Each version has its own set, and the new one starts with defaults.
Fix: install or enable it for the new version. On cPanel, tick it in Select PHP Version. On Plesk, in the website’s PHP Settings. On Ubuntu, install the matching package, such as php8.4-mysql or php8.4-mbstring, then restart PHP-FPM. On AlmaLinux, sudo dnf install php-mysqlnd php-mbstring. On Windows, remove the semicolon in php.ini. In Docker, add it to the Dockerfile with docker-php-ext-install. Check with php -m | grep -i name.
Error 2: Class not found, or Cannot redeclare a function
Cause: a package or plugin that does not support the new version fails to autoload, or two files declare the same function once the stricter rules apply.
Fix: update the package or plugin to a release that supports the version. For Composer projects, run composer why-not php 8.4 and composer update on the package, then clear any cached autoload files with composer dump-autoload -o. For a plugin, update it, or replace it if it has not been updated for a long time.
Error 3: Deprecated notices filling the log
Messages: Deprecated: Creation of dynamic property, Passing null to parameter #1 of type string is deprecated, Implicit conversion from float to int loses precision.
Cause: the code still works, but it relies on behaviour the language is retiring. Large logs full of these slow the site down and can fill the disk.
Fix: in your own code, fix the pattern: declare the property in the class, check for null before the call, cast values on purpose. For code you do not control, do not hide the problem by changing the error level in the code. Lower the log level in php.ini with error_reporting = E_ALL & ~E_DEPRECATED as a stop-gap, and report it to the author. Keep a note to revisit it, because the next version may turn the deprecation into an error.
Error 4: Uncaught TypeError or Unsupported operand types
Cause: from PHP 8, many operations that used to give a warning now throw an error. Adding a string to an array, passing the wrong type to a built-in function, or using a value as an array when it is not one all fail.
Fix: the message names the file and line. Fix the type at the source: cast, check, or set a sensible default. For a plugin, this is a bug in the plugin, so update it.
Error 5: Removed functions and syntax
Messages: Call to undefined function each(), create_function(), Parse error: syntax error, unexpected ‘{‘ on string offsets like $str{0}.
Cause: the function or syntax was removed. Old themes and abandoned plugins often use them.
Fix: replace them with the current alternatives. each() becomes a foreach. create_function() becomes an anonymous function. Curly-brace string offsets become $str[0]. A theme or plugin that uses several removed functions is a sign to replace it, not to patch it.
Error 6: 502 Bad Gateway or 503 after the change
Cause: the web server cannot reach PHP-FPM. The socket name changed, the service did not start, or the pool user and the socket permissions do not match the web server’s user.
Fix: check the service is running with systemctl status php8.4-fpm, check the socket name in the web server configuration, and check the socket ownership. The Nginx side is in how to fix 502 Bad Gateway on Nginx. On AlmaLinux or Rocky, the pool user defaults to apache and must be changed to nginx for an Nginx server.
Error 7: 500 error after moving from mod_php to PHP-FPM
Cause: php_value and php_flag lines in .htaccess only work under mod_php. Under PHP-FPM they cause a 500 error.
Fix: remove those lines from .htaccess and put the settings in a .user.ini file in the site’s folder, or in the pool configuration. cPanel’s MultiPHP INI Editor does the same job through the panel.
Error 8: Upload, memory or timeout limits changed
Symptoms: large uploads fail, imports stop part way, a page that worked now says it ran out of memory.
Cause: the new version started with default limits, because your edited php.ini belongs to the old version.
Fix: set memory_limit, upload_max_filesize, post_max_size and max_execution_time again for the new version, in the place your platform uses. If uploads still fail, the web server may also cap the size, as covered in how to fix 413 Request Entity Too Large on Nginx and PHP.
Error 9: Users are logged out, or sessions fail
Cause: the new PHP process cannot write to the session folder, or it uses a different folder than the old one.
Fix: check session.save_path for the new version and make sure its owner is the PHP user. On a shared platform, set it to a folder inside your account.
Error 10: The old version still runs somewhere
Symptoms: a cron job fails, WP-CLI prints a different version, a queue worker uses removed code.
Cause: the command line and background services use their own PHP, not the web one.
Fix: call the new binary by its full path in cron, as described in how to set up cron jobs in cPanel, change the command line default with update-alternatives on Ubuntu, and restart every long-running worker, because it keeps the old code in memory until it restarts.
Step 2: Fix one thing at a time
When several errors appear together, fix the first fatal one, reload, and read the log again. Often the later errors disappear, because they were caused by the first. Change one setting at a time, so you know which change worked. Write down each fix, so the next site on the same platform takes a fraction of the time.
Step 3: Know when to roll back
Roll back at once if the site is down for customers and the cause is not obvious in ten minutes. Fix it on a copy afterwards. Staying on a version that no longer receives security fixes should be a temporary state with a date to leave it, and the next upgrade should start from the checks in how to check your code for PHP compatibility before you upgrade.
Common mistakes
- Hiding errors instead of fixing them. A deprecation you hide today becomes a fatal error later.
- Editing core files of a plugin. The next update overwrites the change.
- Fixing several things at once. You cannot tell what worked.
- Forgetting background services. Workers and cron jobs keep the old version.
- Leaving debug output on. Turn it off when you are done.
Frequently asked questions
Why did the site work on the test copy and fail on live?
The two had different extensions, limits or file owners. Compare the two PHP configurations side by side.
Is it safe to ignore deprecation notices?
For a while. They are your upgrade to-do list for the next version, so fix the ones in your own code first.
Do I need a developer to fix these?
Most of the errors in this list have simple fixes. A site with a large custom code base, or an abandoned plugin that cannot be replaced, can need developer time.
How do I stop this happening on the next upgrade?
Test on a copy first, keep the extension list, record your settings, and update plugins and packages regularly, so they never fall far behind.
After a PHP upgrade, nearly every problem is one of ten known causes: a missing extension, a removed function, a type error, a lost setting, a socket or permission mismatch, .htaccess directives under FPM, a session folder, or an old version still running somewhere. Read the log, match the message to the list, fix one thing at a time, and roll back if the site is down and the cause is not clear. For help planning the next move, read which PHP version to use: support dates and an upgrade plan.
Want this done for you? If you would rather have an engineer plan and carry out the work on your own site, you can hire the author through the Upwork profile of Munaf Sheikh.