PR-4.3-dev Pending

User tests: Successful: Unsuccessful:

avatar dgrammatiko
dgrammatiko
14 May 2023

Pull Request for Issue # .

Summary of Changes

There's an inconsistency in the com_ajax logic that prevents modules resolving correctly the Helper file (read the testing instructions below). The proposed fix is to use a strtolower for the db name of the module and let the other parts intact...

Testing Instructions

To experience the bug you need to edit the file administrator/modules/mod_guidedtours/src/Helper/GuidedToursHelper.php and add on function named toursAjax ie:

    public function toursAjax()
    {
        return ["success" => true, "message" => "in a bottle"];
    }

Then in the cpanel open the browser console and run

await fetch(new URL(`${Joomla.getOptions('system.paths').baseFull}index.php?option=com_ajax&module=guidedtours&method=tours&format=json`), { headers: { 'X-CSRF-Token': Joomla.getOptions('csrf.token') } }).then(x => x.json())

Note: the part module=guidedtours (prefixed with mod_) reflects the column element in the #__extensions table.

Screenshot 2023-05-14 at 12 05 57

The result is that the com_ajax will Look for a GuidedtoursHelper class, which will fail on any case sensitive filesystem:
Screenshot 2023-05-14 at 11 37 58

Apply the PR and run in the console the following (observe that the module now is defined as GuidedTours)

await fetch(new URL(`${Joomla.getOptions('system.paths').baseFull}index.php?option=com_ajax&module=GuidedTours&method=tours&format=json`), { headers: { 'X-CSRF-Token': Joomla.getOptions('csrf.token') } }).then(x => x.json())

The class is correctly identified as GuidedToursHelper
Screenshot 2023-05-14 at 12 16 12

Actual result BEFORE applying this Pull Request

Expected result AFTER applying this Pull Request

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

@laoneo

avatar joomla-cms-bot joomla-cms-bot - change - 14 May 2023
Category Front End com_ajax
avatar dgrammatiko dgrammatiko - open - 14 May 2023
avatar dgrammatiko dgrammatiko - change - 14 May 2023
Status New Pending
avatar richard67
richard67 - comment - 14 May 2023

@dgrammatiko I have tested, but in opposite to your testing instructions I have tested both cases &module=guidedtours and &module=GuidedTours without and with the PR.

I've not seen any difference.

The &module=guidedtours returns the object with success=false and the message that the helper was not found, and the &module=GuidedTours returns your message in a bottle with success=true, regardless if I have the change from this PR applied or not.

Could you check if you can reproduce my finding?

avatar dgrammatiko
dgrammatiko - comment - 14 May 2023

Could you check if you can reproduce my finding?

Are you on a case sensitive filesystem?

avatar richard67
richard67 - comment - 14 May 2023

Could you check if you can reproduce my finding?

Are you on a case sensitive filesystem?

Server is Ubuntu, so yes.

avatar dgrammatiko dgrammatiko - change - 14 May 2023
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2023-05-14 13:11:29
Closed_By dgrammatiko
Labels Added: PR-4.3-dev
avatar dgrammatiko
dgrammatiko - comment - 14 May 2023

Maybe this is also a combo with DB/PHP. I've had complains for 2 cases https://github.com/dgrammatiko/invalidate-cache and https://github.com/dgrammatiko/mod_child_export and I end up renaming the helper class.

Anyways, I'll close for now. Thanks for checking

avatar dgrammatiko dgrammatiko - close - 14 May 2023
avatar richard67
richard67 - comment - 14 May 2023

@dgrammatiko Maybe I made some mistake when testing? I did everything as described, but who knows.

Add a Comment

Login with GitHub to post a comment