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

Comparison error in apache::mod::php when RedHat and PHP 8 #2332

Closed
polatsinan opened this issue Oct 12, 2022 · 0 comments · Fixed by #2333
Closed

Comparison error in apache::mod::php when RedHat and PHP 8 #2332

polatsinan opened this issue Oct 12, 2022 · 0 comments · Fixed by #2333

Comments

@polatsinan
Copy link
Contributor

polatsinan commented Oct 12, 2022

Describe the Bug

When $php_version is set to 8.0 and the OS is RedHat, the wrong php library is being loaded due to an incorrect comparison.

It should load libphp.so, but instead it tries to load libphp8.0.so.

The problem is in line 96:

$_php_major = regsubst($php_version, '^(\d+)\..*$', '\1')
$_php_version_no_dot = regsubst($php_version, '\.', '')
if $apache::version::scl_httpd_version {
$_lib = "librh-php${_php_version_no_dot}-php${_php_major}.so"
} elsif ($facts['os']['family'] == 'RedHat') and ($_php_major == 8) {
# RedHat + PHP 8 drop the major version in apache module name.
$_lib = "${libphp_prefix}.so"
} else {
$_lib = "${libphp_prefix}${php_version}.so"
}

Line 92 returns a string (so $_php_major is a string), but in line 96 it is comparing it to an integer.

A fix could be replacing line 96 with (adding single quotes to 8:
} elsif ($facts['os']['family'] == 'RedHat') and ($_php_major == '8') {
or even replace it with:
} elsif ($facts['os']['family'] == 'RedHat') and (versioncmp($php_version, '8') >= 0) {
like it is done on line 47:

if ($facts['os']['family'] == 'RedHat') and (versioncmp($php_version, '8') >= 0) {

I can create a PR if the bug is accepted as a bug.

Expected Behavior

The correct php library (libphp.so) should be loaded when using RedHat + PHP 8.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Set $php_version to 8.0 in a RHEL environment.

Environment

  • Puppetlabs/apache 8.1.0
  • RHEL 8.6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants