CRM-12613 - Forward port REST.php

This file had been held back from normal merge-forward due to
merge-conflicts.  Investigating upstream/master, it seems that there were
two changes that may have been source of conflict:

 * 2ede60ec - This is formatting change and a bad-commit of a debug code
 * c5f77b41 - This is a real functional change but was backported (and
   further fixed) in 4.3, so 4.3's version is better.

----------------------------------------
* CRM-12613: Resolve merge of REST.php (4.3=>master)
  http://issues.civicrm.org/jira/browse/CRM-12613
Merge pull request #773 from totten/merge-rest

CRM-12613 - Forward port REST.php