fbpx Common Drupal Problems - Solutions Included | DrupalExp - Premium Drupal Themes & Modules
0

Common Drupal Problems - Solutions Included

Common Drupal Problems - Solutions Included

Whether you are a Drupal newcomer or a seasoned Drupal developer, you're bound to run into one, some, or all of the issues outlined below. Some are obvious, some not so obvious, but we'll show you how to troubleshoot them all regardless.

Some of these issues took a while to troubleshoot, so if you use Drupal as much as we do, make sure you bookmark this page for easy reference in the future. There is nothing worse than spending hours on a problem that can be solved within minutes with the right information (we've all been there).

Issue 01

If you’re working on a Drupal 8 site and you get the message "The provided host name is not valid for this server," you’re not alone. This is a result of a feature added to Drupal 8 to protect against HTTP Host Header attacks.

To fix, set the $settings['trusted_host_patterns'] variable in your settings file. If you are running from one hostname, like www.mysite.com, you’d set it like so: $settings['trusted_host_patterns'] = array( '^www\.mysite\.com$', );

Issue 02

Configuration management in Drupal 8 is great! But you might run into one thing thing that bugs you - for example, if you override a configuration value within settings.php there is no indication in the UI that the values were actually overridden. This is a complete 180 from Drupal 7, which displayed overridden values within the UI. Right now, there is no official solution to this problem, unfortunately, but here are two things you can do:

  • This issue on drupal.org has an actively worked on patch that you can use: https://www.drupal.org/node/2408549
  • The Configuration Update Manager contrib module can give you this info.

Issue 03

Generally, when you’re developing, you don’t want your CSS and JS cached, so that you can debug it. An easy way to make sure caching is turned off is to put these lines in your settings file:

/**
 * Disable CSS and JS aggregation.
 */
$config['system.performance']['css']['preprocess'] = FALSE;
$config['system.performance']['js']['preprocess'] = FALSE;

Issue 04

MAMP is a fantastic local development tool, but it can sometimes be tricky to set up with Drupal and Drush. Are you getting an error similar to this when using Drush, but the site works fine?

exception 'PDOException' with message 'SQLSTATE[HY000] [2002] No such file or directory' in core/lib/Drupal/Core/Database/Driver/mysql/Connection.php:146

There’s an easy fix. Add the following to your database credentials within your settings.*.php file:

'host' => '127.0.0.1',
'unix_socket' => '/Applications/MAMP/tmp/mysql/mysql.sock',

Issue 05

A lot can go wrong if your files and directories are not properly secured. The extended documentation can be found here.

  • sites/default/files: This directory should have the permissions rwxrwx--- or 770
  • You can use the File Permissions module to correctly set up your file permissions, especially if you are seeing errors about your sites/default/files and sites/default/private directories being incorrectly set up.

Issue 06

You’re setting up a new Drupal installation, or doing something new in an existing one, and boom, a white screen. What do you do? There are a handful of options for debugging. Here are a few to get you started:

  • Check your error logs! Look at your Drupal, PHP, and Apache logs.
  • Make sure you have error reporting on. Follow these directions to turn it on and in many cases, get the errors printed on the WSOD: https://drupal.stackexchange.com/a/54241
  • Here’s a debugging tactic to tell you which module may be hanging up your site and causing the issue: https://drupal.stackexchange.com/a/105194
  • Increase your PHP memory limit !

Issue 07

A lot can go wrong if your files and directories are not properly secured. The extended documentation can be found here.

  • sites/default/files: This directory should have the permissions rwxrwx--- or 770
  • You can use the File Permissions module to correctly set up your file permissions, especially if you are seeing errors about your sites/default/files and sites/default/private directories being incorrectly set up.

Issue 08

You’re setting up a new Drupal installation, or doing something new in an existing one, and boom, a white screen. What do you do? There are a handful of options for debugging. Here are a few to get you started:

  • Check your error logs! Look at your Drupal, PHP, and Apache logs.
  • Make sure you have error reporting on. Follow these directions to turn it on and in many cases, get the errors printed on the WSOD: https://drupal.stackexchange.com/a/54241
  • Here’s a debugging tactic to tell you which module may be hanging up your site and causing the issue: https://drupal.stackexchange.com/a/105194
  • Increase your PHP memory limit !

To be continued...