givewp
givewp copied to clipboard
bulk action in legacy give-payment-history page broken
User Story
As an admin, I want resend receipt for some donations.
Details
nonce checking fail with message "We are unable to recognize your session. Please refresh the screen to try again; otherwise contact your website administrator for assistance" (wp_die)
Expected Behavior
The receipts must be resend and I to go back on the payments history list table
Steps to Reproduce
- add some translation for the "Forms" string in the give plugin (I use locotranslate)
- go to the back-office, and in the menu go to the payment history page.
- Click on "Switch to legacy view"
- Select some donations
- choose "resend receipt" in the bulk action list.
- Click on the submit button
=> get error page with the message :
"We are unable to recognize your session. Please refresh the screen to try again; otherwise contact your website administrator for assistance"
Acceptance Criteria
- [ ] The above steps result in the successful sending of receipts
Suggested resolution
The bug seems to come from the fact that the $action passed to the nonce check in the next two calls is assumed to be "bulk-forms".
https://github.com/impress-org/givewp/blob/179d6c46d5d89f7597b567b2ace070c0cab93e12/includes/admin/admin-actions.php#L147 And https://github.com/impress-org/givewp/blob/179d6c46d5d89f7597b567b2ace070c0cab93e12/includes/admin/payments/class-payments-table.php#L815
While its true value is 'bulk-' . sanitize_key(give_get_forms_label_plural())
Which is defined as follows:
- The nonce is produced by
WP_List_Table::display_tablenav
at https://github.com/WordPress/wordpress-develop/blob/87dfd5514b52aef456b7232b1959873e69e651da/src/wp-admin/includes/class-wp-list-table.php#L1673 with the codewp_nonce_field( 'bulk-' . $this->_args['plural'] );
- The value of
$this->_args['plural']
in this context is defined byWP_List_Table::__construct
at https://github.com/WordPress/wordpress-develop/blob/87dfd5514b52aef456b7232b1959873e69e651da/src/wp -admin/includes/class-wp-list-table.php#L157 with codesanitize_key( $args['plural'] )
-
$args['plural']
is defined byGive_Payment_History_Table::__construct
at https://github.com/impress-org/givewp/blob/179d6c46d5d89f7597b567b2ace070c0cab93e12/includes/admin/payments/class-payments-table.php#L140 -
give_get_forms_label_plural()
is defined at https://github.com/impress-org/givewp/blob/179d6c46d5d89f7597b567b2ace070c0cab93e12/includes/post-types.php#L299-L302 -
give_get_default_form_labels()
is defined at https://github.com/impress-org/givewp/blob/179d6c46d5d89f7597b567b2ace070c0cab93e12/includes/post-types.php#L270-L277
This issue is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 14 additional days. Note, if this Issue is reporting a bug, please reach out to our support at https://givewp.com/support. If this is a feature request, please see our feedback board at feedback.givewp.com — that’s the best place to make feature requests, unless you’re providing a PR.
want a PR ?
This issue is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 14 additional days. Note, if this Issue is reporting a bug, please reach out to our support at https://givewp.com/support. If this is a feature request, please see our feedback board at feedback.givewp.com — that’s the best place to make feature requests, unless you’re providing a PR.
I have little time at the moment, but I plan to do a PR within 4 weeks. Please don't close the conversation.
This issue is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 14 additional days. Note, if this Issue is reporting a bug, please reach out to our support at https://givewp.com/support. If this is a feature request, please see our feedback board at feedback.givewp.com — that’s the best place to make feature requests, unless you’re providing a PR.
I see that the bug has already been fixed by someone else. So much the better.
#7204