fix CRM-11994 and also a bunch of php 5.4 notices

Note that all the nice white space removal is done automatically by my friendly editor :)