Deleting Donations without a revenue table should not cause a fatal error
closed
Ben Meredith
When a site does not have a revenue table, and an admin tries to delete a donation, there's a fatal error:
Uncaught exception 'Give\Framework\Database\Exceptions\DatabaseQueryException' with message 'Query failed in database' in ...give/src/Framework/Database/Exceptions/DatabaseQueryException.php on line 32
Ben Meredith
closed
The fix for this issue is to correctly determine when a revenue table is not present. Updates since November to GiveWP now make that situation clearer, and the workaround posted here helps with that.
Additionally, in the next version of GiveWP (2.10.0) we are including a robust set of tools for folks to re-run database update routines that fail (like the one to add the revenue table, here).
For those reasons, I'm closing out this issue. Reach out via our support channels if you continue to have issues. Thanks!
Adam Casey Pastrana
Error found on the Log Updates
Update Task
Array
(
[update_info] => Array
(
[id] => add-past-donation-data-to-revenue-table
[version] => 2.9.0
[callback] => Array
(
[0] => Give\Revenue\Migrations\AddPastDonationsToRevenueTable Object
(
)
[1] => run
)
[type] => database
)
[step] => 1
[update] => 1
[heading] => Update 1 of 1
[percentage] => 0
[total_percentage] => 0
)
Error
To insert revenue, please provide valid donation_id, form_id, amount.
Ben Meredith
Adam Casey Pastrana: I missed this comment back in November, but wanted to follow up here just in case you (or others reading this) run into this particular error. That error
To insert revenue, please provide valid donation_id, form_id, amount.
means that one or more of your donations saved inthe database have become detached from their form (perhaps the form was deleted or renamed, or an older database update routine failed silently). You need to go in and associate all donations with forms, and then the update will run correctly.Ben Meredith
This error is related to the new Revenue table not being added to a site. This should have happened on update to
2.9.x
but in some cases did not.The process to remedy this is:
Go to the following URLs, in order: (add your base URL to each)
- /wp-admin/?give-run-migration=create_revenue_table(this manually forces the database routine again)
- /wp-admin/?give-clear-update=add-past-donation-data-to-revenue-table(this clears the update so that your site can try again. You should see an update alert after this one runs)
Run the update!
Go to this URL:
/wp-admin/edit.php?post_type=give_forms&page=give-tools&tab=logs§ion=updates
(this checks the logs to see if there were any errors. If you see errors, open a support ticket with those errors!)Adam Casey Pastrana
Action Taken:
Go to the following URLs, in order: (add your base URL to each)
/wp-admin/?give-run-migration=create_revenue_table (this manually forces the database routine again)
/wp-admin/?give-run-migration=add-past-donation-data-to-revenue-table (this manually adds existing donations to the revenue table)
/wp-admin/edit.php?post_type=give_forms&page=give-tools&tab=logs§ion=updates (this checks the logs to see if there were any errors.
Result:
First URL was successfully added to DB.
2nd URL have an error adding to DB https://prnt.sc/vmw0pt
3rd URL screenshot https://prnt.sc/vmw40y
I tried to update GiveWP but still I am not getting any progress https://prnt.sc/vmw711
Ben Meredith
Adam Casey Pastrana: There's a typo in the second URL there. it should be
/wp-admin/?give-clear-update=add-past-donation-data-to-revenue-table
That should cause the update to clear and then you can run it again.