Repository navigation
Description
Disclaimer: AI-generated text below the line, generated by Claude Opus 5. The issue was found (by Claude) while working with pull request #768
Having the AI generate issues is cheap, reading and understanding them is not. I respect that some maintainers may want to close AI-generated issues without spending time on explaining why.
Affected Puppet, Ruby, OS and module versions/distributions
- Puppet: openvox 8 (Gemfile range
>= 7, < 9) - Ruby: 3.4.10
- Facter: 5.7.0
- Distribution: any
- Module version: master (12.0.1-rc0)
How to reproduce (e.g Puppet code you use)
The fact parses the first line of php -v only:
https://github.com/voxpupuli/puppet-php/blob/master/lib/facter/phpversion.rb
A php that emits a startup warning writes it to stdout before the version banner. A php on $PATH behaving like this is enough:
#!/bin/sh
echo "PHP Warning: Module 'imagick' already loaded in Unknown on line 0"
echo "PHP 8.2.7 (cli) (built: Jun 8 2023 20:03:25) (NTS)"
echo "Copyright (c) The PHP Group"What are you seeing
php on PATH: "/.../php"
php -v first line: "PHP Warning: Module 'imagick' already loaded in Unknown on line 0"
phpversion fact: nil
The fact resolves to nothing, silently — no version, no warning, no error in the log. Anything keying on $facts['phpversion'] sees an absent fact on a node where php is installed and working.
What behaviour did you expect instead
8.2.7, as on a node whose php starts cleanly. Scanning the whole output rather than the first line would do it, e.g. output[%r{^PHP (\d+\.\d+\.\d+\S*)}, 1] (^ is already per-line in Ruby).
Output log
No log output at all — that is part of the problem; the failure is silent.
Any additional information you'd like to impart
Pre-existing and unrelated to #768, which is about the fact raising when php is absent; that PR does not touch the parsing.
Two smaller things noticed in the same line, not worth their own issues:
- An RC build reports as
8.4.0RC1, since the match keeps the whole token. Probably wanted, but worth knowing. - The regex
%r{^(?:(\d+)\.)(?:(\d+)\.)?(\*|\d+)}has three capture groups nothing reads, and the\*alternative cannot matchphp -voutput.
Activity
tobixen commentedon Sep 18, 2026
I pushed Claude Opus a bit with this one:
So now this has been tested with actual PHP 8.2.33. The bug has been confirmed, but also narrowed down the problem to the land of "corner cases that we may not care about".
Real php does write startup warnings to stdout before printing the version banner. Feeding the exact bytes of a real
php -vinto the fact caused anilvalue to be returned. This is the real output observed:The research also found it to be a quite narrow corner case, most likely not going to hit a lot of production systems nor common distro packages. It depends on
display_errorsfor the CLI SAPI:php -vstdoutphp.ini(officialphp:8.2-cliimage)nilphp.ini-development(display_errors=On)nilphp.ini-production(display_errors=Off)8.2.33php-cli... so it may not be worth fixing, but scanning the whole output instead of the first line would still be a cheap fix.
(Disclaimer: text above is a human rewrite of a longer Claude-generated text. I may be wrong, but I believe I'm still better than Claude on this)