Fix for CRM-15750 advanced search using relationship and smart group pro...

...duces backtrace https://issues.civicrm.org/jira/browse/CRM-15750