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

A string with a number could be passed as a boolean value #1435

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

stickeerehan
Copy link

get_cfg_var() evaluates "true" in php.ini to "1" which is not correctly parsed by the boolean parser.

Fixes issue raised on #1431.

@stickeerehan stickeerehan requested a review from a team as a code owner November 20, 2024 10:58
Copy link

welcome bot commented Nov 20, 2024

Thanks for opening your first pull request! If you haven't yet signed our Contributor License Agreement (CLA), then please do so that we can accept your contribution. A link should appear shortly in this PR if you have not already signed one.

Copy link

linux-foundation-easycla bot commented Nov 20, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

Copy link

codecov bot commented Nov 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.57%. Comparing base (8857b0c) to head (745d595).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #1435      +/-   ##
============================================
- Coverage     73.59%   73.57%   -0.03%     
- Complexity     2685     2687       +2     
============================================
  Files           387      387              
  Lines          7977     7981       +4     
============================================
+ Hits           5871     5872       +1     
- Misses         2106     2109       +3     
Flag Coverage Δ
8.1 ?
8.2 ?
8.3 ?
8.4 73.57% <100.00%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
.../SDK/Common/Configuration/Parser/BooleanParser.php 92.85% <100.00%> (+2.85%) ⬆️

... and 4 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8857b0c...745d595. Read the comment docs.

---- 🚨 Try these New Features:

@brettmc
Copy link
Collaborator

brettmc commented Nov 20, 2024

Hi @stickeerehan thanks for the contribution. We also need to be compliant with the OpenTelemetry spec as much as possible, and here we run into this part: https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/#boolean-value

Any value that represents a Boolean MUST be set to true only by the case-insensitive string "true", meaning "True" or "TRUE" are also accepted, as true. An implementation MUST NOT extend this definition and define additional values that are interpreted as true. Any value not explicitly defined here as a true value, including unset and empty values, MUST be interpreted as false.

Having a quick play with this:
php.ini:

my_bool = true
my_quoted_bool = "true"
$ php -a
Interactive shell

php > var_dump(get_cfg_var('my_bool'));
string(1) "1"
php > var_dump(get_cfg_var('my_quoted_bool'));
string(4) "true"

So, quoting boolean values in php.ini seems to work, and maybe we need to document that?

bobstrecansky
bobstrecansky previously approved these changes Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants