Drupal missing modules and white screen of death
WSOD (white screen of death) can happen in drupal for different reasons. One is that you could be missing some files, probably modules. Maybe you moved something wrong when migrating, or you have wrong git branch or just delete module(s). Anyway when module is missing drupal will try to find it like crayze For example: 1 missing module lead to 900 file_scan_directory() calls resulting in a wasted 250ms every page load it is said here
Reseting passwords in Drupal 7
Reseting drupal password with latest drupal version has become much harder task, before you could just MD5 user table and add new password, now the "salt" is added so it is a bit harder. There are two ways, with mysql and shell access, or with php file. First you can find here
https://drupal.org/node/1023428 - SSH and MySql
https://drupal.org/node/1556488 - PHP file
Drupal Varnish and what to put in .vcl file
Before I talked about some troubleshooting and had some general discussions about caching
http://drupaldump.com/varnish-simple-troubleshooting-defaultvcl
http://drupaldump.com/boost-and-varnish-and-general-tips-and-rants-about...
Now I am going to talk about what to put in your default.vcl file and why.
.host = "127.0.0.1";
.port = "8082";
.connect_timeout = 600s;
.first_byte_timeout = 600s;
.between_bytes_timeout = 600s;
}
Varnish simple troubleshooting for default.vcl
Here is some simple troubleshooting for Varnish
If you want to have simple solution, cache with varnish for all anonymous users and for logged in users you disable varnish use this in your vcl
#check if there is session cookie from logged in user
if (!req.http.Cookie ~ "SESS|SSESS|NO_CACHE") {
unset req.http.Cookie;
}
# Cache things with these extensions whether we are logged in or not, we don't care
if (req.url ~ "\.(js|css|jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf)$") {
return (lookup);
}
}
Boost and Varnish and general tips and rants about Drupal caching
This topic has always been a big pain in the ass for me. Drupal takes a lot of resources, which means money for hosting, you should at least have VPS to have some decent hosting for drupal, but not to have OOMing and high CPU usage all the time, you should use different caching systems.
Boost
Setting perimissions to files and other Drupal directories or your VPS/Server
If you ever wondered how to setup permission and ownership of files on your drupal server installation, look no further, this article has all the good examples.
Varnish help
So Varnish is really good caching thingy if you use drupal (or other stuff) so to see what it is doing and how, you can login to your server and try this commands.
varnishlog - See what Varnish is currently processing, you will get complete header info I think
varnishstat - Shows various information about varnish
varnishhist - Shows a histogram chart of the last 1,000 requests (by default) to the Varnish. Showing | as a hit on the cache and # as a miss. The more | to the left of the chart, the better.
Add UTM tag to links, so other people know when users come from your site
So this is some marketing stuff I do, but it is useful. When you click a link on some site, to give some message to that site and owner or whoevere is taking care of marketing you can add some UTM tags to links so in their google analytics they see that message. So what do we do is I use display suite, create custom code field and use entity data to make new fields that look like this:
if (!empty($entity->field_collegamento)){
foreach ($entity->field_collegamento['und'] as $key => $value) {
Adding tracking (google analytics event) to phone numbers/phone calls
I wanted to have phone call tracking on my website, so I know how many users did click phone number to call over cell phone or phablet or whatever device they can call (maybe google glass or something) So I added some code to my phone fields. I have cck field that I display over display suite, so I override this field and remove default display and create custom display, code field where I use entity data and add custom code to the phone numbers so they are clickable links. Code looks like this
if (!empty($entity->field_phone)){
Removing title from Page to use title from Node or how to make templates for pages per node type
Drupal is great :)) well not so much, it is made in a way that you will always have love/hate relationship with it. So somebody thought that best way to make templates is to have title and h1 tag always in page template separated from the rest of the content, which is fine if you are doing pages in 2002. If you want to have nice header with image of author, date and some other info and display it like you want and not have to use panels just to do that, you have to override, which is ok, but then again somebody else thought, why would you want to override pages by node type.