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

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/ChurchCRM/Service/AppIntegrityService.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public static function hasModRewrite(): bool
// This header comes from index.php (which is the target of .htaccess for invalid URLs)

$check = false;
$logger = LoggerUtils::getAppLogger();
$logger = LoggerUtils::getAppLogger('DEBUG');

if (isset($_SERVER['HTTP_MOD_REWRITE'])) {
$logger->debug("Webserver configuration has set mod_rewrite variable: {$_SERVER['HTTP_MOD_REWRITE']}");
Expand All @@ -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.

$logger->debug('Found rewrite module enabled using apachectl');
$check = true;
}
}
} else {
$logger->debug('PHP is not running through Apache');
}
Expand Down
Loading