2

We upgrade recently from 4.5.8 to 4.6.6 on four of our CiviCRM instances.

In one of the instances ocurrs something very strange and compromising. When we create a new mailing, in the attachment tab appears one/two random files uploaded previously to event custom fields.

However if we try to delete the attached file/s we get the following error:

"Failed to run permission check: Unrecognized target entity table (civicrm_participant)"

Why they appear if they have no connection with the mailings?

Edit: Screenshot

enter image description here

3

I think I've found the cause. Check out bug CRM-16544, it matches your problem exactly (except theirs was Grant and yours is Event). I think we can fix this by adding civicrm_event to the array on line 210 of Container.php, but I'm not familiar enough with the Symfony stuff to be sure. I think your best bet is to file a bug.

| improve this answer | |
  • Thanks, Nicholai! It really looks like the problem we have. However, adding civicrm_event to the array on line 210 of Container.php seems it's not enough. We try also without luck with civicrm_participant and civicrm_value_inscripci__14 that is the entity table of the custom file field in question. – Francesc Bassas i Bullich Aug 26 '15 at 17:16
2

We found a workaround solution. It seems that is a bug in Attachment.php API file.

Original code

315: foreach ($entityFile as $key => $value) {
316:   $select->where('cef.!field = @value', array(
317:     '!field' => $key,

Workaround solution

315: foreach ($entityFile as $key => $value) {
316:   $select->where('cef.!field'.$key.' = @value', array(
317:     '!field'.$key => $key,

Seems that if there is more than one $entityFile element, then where clause is generated wrongly.

| improve this answer | |
  • So where() currently tries to dedupe redundant clauses by using ->wheres[$expr], and it erroneously treats two clauses ("cef.entity_table == 'foo'" and "cef.entity_id=123") as duplicates. The dedupe key should prob be post-interpolation rather than pre-interpolation. – Tim Otten Aug 30 '15 at 23:12
  • 1
    Well, I like this patch better than the others -- it seems closer to the root cause. I've drafted a similar/alternative which I think gets at the cause github.com/civicrm/civicrm-core/pull/6644 . Could you see if it fixes the problem for you? – Tim Otten Sep 1 '15 at 1:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.