GIT - checking status of master and differences

Before final git pull to LIVE site, it is a good idea to check what is going to be pulled. So to do that

Git fetch
git diff master origin/master


git diff --name-only master origin/master

This should give you more insight on what is going to be pulled in the end, as this marks differences between current master branch on LIVE site and master on github.

Debugging ajax calls/requests

In case ajax calls are making a trouble and developer needs more information about what is happening regarding:

Dumping drupal DB without cache tables

If you want to dump DB from production or develop servers and not include cahce table values for faster importing you can use below script. You need to change site_name variable and DUMPDIR to match what you have and also user/password of DB

Bash script for cloning database on server

If you need to copy DB, lets say from production to develop you can use this script and call it like " original_db cloned_db"
For faster cloning it will exclude cache tables data.

Life of a view and what and where to hook or alter

Often I have a need to alter a bit output of a view, either the markup or just query, it's important to know where to hook in a life of a view, here is the list of hooks and alters.

Get list of all the hooks your site currently uses

In includes/, find the module_implements() function (around line 715 in Drupal 7). At the top of the function, just add this below and you will get huge output of all the hooks that are called.


function module_implements($hook, $sort = FALSE, $reset = FALSE) {


Find out which theme function to call to alter each element on page

This is a hack on how to get output of which theme function to call to alter each element on page. So you will need to go to In includes/ in the Drupal 7 theme() function, around line 1161 and change $output from one line to two lines and to have this code below. You will get theme suggestions all around the page, which will be messy but will help you find what you need.

Add a field to entity programmatically

Wanting to add field to some entity (we here pick order entity) by code, for example when deploying to production, use this snippet of code and you will have this new field added.