Drupal Development

Drupal Performance Tips: Avoid DISTINCT in Drupal Views and SQL queries to speed up query execution and improve page load times

On one of the maintenance projects we got we came across a page that used to take around 11 seconds to load. The page was a views listing for users. We were able to speed up the page load times from around 11 seconds to under 3 seconds by taking out just the distinct option used in the view. The following was the select query that was originally generated from the view with the time logged by views in the preview panel.

How to install and configure Boost caching module to speed up performance on your Drupal 6 site

Boost is a module in Drupal that enables file based static page caching in Drupal. When an anonymous user visits a page for the first time in a Boost-enabled Drupal site, the page will get stored as a static html file in a cache folder. When the next anonymous user visits the same page the htaccess rules created by Boost will serve the static file cached in the cache folder instead of bootstrapping drupal for generating the page. This saves a lot of processor usage and would help even entry level hosting servers serve reasonably good volume of traffic. Here is how you can install and configure Boost in a Drupal 6 site.

Solution for warning in Drupal - call_user_func_array() expects parameter 2 to be array, string given in sites/all/modules/contrib/views/views.module

We recently saw this error on a Drupal 6 site that had not been updated for quite a while."warning: call_user_func_array() expects parameter 2 to be array, string given in sites/all/modules/contrib/views/views.module" means what it says. call_user_func_array expects the second parameter to be an array whereas a string was given instead. You can troubleshoot problems like this by writing a bit of debug code before the line where the error is reported.

Deployment Checklist for Drupal web application projects

Developing a Drupal website is a complicated and long process. You have to check whether all the design and functionalities meet with the client specifications. And before the site going to be live you have to check certain criteria.These checklists describes the criteria that should be tested before a site going to be live.

How to log in programmatically as user 1 in Drupal 7

Once in a while you will come across a Drupal site where you have to login to the site without having access to the credentials of user 1. You can easily reset the password of user 1 directly in the database or you can create a small work around to login to the site. Here is how you can login to the Drupal 7 site programmatically as user 1 without knowing user 1 credentials.

How to login programmatically as user 1 in Drupal 6

If you have a Drupal 6 site where you have access to the ftp account but not to the user 1 credentials here is how you can login programmatially to the site as user 1 without resetting the user 1 password. Now that you know that this is possible, remember to not give ftp access to users who do not have access to user 1 credentials as well.

Recovering / Resetting the password of user 1 in Drupal 6 or Drupal 7

Frequently we come across Drupal sites (live or testing) where the user 1 passwords are not known to the owner of the site. You can retrieve the password by changing the email address of user 1 to your email address and then use the forgot password option to reset your password. But if you don't want to change the user 1 email address but instead just want to change the password of user 1 there is an easier alternative via the database.

Understanding db_rewrite_sql, node level access permissions and generation of primary links in Drupal

On a Drupal site that came up for some minor alterations recently we came across an issue where some menu links disappeared for anonymous users while they appeared normally for the administrative users. On digging further we came across an issue with an implementation of hook_db_rewrite_sql in a contributed module.

Drupal debugging tips: Print and Die

While developing Drupal sites, sometimes we may wish to see whether our function is getting called or whether we reach a point or not in the execution path. Usually the dpm() or print_r() functions comes handy in the case, but sometimes, we may not be able to see the debug messages printed due to page redirection just after our print.

How to rebuild menu_links table and rebuild the navigation menu

In Drupal 6, when you are working on a new project and when you change menu items from MENU_NORMAL_ITEMS to MENU_LOCAL_TASK or vice versa you will run into a scenario where the menu_links table entries won't get changed. This can get reflected in menu_links not appearing in your system_admin_menu_block_page listing if you are using it for listing your menu items in a page.

Drupal Tips: Common Browser compatibility issues-Background image not working in IE7/IE8/Opera

For any site - be it Drupal or non-Drupal, this is most probably due to simple mistakes made while entering attributes. Let us see one very common case where a simple mistake can cause glaring issues:

We usually see the css given something like this. We do not see any glaring issue in the class defined below.

Drupal Tips: How to fix White Screen of Death (WSODs) on form submit

April 17, 2012 - 17:39

A white screen shows up while submitting a form in your Drupal Site?
There could be many possible causes for WSODs (White Screen of Death) in Drupal, such as PHP error reporting settings, memory exhaustion, etc. If the exact reason could be figured out, fixing becomes much easier.

For treating this specific WSOD issue on form submit, check for the following symptoms:

Simple steps to improve security on your Drupal site

To ensure the security of confidential data in your Drupal site, testing has to be done to determine whether it protects its data and at the same time maintains its functionality. Web applications are always prone to unauthorized access to or modification of sensitive information. The testing done on the applications to remove such anomalies is called security testing.

dpm() or dsm() - Which should you use?

Drupal’s Devel module provides a wide range of functionalities that make a Drupal developer’s life much saner. Of these, the most useful one is the function dpm() which seems to have a twin clone - dsm().

For those who are unaware, dpm() is a highly useful function for neatly printing (pretty printing) arrays/objects etc in drupal. There is also a function dsm() in the devel module, which seems to do the same thing.

Then which is the correct one?

Releasing the Drupal 7 version of uc_echecknet module

The UC eCheck.Net module is a Drupal module that implements eCheck payments using Authorize.Net's eCheck.Net service and is a popular module for online shopping websites using Drupal for making payments along with Ubercart. The module was officially released for Drupal 6. We have managed to release the updated version of UC eCheck.Net to work with Drupal 7 and is available for download.

How to prevent Drupal's .htaccess rewrite rule from redirecting mobile m._ urls to www.m._ urls

In a common secnario if a user types the url of a Drupal based website without the 'www'.prefix they will be automatically redirected to the  required site with the complete url. This is very convenient for most web users who do not want to type in the obvious 'www' prefix. Webmasters can configure this by changing the settings of the Drupal .htaccess file. However this will  be a problem if the Drupal site has a mobile version with an 'm.' prefix. Users wishing to access the mobile version of that Drupal site will inevitably be redirected to the main website.