Skip to content

Add quoting and escaping, fix off settings skipped, fix completely wrong diff if multiple .ini loaded#76

Closed
kkmuffme wants to merge 3 commits into
sebastianbergmann:8.0from
kkmuffme:add-escaping
Closed

Add quoting and escaping, fix off settings skipped, fix completely wrong diff if multiple .ini loaded#76
kkmuffme wants to merge 3 commits into
sebastianbergmann:8.0from
kkmuffme:add-escaping

Conversation

@kkmuffme
Copy link
Copy Markdown

@kkmuffme kkmuffme commented Jan 9, 2026

  • Fix Ini setting with special chars breaks parsing #64 by adding appropriate quoting and escaping
  • "off" values are simply ignored too for whatever reason...
  • it's wrong if no ini loaded at all
  • it unnecessarily sets values if they are not set in all ini files, but instead it should check if it's set in any ini file. This currently leads to the returned current settings array being about n*m (number of options * number of ini files loaded) times larger than necessary
  • the existing tests are lacking, and they continue to do so (since there's no way to create an ini and load it in the test to test for the "=" values and/or no ini and/or value only set in some ini files)

@kkmuffme kkmuffme marked this pull request as ready for review January 9, 2026 03:21
@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 9, 2026

Codecov Report

❌ Patch coverage is 81.25000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 48.90%. Comparing base (ebf5d96) to head (c535104).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/Runtime.php 81.25% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##                8.0      #76      +/-   ##
============================================
+ Coverage     48.46%   48.90%   +0.44%     
- Complexity       73       74       +1     
============================================
  Files             2        2              
  Lines           130      137       +7     
============================================
+ Hits             63       67       +4     
- Misses           67       70       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sebastianbergmann
Copy link
Copy Markdown
Owner

Thank you for working on this! Please send this against the 8.0 branch and resolve the issues identified by static analysis.

@kkmuffme kkmuffme changed the base branch from main to 8.0 January 9, 2026 16:18
@kkmuffme
Copy link
Copy Markdown
Author

kkmuffme commented Jan 9, 2026

Done

@sebastianbergmann
Copy link
Copy Markdown
Owner

Done

Thank you.

Please remove the commits cc73110 and c95c8b0 from your pull request as these must not go into the 8.0 branch.

When I run the tests locally with your changes applied then I get

1) SebastianBergmann\Environment\RuntimeTest::testGetCurrentSettingsReturnsCorrectDiffIfXdebugValuesArePassed
Failed asserting that an array has the key 'xdebug.mode'.

/path/to/environment/tests/RuntimeTest.php:143

Do you have an idea why that may be?

@kkmuffme
Copy link
Copy Markdown
Author

Please remove the commits cc73110 and c95c8b0 from your pull request as these must not go into the 8.0 branch.

Somehow github added those by itself when changing the PRs merge base. I rebased the branch onto your changes from 8.0 from yesterday and undid github's mess up.

When I run the tests locally with your changes applied
Do you have an idea why that may be?

I do, and the reason for it is described in my last sentence of the PR, with the reason it fails now (but didn't fail previously) being the 2nd last sentence.
Essentially: if the ini setting matches the current setting (= the setting is not overwritten in the runtime with a -d) it is expected that it's empty. Since otherwise (= the wrong behavior it has before the PR) all .ini settings are returned as diff if you have more than 1 .ini.

As method description of getCurrentSettings states:

whether this setting has been changed at runtime

Since you didn't change the xdebug.mode setting at runtime with -d it wasn't returned anymore now.

@sebastianbergmann
Copy link
Copy Markdown
Owner

Thank you for the explanation. Do you want to make the test more robust or should I take care of that?

@kkmuffme
Copy link
Copy Markdown
Author

Since it affects all the tests here and I still have lots of other pending PRs atm, I would appreciate if you could do it, since I'm not sure when I will have time to actually fix it and would be holding things up for quite some while otherwise.

@sebastianbergmann
Copy link
Copy Markdown
Owner

As strange as it may sound, I don't know how to improve these tests. This library is a collection of edge cases that continue to cut me. Do you have an idea? Thanks!

@kkmuffme
Copy link
Copy Markdown
Author

Welcome to my life :-) Since I mostly handle and PR edge cases, I have this issue all the time and many repo's insistence on tests doesn't make it easier (sebastianbergmann/phpunit#5852 is a fix to fix just one example of these edge case scenarios)

Anyway, in this specific case, the issue is:

since there's no way to create an ini and load it in the test to test for the "=" values and/or no ini and/or value only set in some ini files

Afair github actions/any CI allows specifying additional .ini files for PHP don't they? You could create 2 new .ini that are used in the CI, set values there (some only in 1 ini, some in both ini, some with Off, some with On, some with Off in both .ini, some with On in both ini, some with On in 1 ini) and then check the values of the ini + 1 value that is not in the ini whether they exist in array or not
That should make them reproducable at least in the CI? (when not using it in the CI the issue obviously persists)

@sebastianbergmann
Copy link
Copy Markdown
Owner

Superseded by #77.

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.

Ini setting with special chars breaks parsing

2 participants