Answers.Body: <p>It seems to be failing when Drupal is flushing its cache, and the error is related the Views integration of CiviCRM (in the Drupal registry).</p>
  
  <p>There can be various causes, but before digging deeper, I would try:</p>
  
  <ul>
  <li>moving the "views" code base from sites/all/modules/civicrm/drupal/module/views to somewhere outside your Drupal hierarchy,</li>
  <li>clear the Drupal cache</li>
  <li>upgrade the CiviCRM code, remove the Views directory again</li>
  <li>run the CiviCRM upgrade</li>
  </ul>
  
  <p>If all goes well, then move back the Views code and flush cache again, to see if it now works. If not, it will require debugging a bit more in details, perhaps old views data in the DB.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-26T06:11:23.323Z
Answers.Text: I have the same issue but not fixed with the above steps...
Answers.UserDisplayName: flik
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-09T15:02:40.357Z
Answers.LastActivityDate: 2016-06-09T15:02:40.357Z
Answers.UserDisplayName: bgm
Body: <p>I have been spinning my wheels all day trying to upgrade an old CiviCRM installation.  It was running 4.3.4, and I need to get it up to at least the latest 4.6.x.  This error has been dogging me the whole way:</p>
  
  <blockquote>
    <p>[Error: Finish Upgrade DB to 4.4.alpha1]
    PDOException: "SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'civicrm_handler_field_custom_file-class' for key 'PRIMARY'"  </p>
  </blockquote>
  
  <p>I've gone so far as to approach the upgrade in steps; upgrade to the latest 4.3, then 4.4, etc. after starting out trying to do the whole thing (to 4.6.15) in one fell swoop.  I did manage to get it upgraded in that way to 4.3.11, but trying to upgrade to 4.4.21 causes the error.</p>
  
  <p>Googling the error turned up this thread from the forum:
  <a href="https://forum.civicrm.org/index.php?topic=35976.0" rel="nofollow">https://forum.civicrm.org/index.php?topic=35976.0</a>
  so I tried the last suggestion of disabling/enabling CiviCRM beforehand but there was no improvement.  I also tried deleting rows in the registry and registry_files tables that reference civicrm_handler_field_custom_file but that didn't help either.</p>
  
  <p>Suggestions from anyone?</p>
  
  <p>Here's my whole stack trace:</p>
  
  <pre><code>[Error: Finish Upgrade DB to 4.4.alpha1] PDOException: "SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'civicrm_handler_field_custom_file-class' for key 'PRIMARY'"
  #0 /home/mydomain/domains/mydomain.net/public_html/includes/database/database.inc(2139): PDOStatement-&gt;execute((Array:5))
  #1 /home/mydomain/domains/mydomain.net/public_html/includes/database/database.inc(664): DatabaseStatementBase-&gt;execute((Array:5), (Array:4))
  #2 /home/mydomain/domains/mydomain.net/public_html/includes/database/mysql/query.inc(36): DatabaseConnection-&gt;query("INSERT INTO {registry} (name, type, filename, module, weight) VALUES (:db_ins...", (Array:5), (Array:2))
  #3 /home/mydomain/domains/mydomain.net/public_html/includes/registry.inc(179): InsertQuery_mysql-&gt;execute()
  #4 /home/mydomain/domains/mydomain.net/public_html/includes/registry.inc(144): _registry_parse_file("sites/all/modules/civicrm/drupal/modules/views/civicrm/civicrm_handler_field_...", "&lt;?php\n/*\n +----------------------------------------------------------------...", "civicrm", "100")
  #5 /home/mydomain/domains/mydomain.net/public_html/includes/registry.inc(82): _registry_parse_files((Array:180))
  #6 /home/mydomain/domains/mydomain.net/public_html/includes/bootstrap.inc(3076): _registry_update()
  #7 /home/mydomain/domains/mydomain.net/public_html/includes/bootstrap.inc(3062): registry_update()
  #8 /home/mydomain/domains/mydomain.net/public_html/includes/common.inc(7238): registry_rebuild()
  #9 /home/mydomain/domains/mydomain.net/public_html/sites/all/modules/civicrm/CRM/Utils/System/Drupal.php(991): drupal_flush_all_caches()
  #10 /home/mydomain/domains/mydomain.net/public_html/sites/all/modules/civicrm/CRM/Upgrade/Form.php(607): CRM_Utils_System_Drupal-&gt;flush()
  #11 [internal function](): CRM_Upgrade_Form::doIncrementalUpgradeFinish(Object(CRM_Queue_TaskContext), "4.4.alpha1", "4.3.11", "4.4.21", "/tmp/civicrm-post-upgrade7AnGtE")
  #12 /home/mydomain/domains/mydomain.net/public_html/sites/all/modules/civicrm/CRM/Queue/Task.php(79): call_user_func_array((Array:2), (Array:5))
  #13 /home/mydomain/domains/mydomain.net/public_html/sites/all/modules/civicrm/CRM/Queue/Runner.php(186): CRM_Queue_Task-&gt;run(Object(CRM_Queue_TaskContext))
  #14 /home/mydomain/domains/mydomain.net/public_html/sites/all/modules/civicrm/CRM/Queue/Page/AJAX.php(44): CRM_Queue_Runner-&gt;runNext(TRUE)
  #15 /home/mydomain/domains/mydomain.net/public_html/sites/all/modules/civicrm/CRM/Queue/ErrorPolicy.php(80): {closure}()
  #16 /home/mydomain/domains/mydomain.net/public_html/sites/all/modules/civicrm/CRM/Queue/Page/AJAX.php(47): CRM_Queue_ErrorPolicy-&gt;call(Object(Closure))
  #17 [internal function](): CRM_Queue_Page_AJAX::runNext((Array:5))
  #18 /home/mydomain/domains/mydomain.net/public_html/sites/all/modules/civicrm/CRM/Core/Invoke.php(293): call_user_func((Array:2), (Array:5))
  #19 /home/mydomain/domains/mydomain.net/public_html/sites/all/modules/civicrm/CRM/Core/Invoke.php(76): CRM_Core_Invoke::runItem((Array:13))
  #20 /home/mydomain/domains/mydomain.net/public_html/sites/all/modules/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:5))
  #21 /home/mydomain/domains/mydomain.net/public_html/sites/all/modules/civicrm/drupal/civicrm.module(484): CRM_Core_Invoke::invoke((Array:5))
  #22 [internal function](): civicrm_invoke("upgrade", "queue", "ajax", "runNext")
  #23 /home/mydomain/domains/mydomain.net/public_html/includes/menu.inc(517): call_user_func_array("civicrm_invoke", (Array:4))
  #24 /home/mydomain/domains/mydomain.net/public_html/index.php(21): menu_execute_active_handler()
  #25 {main}
  </code></pre>
  
Tags: <upgrade><4.6>
Title: Upgrading old version - Integrity constraint violation: 1062 Duplicate entry 'civicrm_handler_field_custom_file-class' for key 'PRIMARY'"
ThreadText: # Upgrading old version - Integrity constraint violation: 1062 Duplicate entry 'civicrm_handler_field_custom_file-class' for key 'PRIMARY'"
  
  (Asked by: username_0 on 2016-04-24)
  
  I have been spinning my wheels all day trying to upgrade an old CiviCRM installation. It was running 4.3.4, and I need to get it up to at least the latest 4.6.x. This error has been dogging me the whole way:
  
  > [Error: Finish Upgrade DB to 4.4.alpha1]
  > PDOException: "SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'civicrm\_handler\_field\_custom\_file-class' for key 'PRIMARY'"
  
  I've gone so far as to approach the upgrade in steps; upgrade to the latest 4.3, then 4.4, etc. after starting out trying to do the whole thing (to 4.6.15) in one fell swoop. I did manage to get it upgraded in that way to 4.3.11, but trying to upgrade to 4.4.21 causes the error.
  
  Googling the error turned up this thread from the forum:
  <https://forum.civicrm.org/index.php?topic=35976.0>
  so I tried the last suggestion of disabling/enabling CiviCRM beforehand but there was no improvement. I also tried deleting rows in the registry and registry\_files tables that reference civicrm\_handler\_field\_custom\_file but that didn't help either.
  
  Suggestions from anyone?
  
  Here's my whole stack trace:
  
  ```
  [Error: Finish Upgrade DB to 4.4.alpha1] PDOException: "SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'civicrm_handler_field_custom_file-class' for key 'PRIMARY'"
  #0 /home/mydomain/domains/mydomain.net/public_html/includes/database/database.inc(2139): PDOStatement->execute((Array:5))
  #1 /home/mydomain/domains/mydomain.net/public_html/includes/database/database.inc(664): DatabaseStatementBase->execute((Array:5), (Array:4))
  #2 /home/mydomain/domains/mydomain.net/public_html/includes/database/mysql/query.inc(36): DatabaseConnection->query("INSERT INTO {registry} (name, type, filename, module, weight) VALUES (:db_ins...", (Array:5), (Array:2))
  #3 /home/mydomain/domains/mydomain.net/public_html/includes/registry.inc(179): InsertQuery_mysql->execute()
  #4 /home/mydomain/domains/mydomain.net/public_html/includes/registry.inc(144): _registry_parse_file("sites/all/modules/civicrm/drupal/modules/views/civicrm/civicrm_handler_field_...", "<?php\n/*\n +----------------------------------------------------------------...", "civicrm", "100")
  #5 /home/mydomain/domains/mydomain.net/public_html/includes/registry.inc(82): _registry_parse_files((Array:180))
  #6 /home/mydomain/domains/mydomain.net/public_html/includes/bootstrap.inc(3076): _registry_update()
  #7 /home/mydomain/domains/mydomain.net/public_html/includes/bootstrap.inc(3062): registry_update()
  #8 /home/mydomain/domains/mydomain.net/public_html/includes/common.inc(7238): registry_rebuild()
  #9 /home/mydomain/domains/mydomain.net/public_html/sites/all/modules/civicrm/CRM/Utils/System/Drupal.php(991): drupal_flush_all_caches()
  #10 /home/mydomain/domains/mydomain.net/public_html/sites/all/modules/civicrm/CRM/Upgrade/Form.php(607): CRM_Utils_System_Drupal->flush()
  #11 [internal function](): CRM_Upgrade_Form::doIncrementalUpgradeFinish(Object(CRM_Queue_TaskContext), "4.4.alpha1", "4.3.11", "4.4.21", "/tmp/civicrm-post-upgrade7AnGtE")
  #12 /home/mydomain/domains/mydomain.net/public_html/sites/all/modules/civicrm/CRM/Queue/Task.php(79): call_user_func_array((Array:2), (Array:5))
  #13 /home/mydomain/domains/mydomain.net/public_html/sites/all/modules/civicrm/CRM/Queue/Runner.php(186): CRM_Queue_Task->run(Object(CRM_Queue_TaskContext))
  #14 /home/mydomain/domains/mydomain.net/public_html/sites/all/modules/civicrm/CRM/Queue/Page/AJAX.php(44): CRM_Queue_Runner->runNext(TRUE)
  #15 /home/mydomain/domains/mydomain.net/public_html/sites/all/modules/civicrm/CRM/Queue/ErrorPolicy.php(80): {closure}()
  #16 /home/mydomain/domains/mydomain.net/public_html/sites/all/modules/civicrm/CRM/Queue/Page/AJAX.php(47): CRM_Queue_ErrorPolicy->call(Object(Closure))
  #17 [internal function](): CRM_Queue_Page_AJAX::runNext((Array:5))
  #18 /home/mydomain/domains/mydomain.net/public_html/sites/all/modules/civicrm/CRM/Core/Invoke.php(293): call_user_func((Array:2), (Array:5))
  #19 /home/mydomain/domains/mydomain.net/public_html/sites/all/modules/civicrm/CRM/Core/Invoke.php(76): CRM_Core_Invoke::runItem((Array:13))
  #20 /home/mydomain/domains/mydomain.net/public_html/sites/all/modules/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:5))
  #21 /home/mydomain/domains/mydomain.net/public_html/sites/all/modules/civicrm/drupal/civicrm.module(484): CRM_Core_Invoke::invoke((Array:5))
  #22 [internal function](): civicrm_invoke("upgrade", "queue", "ajax", "runNext")
  #23 /home/mydomain/domains/mydomain.net/public_html/includes/menu.inc(517): call_user_func_array("civicrm_invoke", (Array:4))
  #24 /home/mydomain/domains/mydomain.net/public_html/index.php(21): menu_execute_active_handler()
  #25 {main}
  
  ```
  
  **Tags:** upgrade, 4.6
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-06-09. Score: 1
  
  It seems to be failing when Drupal is flushing its cache, and the error is related the Views integration of CiviCRM (in the Drupal registry).
  
  There can be various causes, but before digging deeper, I would try:
  
  * moving the "views" code base from sites/all/modules/civicrm/drupal/module/views to somewhere outside your Drupal hierarchy,
  * clear the Drupal cache
  * upgrade the CiviCRM code, remove the Views directory again
  * run the CiviCRM upgrade
  
  If all goes well, then move back the Views code and flush cache again, to see if it now works. If not, it will require debugging a bit more in details, perhaps old views data in the DB.
  
  > **Comments:**
  > **username_2**: I have the same issue but not fixed with the above steps...  
  
  ---
  
  