How to Fix Strict Warnings in Drupal 6 Running on PHP 5.4

Drupal

Posted on May 13, 2014 in Development, Web

If you are using Drupal 6 and your host suddenly decides to upgrade their PHP version from 5.2 to 5.3 or 5.4, your site will most likely continue to work, but it will start throwing a bunch of strict warnings, even for non-logged users. The warnings will be similar to these:

strict warning: Non-static method view::load() should not be called statically in...
strict warning: Declaration of views_attach_plugin_display_node_content::options_submit() should be compatible with views_plugin_display::options_submit(&$form, &$form_state) in...
strict warning: Non-static method views_many_to_one_helper::option_definition() should not be called statically, assuming $this from incompatible context in...

Since the errors are displayed to everyone and Drupal has no inherent way to hide them, you will want to get rid of them somehow.

Obviously the best solution is to upgrade your site to Drupal 7 to catch up with the modern times and remove the accumulated technical debt, but if it is somebody else’s site, they may not appreciate or understand the sudden need for you to spend x number of hours to upgrade the site. Because, you know, it was working fine until now, why should it suddenly stop working now?

Another possibility is to check with your host whether you can continue to use the older PHP version for this particular site. You might be able to do this yourself from the PHP Configuration section in your cPanel.

If none of the above solutions works for you, consider installing a Drupal module called “Disable Messages” which lets you disable specific messages shown to end users. You can do a whole bunch of things with it and you can also use it to ‘fix’ the strict warnings. Please note that ‘fix’ in this context is not really a fix—you will just be hiding the errors, not really fixing them. But as an immediate solution it works and it will give you time and space to consider what to do in the long run.

Here is how to use it:

1) Download the module archive from the module page. You will want to grab the 6.x version.
2) Unpack it and upload the contents into your site’s modules folder.
3) Log into your site as an admin and activate the module on the modules page (/admin/build/modules).
4) Go to the module’s configuration page (admin/settings/disable-messages).
5) Make sure ‘Enable filtering’ is checked and enter strict .*. in the ‘Messages to be disabled’ box.
6) Save the configuration.

The module uses regular expressions to filter the messages and entering the above ensures that all messages containing the word ‘strict’ will be hidden. If you want to exclude certain pages or users from the filtering, you can do so in the ‘Page and user level filtering options’ tab.

Make yourself a cup of hot chocolate, breathe deeply, and start thinking about what it will take to upgrade your site to the latest Drupal version.

Enjoyed this post? Share it with others.
Share on email
Email
Share on facebook
Facebook
Share on google
Google
Share on twitter
Twitter

Responses (4)

  1. kathir
    January 4, 2016 at 6:02 pm · Reply

    Thank you so much..

    • pixel.ninja
      January 4, 2016 at 6:21 pm ·

      You’re most welcome!

  2. Claudia
    April 14, 2017 at 5:27 am · Reply

    I followed all the steps. It is working … help please !!!

    • pixel.ninja
      April 14, 2017 at 12:08 pm ·

      Hi Claudia,

      I’m sorry, I’m not sure what the issue might be. The above worked fine for me and others 🙁

Leave a reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.