“Deprecated” vs “Fatal error” in PHP: which one breaks your site?
Short answer
Read the first word of the message. “Fatal error:” stops the page there: visitors see WordPress’s critical error page, and it needs fixing now. That includes every “Uncaught …” error (TypeError, ValueError, Error). “Deprecated:” never stops a page: the code works, and PHP warns that a future version won’t accept it; it can wait for the plugin’s next update. “Warning:” and “Notice:” sit in between: the page continues, sometimes with a missing or wrong value. After a PHP upgrade, sort the log by first word, and deal with the fatal errors first.
Tell them apart by the first word
| The message starts with | The page | What to do |
|---|---|---|
| Fatal error: (including Uncaught Error, TypeError, ValueError) | Stops there | Fix now: switch back, update or replace |
| Warning: | Continues, maybe with a wrong value | Fix soon |
| Notice: | Continues | Fix when you can |
| Deprecated: | Continues normally | Let updates fix it before the next PHP version |
A deprecation notice: the page works
PHP 8.4 deprecates making a parameter nullable through its default value. The code runs the same; PHP adds a line:
wp-content/plugins/order-notes/order-notes.php
<?php
class Order_Note {
public function __construct(string $text, DateTime $created = null) {
echo $text, $created ? ' (dated)' : ' (no date)', "\n";
}
}
new Order_Note('Gift wrap');
Gift wrap (no date)Deprecated: Order_Note::__construct(): Implicitly marking parameter $created as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/wp-content/plugins/order-notes/order-notes.php on line 3
Gift wrap (no date)php.net describes this level as “Run-time deprecation notices. Enable this to receive warnings about code that will not work in future versions.” (php.net) More on the level itself: E_DEPRECATED in PHP.
A fatal error: the page stops
Here a plugin uses a constant PHP 8.4 removed. On PHP 8.3 the page completes; on 8.4 nothing after that line runs:
wp-content/plugins/table-viewer/includes/columns.php
<?php
$field_type = 247; // the type number MySQL reports for a column
if ($field_type === MYSQLI_TYPE_INTERVAL) {
echo "List column\n";
}
echo "Done\n";
List column
DoneFatal error: Uncaught Error: Undefined constant "MYSQLI_TYPE_INTERVAL" in /var/www/html/wp-content/plugins/table-viewer/includes/columns.php:3
Stack trace:
#0 {main}
thrown in /var/www/html/wp-content/plugins/table-viewer/includes/columns.php on line 3On a website, WordPress replaces the page with “There has been a critical error on this website.” (what to do).
Why both matter after an upgrade
- Fatal errors are what makes an upgrade go wrong. A check before switching finds most of them, labelled “Will break”.
- Deprecation notices are tomorrow’s fatal errors: PHP 8.0 turned the deprecated functions of PHP 7.x into errors (the list).
- Any displayed message, even a notice, can break redirects and logins: “Cannot modify header information”. Log them instead (how).
CompatNav, free on wordpress.org, sorts what a PHP upgrade changes into exactly these two groups, per plugin and theme, before you switch:
The longer explanation, with all four levels and how to hide them from visitors: deprecation notice or fatal error.
Key takeaways
- “Fatal error:” and “Uncaught …”: the page stops. Fix first.
- “Deprecated:”: the page works; it’s a warning about a future PHP version. Fix through updates.
- “Warning:” and “Notice:”: the page continues, maybe with a wrong value. Fix when you can.
- Displayed messages of any kind can break redirects and logins; log them instead.
- A check before upgrading labels each finding “Will break” or “Deprecation notice”.
Frequently asked questions
Can a deprecation notice become a fatal error?
Yes, in a later PHP version: PHP 8.0 removed functions that PHP 7.2 to 7.4 had deprecated, such as create_function(), and their calls became fatal errors.
Why does my site work although the log is full of messages?
Because they’re deprecation notices, warnings or notices. Only a fatal error stops a page.
Should I hide these messages?
From visitors, yes: log them instead of displaying them. Hiding doesn’t fix anything, so keep reading the log.
Check your own site before you upgrade
CompatNav is a free WordPress plugin. It reads the code of your plugins and themes on your own server and tells you, in plain words, what will break and what will only show notices on the PHP version you choose. It never changes your code. It can’t see problems that only appear while code runs with real data, so a quick check of your site after the upgrade still matters.
Sources
About the code examples: each output is the real output of the code shown, run with the official PHP builds, without a php.ini, with all errors reported and displayed. Only the file path was replaced by a neutral server path.