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

Admin hooks of format "display#controller_name#Form" on legacy admin forms are not executed #36185

Open
2 tasks done
hugo-fasone opened this issue May 17, 2024 · 1 comment · May be fixed by #36186
Open
2 tasks done
Labels
8.1.x Branch BO Category: Back Office Bug Type: Bug Hook NMI Status: issue needs more information Waiting for author Status: action required, waiting for author feedback

Comments

@hugo-fasone
Copy link

hugo-fasone commented May 17, 2024

Prerequisites

Describe the bug and add attachments

Admin hooks of format "display#controller_name#Form" on legacy admin forms such as "displayAdminReturnForm" are not executed.

The hook is supposed to be called here : https://github.com/PrestaShop/PrestaShop/blob/8.1.6/admin-dev/themes/default/template/helpers/form/form.tpl#L663
Here $name_controller is supposed to be the name of the controller, so for exemple "AdminReturn" in the case of the "AdminReturn" controller when we try to view a single order return. The hook should be called at the end of the form

screenshot-127 0 0 1_4502-2024 05 17-12_55_42

But actually, the value of $name_controller is an empty string, so the executed hook is "displayForm" and not "displayAdminReturnForm". This behaviour is caused by these two code snippets:

https://github.com/PrestaShop/PrestaShop/blob/develop/classes/controller/AdminController.php#L2621C1-L2623C10
https://github.com/PrestaShop/PrestaShop/blob/8.1.6/classes/helper/HelperForm.php#L40

On the AdminController.php file, we see that $name_controller takes the value only if it doesn't equal null. But in the HelperForm.php file we see that $name_controller is not equal to null, it's an empty string, thus the bug : $name_controller is equal to an empty string and never takes the Tools::getValue('controller') as a value

We see in this file the smarty affectation of the "name_controller" variable used in the form.tpl file
https://github.com/PrestaShop/PrestaShop/blob/8.1.6/classes/helper/HelperForm.php#L291

This PR introduced this bug : #31514

Expected behavior

The hook "displayAdminReturnForm" should be executed at the end of a return form in backoffice (in the red rectangle on the screenshot above)

Steps to reproduce

  1. Create a module that's attached to the "displayAdminReturnForm" hook
  2. On this module, create a function that returns a simple string, such as "test"
  3. On the "AdminReturn" in backoffice, select a return issued by a customer
  4. The text "test" should appear at the end of the form (see screenshot above), but it doesn't

PrestaShop version(s) where the bug happened

Tested on 8.1.4, but was presumably introduced in 8.0.2

PHP version(s) where the bug happened

N/A

If your bug is related to a module, specify its name and its version

N/A

Your company or customer's name goes here (if applicable).

PliciWeb

@hugo-fasone hugo-fasone added Bug Type: Bug New New issue not yet processed by QA labels May 17, 2024
hugo-fasone added a commit to hugo-fasone/PrestaShop that referenced this issue May 17, 2024
@AureRita
Copy link
Contributor

Hi @hugo-fasone

Thank you for your report and sorry for the time we spend to answer you, to try to reproduce your issue, can you provide us a exemple module to test it ?

waiting for your feedback

@AureRita AureRita added Waiting for author Status: action required, waiting for author feedback BO Category: Back Office NMI Status: issue needs more information Hook 8.1.x Branch and removed New New issue not yet processed by QA labels May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.1.x Branch BO Category: Back Office Bug Type: Bug Hook NMI Status: issue needs more information Waiting for author Status: action required, waiting for author feedback
Projects
None yet
2 participants