What location aliasses are available for drush rsync

What are the values for drush rsync in %notation?

drush @site.prd php-eval "return _core_path_aliases()"
  '%root' => '/home/login2/ctcn-public.mijnlieff.nl',
  '%site' => 'sites/default',
  '%modules' => 'sites/all/modules',
  '%themes' => 'sites/all/themes',
  '%files' => 'sites/default/files',
  '%private' => 'sites/default/files/private',
  '%temp' => '/tmp',

fetch json and pretty print


While working on Deploy RestWS for D7 project issue JSON I needed a pretty print for the node.json and scanner done for Drush Issue Queue Commands Fix for the new json structure on d.o D7. Both issues as still open so help needed.

Doing some research I learned about the PHP context or more specific the HTTP stream context

Can you dig it. Drupal nested array that is.

Spade Large

I sometime need to check arrays for their values dispersed around. Just dumping the array is OK when interested in a particular key or value. But what about those big info arrays from hook_token_info, hook_menu etc. This is what I did.

Drush entity support (patch needs review)

Can you tell the field display weights of all your entities with one command? Or edit a node through the command-line?
drush --yaml entity-type-read node --fields=**/display/**/weight --include-fieldapi
drush entity-update node 12 --json
Watch the video on http://www.youtube.com/watch?v=cVGZzWjdDh8 and get convinced you want to know more of these entity internals.

Upgrade from D6 in 7 steps? Hell no!!!

Sooo ... I've finally upgraded my own site. I thought it would be easy. A simple drupal site only using images. And yes I'm not reading READMEs that often. I trust drush somehow to handle this for me. But drush only sooth the 'pain'. This blog contains my bash script which does some staging from production onto my laptop where I update the site to the latest D6 then upgrade to D7. The script is generic enough to adapt for other upgrades.

How to get that site on localhost?

drush logo

Make sure you have your drush aliases file setup properly. Below a snippet from my b2b.aliases.drushrc.php

$aliases['dev'] = array(
  'uri' => 'http://build2be.dev',  'root' => '/Users/clemens/Sites/build2be.dev/www/',
  'path-aliases' => array(
    '%dump-dir' => '/Users/clemens/Sites/build2be.dev/store',
    '%files' => '/Users/clemens/Sites/build2be.dev/www/sites/build2be.dev/files',

Now we can run

drush rsync @b2b.prd @b2b.dev

update module with a twist

I just did an upgrade from the calendar and date module of which calendar needed to move from 6.x-2.x-dev to 6.x-2.4 version which seemed a pitb exercise. I hope I missed some skills :-p

The following command was not working

drush upc calendar-6.x-2.4

So what I did was download the latest version offsite. Then diff the module trees.

cd /tmp
drush dl calendar-6.x-2.4
cd /my-site/sites/all/modules/calendar
cp -r /tmp/calendar/* ./

Who is currently online

I want to run

svn up
on the site but I need to offline it first. So who is online?

SELECT name, mail, (unix_timestamp()-access)/3600 AS hours
  FROM users
  HAVING hours < 1
  ORDER BY access;

Or for short

drush sql-query "select name, mail, (unix_timestamp()-access)/3600 as hours from users having hours < 1 order by access;"

Using cron to update a site and prepare the backup

For a site on my VM I needed an

svn sync
and the backup files on my developer site.

I initially didn't want to install backup_migrate module. This was partly due to my arcane workflow which is of course by hand and unfamiliarity with back_migrate module.

So this is what I deviced

test_site@serverVM:~$ crontab -l
# m h  dom mon dow   command
*/7 * * * * wget -O - -q -t 1 http://test-site.com/cron.php
*/5 * * * * /home/test_site/svn-up 2>&1 > /home/test_site/svn-up.log
* */1 * * * /home/test_site/ant-backup 2>&1 > /home/test_site/ant-backup.log

Temporary Securing Drupal through Basic Auth in settings.php

We needed to protect our production site from prying eyes for a while with a basic authentication. Using apache basic auth settings seemed not enough. Or actually was too much. We wanted the theme to blend in. So these files were not supposed to get protected. Only our Drupal pages should.

The solution came from http://php.net/manual/en/features.http-auth.php. Adding the following to sites/default/settings.php makes the customer happy and drush too.

$username = 'user';
$password = 'pass';