puppetlabs-apache icon indicating copy to clipboard operation
puppetlabs-apache copied to clipboard

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

Open polatsinan opened this issue 1 year ago • 0 comments

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:

https://github.com/puppetlabs/puppetlabs-apache/blob/6bc10727f32032133337ed5022ef5158b0358847/manifests/mod/php.pp#L92-L101

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: https://github.com/puppetlabs/puppetlabs-apache/blob/6bc10727f32032133337ed5022ef5158b0358847/manifests/mod/php.pp#L47

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

polatsinan avatar Oct 12 '22 09:10 polatsinan