Answers.Body: <p>There are orphan data in civicrm_mailing_job table. Below query should return you the count</p>
  <pre><code>SELECT count(*)
  FROM civicrm_mailing_job j
    LEFT JOIN civicrm_mailing m
      ON m.id = j.mailing_id
  WHERE m.id IS NULL;
  </code></pre>
  <p>To delete you can use</p>
  <pre><code>DELETE j.*
      FROM civicrm_mailing_job j
        LEFT JOIN civicrm_mailing m
          ON m.id = j.mailing_id
      WHERE m.id IS NULL;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-11-03T10:22:25.693Z
Answers.LastActivityDate: 2023-11-03T10:22:25.693Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>Following up the php 8.1 issue  <em><strong>PHP Fatal error:  Uncaught IntlException: datefmt_create: invalid locale: U_ILLEGAL_ARGUMENT_ERROR</strong></em> have tried to jump to the latest 5.67.0 and got the one below, sticking with the &quot;5.67.alpha1&quot; version.</p>
  <pre><code>UPDATE civicrm_mailing_event_queue q INNER JOIN civicrm_mailing_job job ON job.id =
   q.job_id SET q.mailing_id = job.mailing_id, q.is_test=job.is_test 
  WHERE q.id &gt;= 1000006 AND q.id &lt;= 1500005 AND q.mailing_id IS NULL 
  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails
   (`civicrm_prod`.`civicrm_mailing_event_queue`, CONSTRAINT    
   `civicrm_mailing_event_queue_ibfk_1` FOREIGN KEY (`mailing_id`) REFERENCES 
  `civicrm_mailing` (`id`) ON DELETE SET NULL)]
  </code></pre>
  <p>Checking for records violating the constraint returned zero results
  SELECT * FROM civicrm_mailing_event_queue q
  WHERE q.mailing_id IS NULL
  AND q.mailing_id NOT IN (SELECT id FROM civicrm_mailing);</p>
  <p>Temporary workaround is to run the query manually with the &quot;Enable foreign key checks&quot; disabled, however this might be not quite right.
  Anyone else having the same luck? Any word of advice please? Thanks.</p>
  
Tags: <wordpress><upgrade>
Title: Mailing event queue error when upgrading from CiviCRM 5.66 to 5.67
ThreadText: # Mailing event queue error when upgrading from CiviCRM 5.66 to 5.67
  
  (Asked by: username_0 on 2023-11-02)
  
  Following up the php 8.1 issue ***PHP Fatal error: Uncaught IntlException: datefmt\_create: invalid locale: U\_ILLEGAL\_ARGUMENT\_ERROR*** have tried to jump to the latest 5.67.0 and got the one below, sticking with the "5.67.alpha1" version.
  
  ```
  UPDATE civicrm_mailing_event_queue q INNER JOIN civicrm_mailing_job job ON job.id =
   q.job_id SET q.mailing_id = job.mailing_id, q.is_test=job.is_test 
  WHERE q.id >= 1000006 AND q.id <= 1500005 AND q.mailing_id IS NULL 
  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails
   (`civicrm_prod`.`civicrm_mailing_event_queue`, CONSTRAINT    
   `civicrm_mailing_event_queue_ibfk_1` FOREIGN KEY (`mailing_id`) REFERENCES 
  `civicrm_mailing` (`id`) ON DELETE SET NULL)]
  
  ```
  
  Checking for records violating the constraint returned zero results
  SELECT \* FROM civicrm\_mailing\_event\_queue q
  WHERE q.mailing\_id IS NULL
  AND q.mailing\_id NOT IN (SELECT id FROM civicrm\_mailing);
  
  Temporary workaround is to run the query manually with the "Enable foreign key checks" disabled, however this might be not quite right.
  Anyone else having the same luck? Any word of advice please? Thanks.
  
  **Tags:** wordpress, upgrade
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-11-03. Score: 5 | Accepted answer
  
  There are orphan data in civicrm\_mailing\_job table. Below query should return you the count
  
  ```
  SELECT count(*)
  FROM civicrm_mailing_job j
    LEFT JOIN civicrm_mailing m
      ON m.id = j.mailing_id
  WHERE m.id IS NULL;
  
  ```
  
  To delete you can use
  
  ```
  DELETE j.*
      FROM civicrm_mailing_job j
        LEFT JOIN civicrm_mailing m
          ON m.id = j.mailing_id
      WHERE m.id IS NULL;
  
  ```
  
  
  ---
  
  