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

INI values with embedded commas parsed incorrectly #392

Closed
3 of 5 tasks
bishopb opened this issue Jan 12, 2021 · 7 comments
Closed
3 of 5 tasks

INI values with embedded commas parsed incorrectly #392

bishopb opened this issue Jan 12, 2021 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@bishopb
Copy link

bishopb commented Jan 12, 2021

Describe the bug

XDebug 3 supports an xdebug.mode INI setting whose values may be a comma-separated list: for example, xdebug.mode=develop,gcstats,coverage.

However, SPC fails to correctly parse this INI option:

$ spc --ini-values 'xdebug.mode=develop,gcstats,coverage'
<snip>
==> Add php.ini values
✓ xdebug.mode=develop Added to php.ini
✓ gcstats Added to php.ini
✓ coverage Added to php.ini

That's because the CSVArray method unconditionally splits on a comma, without first understanding that the comma is used in the value itself.

Version

  • I have checked releases, and the bug exists in the latest patch version of v1 or v2.
  • v2
  • v1

Runners

  • GitHub Hosted
  • Self Hosted

Operating systems

Ubuntu, MacOS, and Windows

PHP versions

5.5+, though this particular issue with xdebug.mode only applies to 7.3+ with XDebug 3.

To Reproduce

In YAML, this would be represented as:

- uses: shivammathur/setup-php@v2                                       
  with:                                                                 
    ini-values: xdebug.mode=develop,gcstats,coverage         

Expected behavior

When support for INI values with commas is available, I would expect the INI file to have a single INI value added, whose value is exactly as given. Thus, if the INI given is "x=a,b" I would expect the INI file to have exactly that one line. Today, however, the INI file gets two lines: "x=a" followed by "b".

Additional Context

There are many other INI values that could technically have a comma in them: any ones dealing with file paths, dates, times, monetary values, MIME types, user-facing prompts, and PDO DSN. For a concrete example, consider url_rewriter.hosts:

url_rewriter.hosts string
url_rewriter.hosts specifies which hosts are rewritten to include output_add_rewrite_var() values. Defaults to
$_SERVER['HTTP_HOST']. Multiple hosts can be specified by ",", no space is allowed between hosts. e.g.
php.net,wiki.php.net,bugs.php.net

Consequently, I don't think this is a niche problem, but rather one that is an edge case.

Are you willing to submit a PR?

Yes.

@bishopb bishopb added the bug Something isn't working label Jan 12, 2021
@shivammathur
Copy link
Owner

@bishopb
I have added a patch (c9e1d2c) to support quoted csv in ini-values input. So now it won't split commas inside quotes.

For example, this would work.

ini-values: xdebug.mode="develop,gcstats,coverage", date.timezone=UTC

Before I merge this, can you test this using the develop branch (shivammathur/setup-php@develop)

@bishopb
Copy link
Author

bishopb commented Jan 13, 2021

Confirmed, the patch works as described. Thank you!

@bishopb bishopb changed the title INI values with embedded commas parsed correctly INI values with embedded commas parsed incorrectly Jan 13, 2021
bishopb pushed a commit to rollbar/rollbar-php that referenced this issue Jan 13, 2021
To get the XDebug 3 INI setting we need, we require a bug fix branch
from upstream. Switch to that for now.

@see shivammathur/setup-php#392
@shivammathur
Copy link
Owner

@bishopb Thanks for testing. Merged and updated v2.

bishopb pushed a commit to rollbar/rollbar-php that referenced this issue Jan 13, 2021
Upstream fixed a bug with parsing comma-separated INI values, but
requires quoting the value. This commit adds that necessary
quoting.

@see shivammathur/setup-php#392
@smichae
Copy link

smichae commented Jan 15, 2021

@shivammathur This seems to have broken a build where pcov.directory and pcov.exclude are set in ini-values. I've attempted with the escape and without, as well as with single quotes, but nothing seems to work any more - it was working up until a few days ago.
pcov.exclude=\"~(excluded|regex)~\"

@smichae
Copy link

smichae commented Jan 15, 2021

@shivammathur
Here's a sample of what I've been using:

      - uses: shivammathur/setup-php@v2
        with:
          php-version: 7.4
          coverage: pcov
          ini-values: memory_limit=-1, pcov.directory=/home/runner/work/jobname/jobname, pcov.exclude=\"~(.tests|vendor)~\"
          extensions: curl, gd, gmp, intl, json, mbstring, memcached, pcov, readline, xml, zip

Yes, I believe the quotes are required for pcov to properly parse the exclude.

And in case it helps, the error I'm getting in the actions readout: /opt/hostedtoolcache/linux.sh: line 343: syntax error near unexpected token `('

@shivammathur
Copy link
Owner

working on a fix

@shivammathur
Copy link
Owner

@smichae
Fixed, you do not need to escape the quotes. It will work now.

ini-values: pcov.directory=/home/runner/work/jobname/jobname, pcov.exclude="~(.tests|vendor)~"

Test-workflow: https://github.com/shivammathur/test-setup-php/actions/runs/487480158/workflow

On a side note memory_limit is set to -1 for all configurations by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants