Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Console] ArgvInput - Short command input using incorrect environment name #26136

Copy link
Copy link
Closed
@codereviewvideos

Description

@codereviewvideos
Issue body actions
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.4.5-DEV

There appears to be a bug here, but I haven't been able to figure out a solution.

The phpunit tests pass.

If I run bin/console cac:cl -e=dev I'm seeing:

PHP Warning:  strpos(): Empty needle in /var/www/api.codereviewvideos.dev/vendor/symfony/symfony/src/Symfony/Component/Console/Input/ArgvInput.php on line 291
PHP Stack trace:
PHP   1. {main}() /var/www/api.codereviewvideos.dev/bin/console:0
PHP   2. Symfony\Component\Console\Input\ArgvInput->hasParameterOption() /var/www/api.codereviewvideos.dev/bin/console:21
PHP   3. strpos() /var/www/api.codereviewvideos.dev/vendor/symfony/symfony/src/Symfony/Component/Console/Input/ArgvInput.php:291

The bigger issue is:

In FileLocator.php line 44:

  The file "/var/www/api.codereviewvideos.dev/app/config/config_=dev.yml" does not exist.

The =dev bit being the problem.

I tracked this down to the change below in getParameterOption.

return substr($token, strlen($leading));

Looking at the old code:

return substr($token, $pos + 1);

If I change to:

return substr($token, strlen($leading) + 1);

Then the command completes - but the strpos warnings remain.

I added the following just before the new return on line 321:

\Doctrine\Common\Util\Debug::dump([
    'value' => $value,
    'token' => $token,
    '0 === strpos($value, "--")' => 0 === strpos($value, '--'),
    'leading' => $leading,
    'strlen($leading)' => strlen($leading),
    'substr($token, strlen($leading))' => substr($token, strlen($leading) + 1),
]);

If I e.g. run the cache:clear command again I see:

array (size=6)
  'value' => string '-e' (length=2)
  'token' => string '-e=dev' (length=6)
  '0 === strpos($value, "--")' => boolean false
  'leading' => string '-e' (length=2)
  'strlen($leading)' => int 2
  'substr($token, strlen($leading))' => string 'dev' (length=3)

Looks good.

Now if I run the tests I see 8 failures (provideGetParameterOptionValues) e.g:

8) Symfony\Component\Console\Tests\Input\ArgvInputTest::testGetParameterOptionEqualSign with data set #13 (array('app/console', 'foo:bar', '--', '--env=dev'), '--env', false, 'dev')
->getParameterOption() returns the expected value
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'dev'
+'ev'

One extra thing, this only affects the short options (-e=dev), using the longer form (--env=dev) does not trigger this issue. However, the strpos(): Empty needle issue occurs for both long and short form.

Sorry I haven't been able to figure this out, but I hope this helps in some way in tracking down the root cause. Thank you for your time.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.