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

Add additional method to check for mod_rewrite #6911

Conversation

grayeul
Copy link
Contributor

@grayeul grayeul commented Mar 19, 2024

Description & Issue number it closes

This closes #6910 by adding an additional method to check if apache is able to process rewrite rules.

Screenshots (if appropriate)

N/A

How to test the changes?

This could be checked if a demo could be spun up on Softaculous from this change... and then checking the Admin/Debug page to verify that it reports mod_rewrite is detected.

Alternatively, if you are running a setup where php is not loaded as a module, but is enabled via CGI (which prevents apache_get_modules() from working via PHP) -- then you can verify the rewrite module is properly detected in this case similarly with the Admin/Debug page, or in the initial ChurchCRM setup, if you have a blank database.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

This has been tested on a RockyLinux v8 install, using php via the php-fpm service.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Copy link
Contributor

@DawoudIO DawoudIO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this one A and one change before we merge

src/ChurchCRM/Service/AppIntegrityService.php Outdated Show resolved Hide resolved
@@ -213,6 +213,12 @@ public static function hasModRewrite(): bool
$check = in_array('mod_rewrite', apache_get_modules());
}
$logger->debug("Apache mod_rewrite check status: $check");
if (empty($check)) {
if (!empty(shell_exec('/usr/sbin/apachectl -M | grep rewrite'))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we catch errors from shell_exec and ignore

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will double check behavior, but I thought I read that any errors would naturally be ignored, so not sure what action could be taken.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have verified that errors simply result in an empty output from shell_exec() -- so this should cause no problems if the path is wrong, it just won't be able to detect the module. I have verified that on Windows also -- though I think often in the Windows setup php would be a module within apache, and this bit of code would never be executed.

@DAcodedBEAT DAcodedBEAT merged commit fcab566 into master Mar 24, 2024
4 checks passed
@DAcodedBEAT DAcodedBEAT deleted the 6910-bug-minor-mod_rewrite-presence-not-properly-detected-when-using-cgi-instead-of-apache-module branch March 24, 2024 05:50
@DAcodedBEAT DAcodedBEAT added this to the 5.7.0 milestone Apr 3, 2024
@DAcodedBEAT DAcodedBEAT added the php Pull requests that update Php code label Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
php Pull requests that update Php code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: minor: mod_rewrite presence not properly detected when using CGI instead of apache module
3 participants