PHP Notices, Warnings and Errors on Your Drupal Site

PHP Notices, Warnings and Errors on Your Drupal Site

Websites will run into problems. Whether you’re using Drupal or any other software, there will be problems at some point.

Drupal runs on PHP and when PHP has problems, it reports them to you.

However, often these errors will appear on your site and will be visible to visitors, as in the image below:

PHP Notices on Your Drupal Site

In this tutorial, we’re going to give you a quick introduction to these errors. We’ll explain the different types that might appear on your site and how you can stop them from showing.

There are three main ways in which PHP will report problems: notices, warnings and errors.


What are PHP Notices?

These are the least important. According to the official PHP website, notices are generated when:

“the script encountered something that could indicate an error, but could also happen in the normal course of running a script.”


What are PHP Warnings?

Warnings are more serious, but probably won’t break your site. According to the official PHP website, warnings are:

“non-fatal errors. Execution of the script is not halted.”


What are PHP Errors?>

Errors are the most serious type of problem and may break your site. According to the official PHP website, warnings are:

“Fatal run-time errors. These indicate errors that can not be recovered from, such as a memory allocation problem. Execution of the script is halted.”


Solution #1: Disable Error Reporting on Your Drupal Site

One solution is to simply stop the errors from showing.

  • Go to Configuration > Logging and Errors.
  • You have three choices:
    • None will disable all error reporting.
    • Errors and warnings will display on the most serious problems.
    • All messages will display all problems and is probably only useful for developers.
Disabling Error Reporting on Your Drupal Siteg

Solution #2: Fix the Problem

Yes, yes, I know this is a controversial idea. Fixing a problem is definitely harder than hiding a problem.

Here are some suggestions to help you fix the problem. Please backup your site before trying any of these.

  • Make sure your Drupal site and all your modules and themes are up-to-date.
  • Search Google and Drupal.org for anyone who has reported the same message. See if they have found a solution.
  • Read the message itself for hints about the problem. For example, the problem in the image at the top of this tutorial is all/modules/calendar/includes/calendar_plugin_display_page.inc on line 47. This tells that the problem may well be with the Calendar module, because the error is coming from the Calendar module folder. If the problem is serious, you might consider disabling the problematic module or theme.

Instructor

  • Steve is the founder of OSTraining. Originally from the UK, he now lives in Sarasota in the USA. Steve's work straddles the line between teaching and web development.

0 0 votes
Blog Rating
Subscribe
Notify of
3 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Julian Granger-Bevan

There’s quite a basic thing that you’ve left out – and that is to report the bug to the issues queue of the module that the problem seems to be coming from.

Most module maintainers will want to fix these bugs, and saves the overkill of disabling a module or theme that you otherwise wanted to use.

Sean Smith

This seems very straight forward, but I’m stuck on the first step. I don’t see “configuration” or “logging and errors” anywhere. I have a “site configuration” at the top, but logging & errors is not one of the options. Any advice?

mefree

I see that this is a 4 yr old reply, but the answer (in D7) is Configuration/Development/Logging & Errors.

3
0
Would love your thoughts, please comment.x
()
x