How to use WP Umbrella to troubleshoot PHP errors?
During its execution, a PHP application (such a plugin) may generate many different types of errors. For developers trying to find a cause of a misbehaving application, seeing these errors is essential. PHP developers, however, frequently have trouble displaying error messages from their applications.
Sometimes, they don’t even know that their scripts are broken. Instead, their websites just fail silently, which is not acceptable if you are maintaining WordPress websites.
WP Umbrella track and monitor PHP errors so every developer diagnose, fix, and optimize the performance of their code.
This article is a deep dive into WP Umbrella’s PHP errors monitoring feature. I’ll explain you:
- The different type of errors in PHP;
- Why they happen and how they can (sometimes) harm your website uptime and performance
- How to use WP Umbrella to troubleshoot these PHP errors.
Let’s get started!
Types of Errors in PHP
A PHP Error occurs when something is wrong in the PHP code. For example, a semicolon could be missing, or a variable might be called incorrectly.
There are four different types of errors in PHP:
- Warning Error
- Notice Error
- Parse Error
- Fatal Error
Understanding the type of problem that is occurring is crucial to effectively resolving PHP issues.
Warning errors in PHP
When a warning error occurs in PHP, the script will continue to run. The message only serves as a warning that there is an issue and that it could cause bigger problems down the road.
Warning errors in PHP are usually caused by:
- Calling a file that does not exist’
- Incorrect parameters in a function
Notice Errors in PHP
Notice errors in PHP are minor errors. Like warning errors, they also do not stop code execution.
Notice errors usually occur when a script tries to access an undefined variable.
Parse Error (Syntax) in PHP
The most common cause of parse errors is a misused or missing syntax symbol. In such situation, the compiler catches the error and terminates the script execution.
There are several reasons why parse errors occur:
- Unclosed brackets or quotes
- Missing or extra semicolons or parentheses
Fatal Errors in PHP
These errors crash your program and are classified as critical errors. This type of error is usually caused by an undefined function or class in the script.
These are the three different types of fatal errors in PHP:
- Startup fatal error: when the system isn’t capable of running the code right after install)
- Compile time fatal error: when the developer uses non-existant variables)
- Runtime fatal error: occurs during the execution of the program, causing it to stop working)
Why plugins and theme generate PHP errors?
Plugins and themes can generate many PHP errors. Some of them are not dangerous, while others can jeopardize your website uptime and performance. But why is this so?
Outdated PHP / WordPress version.
Mostly because they are not following the new coding best practices or because the code is not any longer compatible with WordPress or with PHP itself.
PHP and WordPress are regularly updated, and plugins and themes must follow the pace, otherwise, they start generating errors and security breaches.
Example: your hosting provider is using PHP8. One of the plugins has been coded under PHP7 and was not been updated since PHP8 was released. This can generate a lot of PHP errors if the plugin is using functions or coding practices that do not exist with the new PHP version.
Conflicts between plugins
PHP errors can also be caused by 2 or more conflicting plugins. Plugins and themes can indeed conflicts if they are using the same naming convention.
Example: Plugin A and plugin B have two different functions, but both are named function microwave(). This can confuse the server that will not know how which function it has to execute first and will result in PHP error(s).
Plugins can also conflict if they are using the same library but with a different version of it.
Example: two plugins use Guzzle to send HTTP requests, but one uses Guzzle 7.0, and the other Guzzle 6.0. This can confuse your server and generate PHP errors.
That’s why it’s critical to keep your theme and plugins up to date.