Issue with Donations “New View”
-
When I use the “New View” and click “on “Edit” to open a donation, the page keeps loading and nothing happens.
Debugging:
1. On an URL like
/wp-admin/edit.php?post_type=give_forms&page=give-payment-history&id=11000an ajax call is fired to fetch data from/wp-json/givewp/v3/donations/11000?includeSensitiveData=true&anonymousDonations=include&_embed=true&_locale=user2. The wp-json url returns a server error:
{
"code": "internal_server_error",
"message": "<p>There has been a critical error on this website.<\/p><p><a href=\"https:\/\/wordpress.org\/documentation\/article\/faq-troubleshooting\/\">Learn more about troubleshooting WordPress.<\/a><\/p>",
"data": {
"status": 500,
"error": {
"type": 1,
"message": "Uncaught Give\\Framework\\Database\\Exceptions\\DatabaseQueryException: Database Query in \/httpdocs\/wp-content\/plugins\/give\/src\/Framework\/Database\/DB.php:250\nStack trace:\n#0 \/httpdocs\/wp-content\/plugins\/give\/src\/Framework\/Database\/DB.php(86): Give\\Framework\\Database\\DB::runQueryWithErrorChecking()\n#1 \/httpdocs\/wp-content\/plugins\/give\/src\/Framework\/Models\/ModelQueryBuilder.php(100): Give\\Framework\\Database\\DB::__callStatic()\n#2 \/httpdocs\/wp-content\/plugins\/give\/src\/EventTickets\/Repositories\/EventTicketRepository.php(303): Give\\Framework\\Models\\ModelQueryBuilder->getAll()\n#3 \/httpdocs\/wp-content\/plugins\/give\/src\/Donations\/Models\/Donation.php(277): Give\\EventTickets\\Repositories\\EventTicketRepository->getTotalByDonation()\n#4 \/httpdocs\/wp-content\/plugins\/give\/src\/API\/REST\/V3\/Routes\/Donations\/ViewModels\/DonationViewModel.php(62): Give\\Donations\\Models\\Donation->eventTicketsAmount()\n#5 \/httpdocs\/wp-content\/plugins\/give\/src\/API\/REST\/V3\/Routes\/Donations\/DonationController.php(285): Give\\API\\REST\\V3\\Routes\\Donations\\ViewModels\\DonationViewModel->exports()\n#6 \/httpdocs\/wp-includes\/rest-api\/class-wp-rest-server.php(1292): Give\\API\\REST\\V3\\Routes\\Donations\\DonationController->get_item()\n#7 \/httpdocs\/wp-includes\/rest-api\/class-wp-rest-server.php(1125): WP_REST_Server->respond_to_request()\n#8 \/httpdocs\/wp-includes\/rest-api\/class-wp-rest-server.php(439): WP_REST_Server->dispatch()\n#9 \/httpdocs\/wp-includes\/rest-api.php(467): WP_REST_Server->serve_request()\n#10 \/httpdocs\/wp-includes\/class-wp-hook.php(341): rest_api_loaded()\n#11 \/httpdocs\/wp-includes\/class-wp-hook.php(365): WP_Hook->apply_filters()\n#12 \/httpdocs\/wp-includes\/plugin.php(570): WP_Hook->do_action()\n#13 \/httpdocs\/wp-includes\/class-wp.php(418): do_action_ref_array()\n#14 \/httpdocs\/wp-includes\/class-wp.php(821): WP->parse_request()\n#15 \/httpdocs\/wp-includes\/functions.php(1343): WP->main()\n#16 \/httpdocs\/wp-blog-header.php(16): wp()\n#17 \/httpdocs\/index.php(17): require('...')\n#18 {main}\n thrown",
"file": "\/httpdocs\/wp-content\/plugins\/give\/src\/Framework\/Database\/DB.php",
"line": 250
}
},
"additional_errors": []
}3. To find out more info, in
src/Framework/Database/DB.phpinrunQueryWithErrorChecking()function I addvar_dump($wpError);andvar_dump($wpdb->last_query);– now the error shows as:object(WP_Error)#24042 (3) {
["errors"]=>
array(1) {
["db_delta_error"]=>
array(1) {
[0]=>
string(207) "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE 1 = 0) AS tickets WHERE tickets.donation_id = '11000'' at line 1"
}
}
["error_data"]=>
array(0) {
}
["additional_data":protected]=>
array(0) {
}
}
string(229) "SELECT * FROM (SELECT NULL as id, NULL as event_id, NULL as ticket_type_id, NULL as donation_id, NULL as amount, NULL as created_at, NULL as updated_at, NULL as currency WHERE 1 = 0) AS tickets WHERE tickets.donation_id = '11000'"4. This query is coming from
src/EventTickets/Repositories/EventTicketRepository.phpfromprepareQuery()and it clearly looks invalid, missing aFROMin the subquery.
You must be logged in to reply to this topic.