veda-consulting-company / uk.co.vedaconsulting.outlookapi

Other
4 stars 18 forks source link

"processattachments" API call results in high-severity errors in log #67

Open MegaphoneJon opened 5 years ago

MegaphoneJon commented 5 years ago

Whenever the processattachments action is called I get this in my error logs:

a:6:{s:5:"%type";s:23:"Recoverable fatal error";s:8:"@message";O:25:"Drupal\Core\Render\Markup":1:{s:9:" * string";s:72:"Object of class CRM_Core_DAO_EntityFile could not be converted to string";}s:9:"%function";s:28:"CRM_Utils_Array::escapeXML()";s:5:"%file";s:69:"/var/www/mysite.org/vendor/civicrm/civicrm-core/CRM/Utils/Array.php";s:5:"%line";i:178;s:17:"@backtrace_string";s:957:"#0 /var/www/mysite.org/web/core/includes/bootstrap.inc(587): _drupal_error_handler_real(4096, 'Object of class...', '/var/www/mys...', 178, Array)                                                                              
#1 [internal function]: _drupal_error_handler(4096, 'Object of class...', '/var/www/crm.ag...', 178, Array)
#2 /var/www/mysite.org/vendor/civicrm/civicrm-core/CRM/Utils/Array.php(178): str_replace(Array, Array, Object(CRM_Core_DAO_EntityFile))                                                                                                    
#3 /var/www/mysite.org/vendor/civicrm/civicrm-core/CRM/Utils/Array.php(150): CRM_Utils_Array::escapeXML(Object(CRM_Core_DAO_EntityFile))                                                                                                   
#4 /var/www/mysite.org/vendor/civicrm/civicrm-core/CRM/Utils/REST.php(180): CRM_Utils_Array::xml(Array)
#5 /var/www/mysite.org/vendor/civicrm/civicrm-core/CRM/Utils/REST.php(107): CRM_Utils_REST::output(Array)
#6 /var/www/mysite.org/vendor/civicrm/civicrm-core/CRM/Utils/REST.php(118): CRM_Utils_REST->run()
#7 /var/www/mysite.org/web/libraries/civicrm/extern/rest.php(41): CRM_Utils_REST->bootAndRun()
#8 {main}";}

I don't have Outlook so I can't easily replicate this for testing, but it seems like the fix is to change the return line to cast the object to an array, because otherwise you're trying to return an object as XML. E.g.:

  return civicrm_api3_create_success((array) $entityFileDAO, $params);