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

Use a sensible default if none is found #36692

Merged

Conversation

roland-d
Copy link
Contributor

@roland-d roland-d commented Jan 15, 2022

Summary of Changes

When you have a module installed but the module manifest does not have the client attribute set, uninstalling this module crashes:
image

The same thing happens when you install the module but when you refresh the page it tells you the module installation was fine.

So the change here is to set a sensible default of site as that is where most modules are installed.

This was tested on PHP 8.1

Testing Instructions

  1. Go to System -> Global Configuration
  2. Click on the Server tab
  3. Set Error reporting to Maximum
  4. Click on Save & Close
  5. Go to System -> Install -> Extensions
  6. Install the attached module
    mod_test.zip
  7. See that you get the error as shown above but the module is installed
  8. Uninstall the module
  9. See that you get the error as shown above but the module is uninstalled
  10. Apply the patch
  11. Install the module again
  12. Notice that there is no error now
  13. Uninstall the module
  14. Notice that there is no error now

Actual result BEFORE applying this Pull Request

The module does install but the user faces a fatal error

Expected result AFTER applying this Pull Request

The module is installed but no fatal error is shown

Documentation Changes Required

None

Signed-off-by: Roland Dalmulder <contact@rolandd.com>
@ChristineWk
Copy link

@roland-d
Can't confirm point 3 and point 5. (No error)
Maybe it belongs to PHP version? I'm using PHP 7.4 / Joomla Version 4.0.6-dev


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/36692.

@roland-d
Copy link
Contributor Author

@ChristineWk Thank you for testing. I was actually doing my tests on PHP 8.1 but even though the issue should be reproducible on 7.4. For it to show on PHP 7.4 I have changed the instructions a bit, can you see if you can get an error now?

@ChristineWk
Copy link

Tested again. No error ... Checks:
Module for testing purposes / 1.0.0 / Jan15 / Developer
PHP 7.4.25 / DB 5.7 / PHP Built on Linux / cgi-fci

@PhilETaylor

This comment was marked as abuse.

@roland-d
Copy link
Contributor Author

So you are assuming site rather than administrator or cli here...
Yes, because modules cannot be loaded in the cli and as I stated in my opening post is that most modules are installed for the front-end of the site instead of the administrator.

I do not think this is so different from the default set in the TemplateAdapter.php except that there the default is set to administrator.

@roland-d
Copy link
Contributor Author

@ChristineWk I am going to test it again to see if I cannot get the error but I really do not understand why you see no error.

@infograf768
Copy link
Member

IMHO, such a module (or any extension) without a client in the manifest should just be prevented from being installed and should throw an error.

@roland-d
Copy link
Contributor Author

@infograf768 That actually crossed my mind as well but the module is already installed at this point, so I figured why not :) I am fine to change this PR to also check if the client is set. Regardless I think a default is not a bad fallback.

@infograf768
Copy link
Member

In fact, I tried to installed that module and result depends on php version.
Php 8.0.8 I get an internal server error.

Screenshot 2022-01-16 at 09 32 51

php 7.4.21: the module installs with a default clientId of 0 (site) and can be uninstalled without any error.

Therefore, what we need is preventing installing and meaningfull error I guess to adapt to php 8+

@roland-d
Copy link
Contributor Author

@infograf768 The Internal Server Error is actually the 0 Undefined constant "JPATH_" You can see that in the Network tab and click on the repsonse tab. That will show you the HTML page with the error in it.

So I checked again on PHP 7.4 and now the installer runs fine as @ChristineWk and you found out. This is because an undefined constant is only fatal since PHP 8.

The default client ID of 0 is not a change from this PR, that is already in Joomla. The adaptation to PHP 8+ is to also set a default client to site so you get an existing constant.

@brianteeman
Copy link
Contributor

If possible why not change it so that modules cannot be installed without a defined client AND use a default when uninstalling a module that doesnt have a defined client

@roland-d
Copy link
Contributor Author

I wonder if not allowing a module to install when the client is missing is a B/C break at this point.

@chmst
Copy link
Contributor

chmst commented Jan 25, 2022

It would be friendly allowing the installation and write an information "Module is installed for frontend. "

@roland-d
Copy link
Contributor Author

@chmst That already happens based on the method tag in a module.

@chmst chmst changed the base branch from 4.0-dev to 4.1-dev January 31, 2022 18:13
@chmst chmst removed the PR-4.0-dev label Jan 31, 2022
@richard67 richard67 added the PBF Pizza, Bugs and Fun label Apr 22, 2022
@HLeithner HLeithner changed the base branch from 4.1-dev to 4.2-dev June 27, 2022 13:06
@HLeithner
Copy link
Member

This pull request has automatically rebased to 4.2-dev.

@joomla-bot
Copy link
Contributor

This pull requests has been automatically converted to the PSR-12 coding standard.

@Hackwar Hackwar added the Small A PR which only has a small change label Feb 26, 2023
@Hackwar Hackwar added the bug label Apr 6, 2023
@HLeithner HLeithner changed the base branch from 4.2-dev to 4.3-dev May 2, 2023 16:30
@HLeithner
Copy link
Member

This pull request has been automatically rebased to 4.3-dev.

@obuisard
Copy link
Contributor

obuisard commented Jun 20, 2023

One issue is that we allow extensions with the client tag to be 0 while it should be site, for instance. We should stop allowing extensions to be installed with an improper value for 'client'. It is now well documented (change for 5.0 ?).
AND use the fix from Roland @roland-d for b/c with extensions that have already be installed.
So, I am in favor of this PR, still necessary for b/c even if we start enforcing the client values.

@RickR2H
Copy link
Member

RickR2H commented Aug 26, 2023

I have tested this item ✅ successfully on e45e805

I'm on PHP 8.1 installing the test module is not working. I get the same error as @infograf768. Adding the patch will allow the module to install. I count this as a successful test.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/36692.

@pjasmits
Copy link

I have tested this item ✅ successfully on e45e805

I'm on PHP 8.1 installing the test module is not working. I get the same error as @infograf768. Adding the patch will allow the module to install. I count this as a successful test.

@HLeithner HLeithner changed the base branch from 4.3-dev to 4.4-dev September 30, 2023 22:45
@HLeithner
Copy link
Member

This pull request has been automatically rebased to 4.4-dev.

@heelc29
Copy link
Contributor

heelc29 commented Oct 24, 2023

I have tested this item ✅ successfully on e45e805


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/36692.

@MacJoom MacJoom self-assigned this Nov 22, 2023
@reDimDev
Copy link

I have tested this item ✅ successfully on 8f9f2ce


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/36692.

1 similar comment
@tomsrocket
Copy link

I have tested this item ✅ successfully on 8f9f2ce


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/36692.

@richard67
Copy link
Member

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/36692.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Feb 24, 2024
@stimpsonjcat
Copy link

Successfully tested this in Joomla 5.1 alpha 3 with php 8.3.3. When installing I get a warning: Unable to detect manifest file. Nothing is installed.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/36692.

@stimpsonjcat
Copy link

I have tested this item ✅ successfully on 0e5c276


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/36692.

@MacJoom MacJoom merged commit 708b1ea into joomla:4.4-dev Feb 28, 2024
3 checks passed
@MacJoom
Copy link
Contributor

MacJoom commented Feb 28, 2024

Thank you!

@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Feb 28, 2024
@Quy Quy added this to the Joomla! 4.4.4 milestone Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug PBF Pizza, Bugs and Fun PR-4.4-dev Small A PR which only has a small change
Projects
None yet
Development

Successfully merging this pull request may close these issues.