Answers.Body: <p>This is fixed in 5.9.1 ............</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-17T08:18:30.263Z
Answers.LastActivityDate: 2019-01-17T08:18:30.263Z
Answers.UserDisplayName: user4278
Answers.Body: <p>This is a core bug and Eileen has send a <a href="https://github.com/civicrm/civicrm-core/pull/13451" rel="noreferrer">PR</a> for the fix. Will you be able to try by applying the patch from <a href="https://patch-diff.githubusercontent.com/raw/civicrm/civicrm-core/pull/13451.patch" rel="noreferrer">here</a>? </p>
  
  <p>If the patch works for you than please comment your test result on PR so that it will speed up process of merging into core and having it available in next release.</p>
  
  <p>Cheers</p>
  
  <p>Pradeep</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-16T20:58:25.980Z
Answers.Text: Thanks alot Pradeep, that solves the issue. I've commented on the PR.
Answers.UserDisplayName: Nic
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-16T20:28:14.570Z
Answers.LastActivityDate: 2019-01-16T20:28:14.570Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>I upgraded two Joomla sites from 5.8.x to 5.9 and one of them now gives an error for anonymous contributions or membership registrations:</p>
  
  <p>Error:</p>
  
  <pre><code>Database Error Code: Cannot add or update a child row: a foreign key constraint fails (`zzz`.`civicrm_acl_contact_cache`, CONSTRAINT `FK_civicrm_acl_contact_cache_user_id` FOREIGN KEY (`user_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE CASCADE), 1452
  </code></pre>
  
  <p>Additional Details:</p>
  
  <p>Array
  (
      [callback] => Array
          (
              [0] => CRM_Core_Error
              [1] => handle
          )</p>
  
  <pre><code>[code] =&gt; -3
  [message] =&gt; DB Error: constraint violation
  [mode] =&gt; 16
  [debug_info] =&gt; INSERT INTO civicrm_acl_contact_cache ( user_id, contact_id, operation ) VALUES(0, 0, 'View') [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`zzz`.`civicrm_acl_contact_cache`, CONSTRAINT `FK_civicrm_acl_contact_cache_user_id` FOREIGN KEY (`user_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE CASCADE)]
  [type] =&gt; DB_Error
  [user_info] =&gt; INSERT INTO civicrm_acl_contact_cache ( user_id, contact_id, operation ) VALUES(0, 0, 'View') [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`zzz`.`civicrm_acl_contact_cache`, CONSTRAINT `FK_civicrm_acl_contact_cache_user_id` FOREIGN KEY (`user_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE CASCADE)]
  [to_string] =&gt; [db_error: message="DB Error: constraint violation" code=-3 mode=callback callback=CRM_Core_Error::handle prefix="" info="INSERT INTO civicrm_acl_contact_cache ( user_id, contact_id, operation ) VALUES(0, 0, 'View') [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`zzz`.`civicrm_acl_contact_cache`, CONSTRAINT `FK_civicrm_acl_contact_cache_user_id` FOREIGN KEY (`user_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE CASCADE)]"]
  </code></pre>
  
  <p>)</p>
  
  <p>This matches a similar issue after 5.9.0 upgrade: <a href="https://civicrm.stackexchange.com/questions/28002/db-error-constraint-violation-on-anonymous-user-event-registration-after-5-8-2/28095#28095">DB Error: constraint violation on anonymous user event registration after 5.8.2 -&gt; 5.9.0 update</a></p>
  
  <p>I have Mail enabled. The error doesn't occur when logged in so I've matched and then enabled more permissions than the other site which works, but it makes no difference.</p>
  
Tags: <joomla><error><acl><upgrade>
Title: DB Error: constraint violation on anonymous user contribution/membership registration after 5.8.2 -> 5.9.0 update
ThreadText: # DB Error: constraint violation on anonymous user contribution/membership registration after 5.8.2 -> 5.9.0 update
  
  (Asked by: username_0 on 2019-01-16)
  
  I upgraded two Joomla sites from 5.8.x to 5.9 and one of them now gives an error for anonymous contributions or membership registrations:
  
  Error:
  
  ```
  Database Error Code: Cannot add or update a child row: a foreign key constraint fails (`zzz`.`civicrm_acl_contact_cache`, CONSTRAINT `FK_civicrm_acl_contact_cache_user_id` FOREIGN KEY (`user_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE CASCADE), 1452
  
  ```
  
  Additional Details:
  
  Array
  (
  [callback] => Array
  (
  [0] => CRM\_Core\_Error
  [1] => handle
  )
  
  ```
  [code] => -3
  [message] => DB Error: constraint violation
  [mode] => 16
  [debug_info] => INSERT INTO civicrm_acl_contact_cache ( user_id, contact_id, operation ) VALUES(0, 0, 'View') [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`zzz`.`civicrm_acl_contact_cache`, CONSTRAINT `FK_civicrm_acl_contact_cache_user_id` FOREIGN KEY (`user_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE CASCADE)]
  [type] => DB_Error
  [user_info] => INSERT INTO civicrm_acl_contact_cache ( user_id, contact_id, operation ) VALUES(0, 0, 'View') [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`zzz`.`civicrm_acl_contact_cache`, CONSTRAINT `FK_civicrm_acl_contact_cache_user_id` FOREIGN KEY (`user_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE CASCADE)]
  [to_string] => [db_error: message="DB Error: constraint violation" code=-3 mode=callback callback=CRM_Core_Error::handle prefix="" info="INSERT INTO civicrm_acl_contact_cache ( user_id, contact_id, operation ) VALUES(0, 0, 'View') [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`zzz`.`civicrm_acl_contact_cache`, CONSTRAINT `FK_civicrm_acl_contact_cache_user_id` FOREIGN KEY (`user_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE CASCADE)]"]
  
  ```
  
  )
  
  This matches a similar issue after 5.9.0 upgrade: [DB Error: constraint violation on anonymous user event registration after 5.8.2 -> 5.9.0 update](https://civicrm.stackexchange.com/questions/28002/db-error-constraint-violation-on-anonymous-user-event-registration-after-5-8-2/28095#28095)
  
  I have Mail enabled. The error doesn't occur when logged in so I've matched and then enabled more permissions than the other site which works, but it makes no difference.
  
  **Tags:** joomla, error, acl, upgrade
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2019-01-16. Score: 4 | Accepted answer
  
  This is a core bug and Eileen has send a [PR](https://github.com/civicrm/civicrm-core/pull/13451) for the fix. Will you be able to try by applying the patch from [here](https://patch-diff.githubusercontent.com/raw/civicrm/civicrm-core/pull/13451.patch)?
  
  If the patch works for you than please comment your test result on PR so that it will speed up process of merging into core and having it available in next release.
  
  Cheers
  
  username_2
  
  > **Comments:**
  > **username_0**: Thanks alot username_2, that solves the issue. I've commented on the PR.  
  
  ---
  
  ### Answer by username_1 on 2019-01-17. Score: 0
  
  This is fixed in 5.9.1 ............
  
  
  ---
  
  