• Home
  • Linux
  • Fix it!
  • Dogs
  • Contact
  • english
  • deutsch
How To Everything!

Latest 5 in Linux Troubleshooting

  • Automount external hard disks on the Raspberry Pi
  • Speeding up usb storage devices on the Raspberry Pi
  • Nvidia and ATI Graphics Card Problems with Ubuntu (10.04-12.04)
  • Finally No More Tearing Anywhere With Mate Desktop And Compiz
  • Fix Stuttering Video With No Sound

linux tags

driver mint energy imac firmware wifi mate classic ubuntu nvidia gconf-editor sound networking mplayer flash skype compiz lmde webcam ethernet HD 4000 window buttons dvb video ssd imagemagick digitenne isight Ivy Bridge tearing
more tags

share this


Selectively hide "strict warning" errors with PHP 5.4, Drupal 6.x, Views

If you are using Drupal 6.x and Views 2.x or 3.x and the server your drupal installation is hosted on was recently updated from php 5.2 to 5.3 or 5.4 you might suddenly have to deal with warnings like the following ones: 

  • strict warning: Non-static method view::load() should not be called statically in ...
  • strict warning: Declaration of views_handler_filter::options_submit() should be compatible with views_handler::options_submit($form, &$form_state) in ...
  • strict warning: Declaration of views_handler_filter_boolean_operator::value_validate() should be compatible with views_handler_filter::value_validate($form, &$form_state) in 

The most annoying thing about those is that they are also being displayed to anonymous users and drupal has no build-in method to prevent this.


Why hiding all error messages through theming is a bad idea

There are a lot of howto articles out there, that suggest that it is a good idea to get rid of all error messages by hiding them through theming. It is a quick and easy fix but it is also a dirty one that potentially can create problems because of the following reasons:

  • hiding error messages through theming is only possible by hiding all messages for everyone
  • therefore not even the admin will see any more errors, limiting the feedback from the system while developing 
  • also registered users won't get messages like "wrong password", "last login"
  • confirmation messages to anonymous users e.g. from a contact form also won't show anymore 

If you don't care about these downsides and still want to do it: just open the template.php file inside your current templates directory and comment out or delete the block that starts with <?php if ($messages): ?> and ends with <?php endif; ?>. Be sure to double-check whether you edited the whole block because otherwise you might break your template and your site. If you have 5 more minutes be sure to read on, since a much cleaner workaround will only take that long. 


How to hide only specific error messages to specific users

Thanks to contributer zyxware there is a module called "Disable Messages" that helps you with all issues connected to error- or warning messages on your site. Here how to get and install it:

  • Go to the "Disable Messages" project page and download the tar.gz file that fits your Drupal version. Drupal 6 users need 6.x.... 
  • Upload this file to your modules folder and unpack it
  • Activate it on the admin/build/modules page and hit save configuration at the bottom of the page

To completely make use of this module you'll need to be a bit familiar with regular expressions. But since it is a rather complex topic, we want to get you starting by explaining how to hide all error messages with the word "static" to everyone, but by doing that not hiding "wrong password" or similar messages:

  • go to the modules configuration page at admin/settings/disable-messages
  • make sure "Enable filtering" is checked
  • in "Messages to be disabled:" enter
    • strict .*.
  • this will filter all messages that contain the word strict and additional characters
  • in "Page and user level filtering options" you can optionally input pages or user names, that should be exclude from the filtering
  • the drupal user permission page at admin/user/permissions provides you with additional options to configure user based display

How To Everything!

disclaimer image sources some rights reserved

Links

jrhenkelmann.net anchesa kyamara healthy happy joy joy