how to prevent warnings from displaying to anonymous users
First you should turn down the error_reporting options on your production server. This will erase most of PHP's warnings and notifications.

Also you can configure drupal to only log the errors. To do that go to Administration &gt; Configuration &gt; Development &gt; Logging and errors or directly to the path /admin/config/development/logging and set "Error messages to display" to none. Drupal then still logs errors but doesn't display them to users.

If you still need finer control over messages surely the module disable_messages can help you.