givewp icon indicating copy to clipboard operation
givewp copied to clipboard

bulk action in legacy give-payment-history page broken

Open pulsovi opened this issue 1 year ago • 4 comments

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

  1. add some translation for the "Forms" string in the give plugin (I use locotranslate)
  2. go to the back-office, and in the menu go to the payment history page.
  3. Click on "Switch to legacy view"
  4. Select some donations
  5. choose "resend receipt" in the bulk action list.
  6. 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 code wp_nonce_field( 'bulk-' . $this->_args['plural'] );
  • The value of $this->_args['plural'] in this context is defined by WP_List_Table::__construct at https://github.com/WordPress/wordpress-develop/blob/87dfd5514b52aef456b7232b1959873e69e651da/src/wp -admin/includes/class-wp-list-table.php#L157 with code sanitize_key( $args['plural'] )
  • $args['plural'] is defined by Give_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

pulsovi avatar Dec 26 '23 20:12 pulsovi

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.

github-actions[bot] avatar Feb 10 '24 01:02 github-actions[bot]

want a PR ?

pulsovi avatar Feb 19 '24 21:02 pulsovi

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.

github-actions[bot] avatar Apr 05 '24 01:04 github-actions[bot]

I have little time at the moment, but I plan to do a PR within 4 weeks. Please don't close the conversation.

pulsovi avatar Apr 10 '24 09:04 pulsovi

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.

github-actions[bot] avatar May 26 '24 01:05 github-actions[bot]

I see that the bug has already been fixed by someone else. So much the better.

#7204

pulsovi avatar May 26 '24 20:05 pulsovi