Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database error upgrading to 3.15 #224

Open
mwestergaard opened this issue Feb 19, 2022 · 13 comments
Open

Database error upgrading to 3.15 #224

mwestergaard opened this issue Feb 19, 2022 · 13 comments

Comments

@mwestergaard
Copy link

I upgraded my dev system (CiviCRM 5.46.0) to 3.15 and received:

DB_DataObject Error: update: trying to perform an update without the key set, and argument to update is not DB_DATAOBJECT_WHEREADD_ONLY Array ( [seq] => Array ( [0] => id [1] => 1 ) [keys] => Array ( [0] => id ) )

Test transactions (PayPal CheckOut) seem to completing successfully and I don't see anything fishy in the log. I tried updating a second system (CiviCRM 5.46.2) and received the same error. Again, test transactions appear to be working.

The error might be thrown here: https://github.com/civicrm/civicrm-packages/blob/master/DB/DataObject.php

@eileenmcnaughton
Copy link
Owner

@mwestergaard are you able to get a full backtrace on that error?

@ananelson
Copy link

Does this help? I'm seeing the same issue.

#0 /home/improv/www/www/sites/all/modules/civicrm/CRM/Core/Error.php(433): CRM_Core_Error::backtrace("backTrace", TRUE)
#1 /home/improv/www/www/sites/all/modules/civicrm/CRM/Core/Invoke.php(39): CRM_Core_Error::handleUnhandledException(Object(CiviCRM_API3_Exception))
#2 /home/improv/www/www/sites/all/modules/civicrm/drupal/civicrm.module(471): CRM_Core_Invoke::invoke((Array:4))
#3 /home/improv/www/www/includes/menu.inc(527): civicrm_invoke("payment", "ipn", "3")
#4 /home/improv/www/www/index.php(21): menu_execute_active_handler()
#5 {main}

@ananelson
Copy link

Feb 24 11:02:31  [debug] $backTrace = #0 /home/improv/www/www/sites/all/modules/civicrm/CRM/Core/Error.php(942): CRM_Core_Error::backtrace("backTrace", TRUE)
#1 /home/improv/www/www/sites/all/modules/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(922): CRM_Core_Error::exceptionHandler(Object(DB_DataObject_Error))
#2 /home/improv/www/www/sites/all/modules/civicrm/packages/DB/DataObject/Error.php(44): PEAR_Error->__construct("DB_DataObject Error: update: trying to perform an update without\n           ...", -1, 16, (Array:2))
#3 /home/improv/www/www/sites/all/modules/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(577): DB_DataObject_Error->__construct("update: trying to perform an update without\n                        the key ...", -1, 16, (Array:2), NULL)
#4 /home/improv/www/www/sites/all/modules/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(223): PEAR::_raiseError(Object(PEAR), "update: trying to perform an update without\n                        the key ...", -1, 16, (Array:2), NULL, "DB_DataObject_Error")
#5 /home/improv/www/www/sites/all/modules/civicrm/packages/DB/DataObject.php(4830): PEAR->__call("raiseError", (Array:6))
#6 /home/improv/www/www/sites/all/modules/civicrm/packages/DB/DataObject.php(1385): DB_DataObject->raiseError("update: trying to perform an update without\n                        the key ...", -1)
#7 /home/improv/www/www/sites/all/modules/civicrm/CRM/Core/ManagedEntities.php(392): DB_DataObject->update()
#8 /home/improv/www/www/sites/all/modules/civicrm/CRM/Core/ManagedEntities.php(191): CRM_Core_ManagedEntities->updateExistingEntity(Object(CRM_Core_DAO_Managed), (Array:7))
#9 /home/improv/www/www/sites/all/modules/civicrm/CRM/Core/ManagedEntities.php(171): CRM_Core_ManagedEntities->reconcileEnabledModule("nz.co.fuzion.omnipaymultiprocessor")
#10 /home/improv/www/www/sites/all/modules/civicrm/CRM/Core/ManagedEntities.php(132): CRM_Core_ManagedEntities->reconcileEnabledModules()
#11 /home/improv/www/www/sites/all/modules/civicrm/CRM/Core/Invoke.php(409): CRM_Core_ManagedEntities->reconcile()
#12 /home/improv/www/www/sites/all/modules/civicrm/CRM/Core/Invoke.php(100): CRM_Core_Invoke::rebuildMenuAndCaches()
#13 /home/improv/www/www/sites/all/modules/civicrm/CRM/Core/Invoke.php(65): CRM_Core_Invoke::hackMenuRebuild((Array:2))
#14 /home/improv/www/www/sites/all/modules/civicrm/CRM/Core/Invoke.php(36): CRM_Core_Invoke::_invoke((Array:2))
#15 /home/improv/www/www/sites/all/modules/civicrm/drupal/civicrm.module(471): CRM_Core_Invoke::invoke((Array:2))
#16 /home/improv/www/www/includes/menu.inc(527): civicrm_invoke("clearcache")
#17 /home/improv/www/www/index.php(21): menu_execute_active_handler()
#18 {main}

@mwestergaard
Copy link
Author

I don't know if this is related, but I found one error in my web log at the time I upgraded:

PHP Warning: Invalid argument supplied for foreach() in /var/www/html/wp-content/uploads/civicrm/ext/biz.jmaconsulting.lineitemedit/lineitemedit.php on line 287, referer: http://pi/civicrm/contribute/transact/?reset=1&id=6&action=preview

Thinking it might be an extension conflict, I turned on debug, disabled both extensions, and then uninstalled omnipaymultiprocessor. When I reinstalled, I didn't get the DB_DataObject Error. I re-enabled lineitemedit and both seem to be working. Oddly, I now receive an error on any extension I enable:

Sorry, due to an error, we are unable to fulfill your request at the moment. You may want to contact your administrator or service provider with more details about what action you were performing when this occurred.
API error: DB Error: already exists on payment_processor_type.create( entity name omnipay_FirstAtlanticCommerce_FAC)

I got that when I upgraded the mosaico extension earlier today.

@cloudcogsio
Copy link
Contributor

I also ran into some issues with a clean install of Civi.

The issue is that my gateway project files contains a copy of the *.mgd.php file in a Support folder for the First Atlantic Commerce Gateway.
Previously, my project was not included in the vendor folder of the plugin but has since been included in release 2.15

During installation of the plugin I believe the plugin loads all files it can find using the "*.mgd.php" pattern.
See omnipaymultiprocessor.civix.php

$mgdFiles = _omnipaymultiprocessor_civix_find_files(__DIR__, '*.mgd.php');

Since this file is also in the Metadata folder of the plugin it loads twice which is causing the issues.

There are two proposed solutions:

  1. I can remove the metadata file from the FirstAtlantic gateway project.
  2. @eileenmcnaughton can change the loading mechanism so the metadata files are only loaded from top level Metadata folder and NOT traverse into the vendor folders.

Another release is required to avoid "out of the box" issues.

As a workaround for those affected:

  1. Uninstall the plugin from within Civi (the downloaded plugin files are retained)
  2. Navigate to the plugin files and remove the file "omnipay_FirstAtlanticCommerce_FAC.mgd.php" found at "nz.co.fuzion.omnipaymultiprocessor/vendor/cloudcogsio/omnipay-firstatlanticcommerce-gateway/src/Support/CiviCRM"
  3. Reinstall the plugin from within Civi

@eileenmcnaughton
Copy link
Owner

@cloudcogsio I suspect BOTH 1 & 2 should probably be done....

@stesi561
Copy link

An alternative route to the above if you are not using FirstAtlanticCommerce payment processor is to remove the .mgd.php file from both locations and just cv flush - at least I think this works! I couldn't get the above steps to work without hitting other problems. (uninstalling resulted in other errors.)

@cloudcogsio
Copy link
Contributor

@eileenmcnaughton FAC lib was updated. (v1.0.2.1) Removed the mgd from the vendor folder.
Another vendor update and release should fix.

@eileenmcnaughton
Copy link
Owner

I just did ^^ & tagged 3.16

@timatidg
Copy link

timatidg commented Jun 2, 2022

I received this error going from 3.16 to 3.18 today.

$backTrace = #0 .../public_html/sites/all/modules/civicrm/CRM/Core/Error.php(954): CRM_Core_Error::backtrace("backTrace", TRUE) #1 .../public_html/sites/all/modules/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(922): CRM_Core_Error::exceptionHandler(Object(DB_Error)) #2 .../public_html/sites/all/modules/civicrm/vendor/pear/db/DB.php(997): PEAR_Error->__construct("DB Error: already exists", -5, 16, (Array:2), "INSERT INTO civicrm_payment_processor_type (name , title , description...") #3 .../public_html/sites/all/modules/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(575): DB_Error->__construct(-5, 16, (Array:2), "INSERT INTO civicrm_payment_processor_type (name,title,description...") #4 .../public_html/sites/all/modules/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(223): PEAR->_raiseError(Object(DB_mysqli), NULL, -5, 16, (Array:2), "INSERT INTO civicrm_payment_processor_type (name , title , description...", "DB_Error", TRUE) #5 .../public_html/sites/all/modules/civicrm/vendor/pear/db/DB/common.php(1928): PEAR->__call("raiseError", (Array:7)) #6 .../public_html/sites/all/modules/civicrm/vendor/pear/db/DB/mysqli.php(936): DB_common->raiseError(-5, NULL, NULL, "INSERT INTO civicrm_payment_processor_type (name,title,description...", "1062 ** Duplicate entry 'omnipay_FirstAtlanticCommerce_FAC' for key 'UI_name'") #7 .../public_html/sites/all/modules/civicrm/vendor/pear/db/DB/mysqli.php(406): DB_mysqli->mysqliRaiseError() #8 .../public_html/sites/all/modules/civicrm/vendor/pear/db/DB/common.php(1234): DB_mysqli->simpleQuery("INSERT INTO civicrm_payment_processor_type (name , title , description...") #9 .../public_html/sites/all/modules/civicrm/packages/DB/DataObject.php(2696): DB_common->query("INSERT INTO civicrm_payment_processor_type (name,title,description...") #10 .../public_html/sites/all/modules/civicrm/packages/DB/DataObject.php(1245): DB_DataObject->_query("INSERT INTO civicrm_payment_processor_type (name , title , `description...") #11 .../public_html/sites/all/modules/civicrm/CRM/Core/DAO.php(660): DB_DataObject->insert() #12 .../public_html/sites/all/modules/civicrm/CRM/Financial/BAO/PaymentProcessorType.php(138): CRM_Core_DAO->save() #13 .../public_html/sites/all/modules/civicrm/api/v3/utils.php(1319): CRM_Financial_BAO_PaymentProcessorType::create((Array:12)) #14 .../public_html/sites/all/modules/civicrm/api/v3/PaymentProcessorType.php(27): _civicrm_api3_basic_create("CRM_Financial_BAO_PaymentProcessorType", (Array:12), "PaymentProcessorType") #15 .../public_html/sites/all/modules/civicrm/Civi/API/Provider/MagicFunctionProvider.php(89): civicrm_api3_payment_processor_type_create((Array:12)) #16 .../public_html/sites/all/modules/civicrm/Civi/API/Kernel.php(149): Civi\API\Provider\MagicFunctionProvider->invoke((Array:8)) #17 .../public_html/sites/all/modules/civicrm/Civi/API/Kernel.php(81): Civi\API\Kernel->runRequest((Array:8)) #18 .../public_html/sites/all/modules/civicrm/api/api.php(22): Civi\API\Kernel->runSafe("payment_processor_type", "create", (Array:10)) #19 .../public_html/sites/all/modules/civicrm/CRM/Core/ManagedEntities.php(189): civicrm_api("payment_processor_type", "create", (Array:10)) #20 .../public_html/sites/all/modules/civicrm/CRM/Core/ManagedEntities.php(151): CRM_Core_ManagedEntities->insertNewEntity((Array:7)) #21 .../public_html/sites/all/modules/civicrm/CRM/Core/ManagedEntities.php(112): CRM_Core_ManagedEntities->reconcileEntities((Array:36)) #22 .../public_html/sites/all/modules/civicrm/CRM/Core/Invoke.php(413): CRM_Core_ManagedEntities->reconcile() #23 .../public_html/sites/all/modules/civicrm/CRM/Extension/Manager.php(228): CRM_Core_Invoke::rebuildMenuAndCaches(TRUE) #24 .../public_html/sites/all/modules/civicrm/CRM/Extension/Downloader.php(143): CRM_Extension_Manager->replace("/tmp/tmp-erZu4Y//nz.co.fuzion.omnipaymultiprocessor-3.18") #25 .../public_html/sites/all/modules/civicrm/api/v3/Extension.php(239): CRM_Extension_Downloader->download("nz.co.fuzion.omnipaymultiprocessor", "https://github.com/eileenmcnaughton/nz.co.fuzion.omnipaymultiprocessor/archiv...") #26 .../public_html/sites/all/modules/civicrm/Civi/API/Provider/MagicFunctionProvider.php(89): civicrm_api3_extension_download((Array:4)) #27 .../public_html/sites/all/modules/civicrm/Civi/API/Kernel.php(149): Civi\API\Provider\MagicFunctionProvider->invoke((Array:8)) #28 .../public_html/sites/all/modules/civicrm/Civi/API/Kernel.php(81): Civi\API\Kernel->runRequest((Array:8)) #29 .../public_html/sites/all/modules/civicrm/api/api.php(22): Civi\API\Kernel->runSafe("Extension", "download", (Array:2)) #30 .../public_html/sites/all/modules/civicrm/CRM/Admin/Form/Extensions.php(204): civicrm_api("Extension", "download", (Array:2)) #31 .../public_html/sites/all/modules/civicrm/CRM/Core/Form.php(573): CRM_Admin_Form_Extensions->postProcess() #32 .../public_html/sites/all/modules/civicrm/CRM/Core/StateMachine.php(144): CRM_Core_Form->mainProcess() #33 .../public_html/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Next.php(43): CRM_Core_StateMachine->perform(Object(CRM_Admin_Form_Extensions), "next", "Next") #34 .../public_html/sites/all/modules/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Next->perform(Object(CRM_Admin_Form_Extensions), "next") #35 .../public_html/sites/all/modules/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller->handle(Object(CRM_Admin_Form_Extensions), "next") #36 .../public_html/sites/all/modules/civicrm/CRM/Core/Controller.php(355): HTML_QuickForm_Page->handle("next") #37 .../public_html/sites/all/modules/civicrm/CRM/Core/Page/Basic.php(334): CRM_Core_Controller->run() #38 .../public_html/sites/all/modules/civicrm/CRM/Core/Page/Basic.php(140): CRM_Core_Page_Basic->edit(2, NULL) #39 .../public_html/sites/all/modules/civicrm/CRM/Admin/Page/Extensions.php(105): CRM_Core_Page_Basic->run() #40 .../public_html/sites/all/modules/civicrm/CRM/Core/Invoke.php(319): CRM_Admin_Page_Extensions->run((Array:3), NULL) #41 .../public_html/sites/all/modules/civicrm/CRM/Core/Invoke.php(69): CRM_Core_Invoke::runItem((Array:19)) #42 .../public_html/sites/all/modules/civicrm/CRM/Core/Invoke.php(36): CRM_Core_Invoke::_invoke((Array:3)) #43 .../public_html/sites/all/modules/civicrm/drupal/civicrm.module(471): CRM_Core_Invoke::invoke((Array:3)) #44 .../public_html/includes/menu.inc(527): civicrm_invoke("admin", "extensions") #45 .../public_html/index.php(21): menu_execute_active_handler() #46 {main}

@eileenmcnaughton
Copy link
Owner

@timatidg it implies that for some reason you have omnipay_FirstAtlanticCommerce in your payment processor type table (civicrm_payment_processor_type) but not in civicrm_managed - so it is trying to add it

@timatidg
Copy link

timatidg commented Jun 2, 2022

@eileenmcnaughton, Thank you!

I deleted it from the database table (civicrm_payment_processor_type), disabled and re-enabled the (already upgraded) extension and did not receive further error messages.

@eileenmcnaughton
Copy link
Owner

yay!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants