APIエラー:DB制約違反 – domain_idがDashboardの必須項目としてマークされ、APIを作成する必要があります。もしそうなら、バグレポートを提出してください

私は、WordPress 4.9.5でCiviCRM
5.0.0を実行しており、(検証画面の後に)拡張機能をアクティブ/非アクティブにしようとするたびに、またはCiviCRMのWordPress
Access
Controlパネルを検証するたびに、DB制約違反が発生します。エラーメッセージが表示されたにもかかわらず、必要なアクションは完了しています。

これは、ある月以降存在するエラーであるため、いくつかのリリース(私はいつ正確に覚えていない)です。

詳細なエラーメッセージ:

Apr 18 00:12:41  [info] $Fatal Error Details = Array
(
    [callback] => Array
        (
            [0] => CRM_Core_Error
            [1] => exceptionHandler
        )

    [code] => -3
    [message] => DB Error: constraint violation
    [mode] => 16
    [debug_info] =>
                  INSERT INTO civicrm_dashboard_contact ( dashboard_id, contact_id )
                  VALUES  ( 7, 2 ), ( 7, 9 ), ( 7, 10 ), ( 7, 12 ), ( 7, 13 ), ( 7, 19 ), ( 7, 20 ), ( 7, 21 ), ( 7, 22 ), ( 7, 31 ), ( 7, 36 ), ( 7, 39 ), ( 7, 76 ) [nativecode=1452 ** Cannot add or update a child row: a foreign key const
raint fails (`aquaparismcivi`.`civicrm_dashboard_contact`, CONSTRAINT `FK_civicrm_dashboard_contact_dashboard_id` FOREIGN KEY (`dashboard_id`) REFERENCES `civicrm_dashboard` (`id`) ON DELETE CASCADE)]
    [type] => DB_Error
    [user_info] =>
                  INSERT INTO civicrm_dashboard_contact ( dashboard_id, contact_id )
                  VALUES  ( 7, 2 ), ( 7, 9 ), ( 7, 10 ), ( 7, 12 ), ( 7, 13 ), ( 7, 19 ), ( 7, 20 ), ( 7, 21 ), ( 7, 22 ), ( 7, 31 ), ( 7, 36 ), ( 7, 39 ), ( 7, 76 ) [nativecode=1452 ** Cannot add or update a child row: a foreign key const
raint fails (`aquaparismcivi`.`civicrm_dashboard_contact`, CONSTRAINT `FK_civicrm_dashboard_contact_dashboard_id` FOREIGN KEY (`dashboard_id`) REFERENCES `civicrm_dashboard` (`id`) ON DELETE CASCADE)]
    [to_string] => [db_error: message="DB Error: constraint violation" code=-3 mode=callback callback=CRM_Core_Error::exceptionHandler prefix="" info="
                  INSERT INTO civicrm_dashboard_contact ( dashboard_id, contact_id )
                  VALUES  ( 7, 2 ), ( 7, 9 ), ( 7, 10 ), ( 7, 12 ), ( 7, 13 ), ( 7, 19 ), ( 7, 20 ), ( 7, 21 ), ( 7, 22 ), ( 7, 31 ), ( 7, 36 ), ( 7, 39 ), ( 7, 76 ) [nativecode=1452 ** Cannot add or update a child row: a foreign key const
raint fails (`aquaparismcivi`.`civicrm_dashboard_contact`, CONSTRAINT `FK_civicrm_dashboard_contact_dashboard_id` FOREIGN KEY (`dashboard_id`) REFERENCES `civicrm_dashboard` (`id`) ON DELETE CASCADE)]"]
)

トレース

Apr 18 00:12:41  [info] $backTrace = #0 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/CRM/Core/Error.php(948): CRM_Core_Error::backtrace("backTrace", TRUE)
#1 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/packages/PEAR.php(921): CRM_Core_Error::exceptionHandler(Object(DB_Error))
#2 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/packages/DB.php(985): PEAR_Error->__construct("DB Error: constraint violation", -3, 16, (Array:2), "n                  INSERT INTO civicrm_dashboard_contact ( dashboard_id, con...
")
#3 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/packages/PEAR.php(575): DB_Error->__construct(-3, 16, (Array:2), "n                  INSERT INTO civicrm_dashboard_contact ( dashboard_id, con...")
#4 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/packages/PEAR.php(223): PEAR->_raiseError(Object(DB_mysqli), NULL, -3, 16, (Array:2), "n                  INSERT INTO civicrm_dashboard_contact ( dashboard_id, con...", "DB_Error"
, TRUE)
#5 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/packages/DB/common.php(1905): PEAR->__call("raiseError", (Array:7))
#6 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/packages/DB/mysqli.php(933): DB_common->raiseError(-3, NULL, NULL, "n                  INSERT INTO civicrm_dashboard_contact ( dashboard_id, con...", "1452 ** Cannot add or update
 a child row: a foreign key constraint fails (`aq...")
#7 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/packages/DB/mysqli.php(403): DB_mysqli->mysqliRaiseError()
#8 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/packages/DB/common.php(1216): DB_mysqli->simpleQuery("n                  INSERT INTO civicrm_dashboard_contact ( dashboard_id, con...")
#9 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php(2446): DB_common->query("n                  INSERT INTO civicrm_dashboard_contact ( dashboard_id, con...")
#10 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php(1635): DB_DataObject->_query("n                  INSERT INTO civicrm_dashboard_contact ( dashboard_id, con...")
#11 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php(392): DB_DataObject->query("n                  INSERT INTO civicrm_dashboard_contact ( dashboard_id, con...")
#12 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php(1348): CRM_Core_DAO->query("n                  INSERT INTO civicrm_dashboard_contact ( dashboard_id, con...", TRUE)
#13 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/CRM/Core/BAO/Dashboard.php(467): CRM_Core_DAO::executeQuery("n                  INSERT INTO civicrm_dashboard_contact ( dashboard_id, con...")
#14 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/CRM/Core/BAO/Dashboard.php(416): CRM_Core_BAO_Dashboard::addContactDashlet(Object(CRM_Core_DAO_Dashboard))
#15 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/CRM/Core/BAO/Dashboard.php(50): CRM_Core_BAO_Dashboard::addDashlet((Array:3))
#16 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/api/v3/utils.php(1288): CRM_Core_BAO_Dashboard::create((Array:3), (Array:1))
#17 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/api/v3/Dashboard.php(51): _civicrm_api3_basic_create("CRM_Core_BAO_Dashboard", (Array:3), "Dashboard")
#18 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/Civi/API/Provider/MagicFunctionProvider.php(89): civicrm_api3_dashboard_create((Array:3))
#19 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/Civi/API/Kernel.php(169): CiviAPIProviderMagicFunctionProvider->invoke((Array:9))
#20 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/Civi/API/Kernel.php(100): CiviAPIKernel->runRequest((Array:9))
#21 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/api/api.php(23): CiviAPIKernel->runSafe("Dashboard", "create", (Array:3), NULL)
#22 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/CRM/Core/ManagedEntities.php(290): civicrm_api("Dashboard", "create", (Array:3))
#23 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/CRM/Core/ManagedEntities.php(196): CRM_Core_ManagedEntities->disableEntity(Object(CRM_Core_DAO_Managed))
#24 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/CRM/Core/ManagedEntities.php(123): CRM_Core_ManagedEntities->reconcileDisabledModules()
#25 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(395): CRM_Core_ManagedEntities->reconcile()
#26 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/CRM/Extension/Manager.php(252): CRM_Core_Invoke::rebuildMenuAndCaches(TRUE)
#27 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/CRM/Extension/Manager.php(289): CRM_Extension_Manager->install((Array:1))
#28 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/api/v3/Extension.php(135): CRM_Extension_Manager->enable((Array:1))
#29 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/Civi/API/Provider/MagicFunctionProvider.php(89): civicrm_api3_extension_enable((Array:2))
#30 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/Civi/API/Kernel.php(169): CiviAPIProviderMagicFunctionProvider->invoke((Array:9))
#31 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/Civi/API/Kernel.php(100): CiviAPIKernel->runRequest((Array:9))
#32 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/api/api.php(43): CiviAPIKernel->runSafe("Extension", "enable", (Array:2))
#33 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/CRM/Admin/Form/Extensions.php(195): civicrm_api3("Extension", "enable", (Array:2))
#34 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/CRM/Core/Form.php(447): CRM_Admin_Form_Extensions->postProcess()
#35 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/CRM/Core/StateMachine.php(160): CRM_Core_Form->mainProcess()
#36 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/CRM/Core/QuickForm/Action/Next.php(61): CRM_Core_StateMachine->perform(Object(CRM_Admin_Form_Extensions), "next", "Next")
#37 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Next->perform(Object(CRM_Admin_Form_Extensions), "next")
#38 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller->handle(Object(CRM_Admin_Form_Extensions), "next")
#39 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/CRM/Core/Controller.php(351): HTML_QuickForm_Page->handle("next")
#40 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/CRM/Core/Page/Basic.php(398): CRM_Core_Controller->run()
#41 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/CRM/Core/Page/Basic.php(156): CRM_Core_Page_Basic->edit(32, NULL)
#42 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/CRM/Admin/Page/Extensions.php(121): CRM_Core_Page_Basic->run()
#43 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(309): CRM_Admin_Page_Extensions->run((Array:3), NULL)
#44 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(84): CRM_Core_Invoke::runItem((Array:16))
#45 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:3))
#46 /home/aquaparism/www/wp-content/plugins/civicrm/civicrm.php(1246): CRM_Core_Invoke::invoke((Array:3))
#47 /home/aquaparism/www/wp-includes/class-wp-hook.php(286): CiviCRM_For_WordPress->invoke("")
#48 /home/aquaparism/www/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters("", (Array:1))
#49 /home/aquaparism/www/wp-includes/plugin.php(453): WP_Hook->do_action((Array:1))
#50 /home/aquaparism/www/wp-admin/admin.php(224): do_action("toplevel_page_CiviCRM")
#51 {main}

同時に2番目のエラーが発生します。

Apr 18 00:12:41  [info] $ManagedEntities_failed = Array
(
    [entity] => Dashboard
    [action] => create
    [params] => Array
        (
            [version] => 3
            [id] => 7
            [is_active] => 0
        )

    [result] => Array
        (
            [error_code] => constraint violation
            [sql] =>
                  INSERT INTO civicrm_dashboard_contact ( dashboard_id, contact_id )
                  VALUES  ( 7, 2 ), ( 7, 9 ), ( 7, 10 ), ( 7, 12 ), ( 7, 13 ), ( 7, 19 ), ( 7, 20 ), ( 7, 21 ), ( 7, 22 ), ( 7, 31 ), ( 7, 36 ), ( 7, 39 ), ( 7, 76 ) [nativecode=1452 ** Cannot add or update a child row: a foreign key const
raint fails (`aquaparismcivi`.`civicrm_dashboard_contact`, CONSTRAINT `FK_civicrm_dashboard_contact_dashboard_id` FOREIGN KEY (`dashboard_id`) REFERENCES `civicrm_dashboard` (`id`) ON DELETE CASCADE)]
            [tip] => add debug=1 to your API call to have more info about the error
            [is_error] => 1
            [error_message] => DB Constraint Violation - domain_id should possibly be marked as mandatory for Dashboard,create API. If so, please raise a bug report.
            [debug_information] =>
                  INSERT INTO civicrm_dashboard_contact ( dashboard_id, contact_id )
                  VALUES  ( 7, 2 ), ( 7, 9 ), ( 7, 10 ), ( 7, 12 ), ( 7, 13 ), ( 7, 19 ), ( 7, 20 ), ( 7, 21 ), ( 7, 22 ), ( 7, 31 ), ( 7, 36 ), ( 7, 39 ), ( 7, 76 ) [nativecode=1452 ** Cannot add or update a child row: a foreign key const
raint fails (`aquaparismcivi`.`civicrm_dashboard_contact`, CONSTRAINT `FK_civicrm_dashboard_contact_dashboard_id` FOREIGN KEY (`dashboard_id`) REFERENCES `civicrm_dashboard` (`id`) ON DELETE CASCADE)]
        )

)

さまざまな回答で提案されているように、私はアップグレードスクリプトを再実行します。私のデータベースは既にアップグレードされています。

どのようなアイデアが来てどこからどのように私はそれを解決することができますか?
これは実行中のデータベースであり、私はそれに関するデータを失わないようにしたいと思います。

ベストアンサー

domain_id 列に値がない civicrm_dashboard
にエントリがあるサイトでこのエラーが発生しました。

私は civicrm_dashboard
civicrm_dashboard_contact をバックアップし、
civicrm_dashboard からdomain_idを持たない行と
civicrm_dashboard_contact >と私は元気だった。

これを振り返ってみると、適切なdomain_idを civicrm_dashboard
テーブルに挿入する方がよいでしょう。

問題が発生した場合に備えて、編集中のデータベースとテーブルを必ずバックアップしてください。

返信を残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です