Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Form] Bug in debug:form command #25394

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

Closed
maidmaid opened this issue Dec 8, 2017 · 10 comments
Closed

[Form] Bug in debug:form command #25394

maidmaid opened this issue Dec 8, 2017 · 10 comments

Comments

@maidmaid
Copy link
Contributor

maidmaid commented Dec 8, 2017

Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 4.0.0
➜  tmp.3oyTrHIJZT git:(master) php bin/console debug:form Symfony\\Component\\Form\\Extension\\Core\\Type\\ChoiceType -v

Symfony\Component\Form\Extension\Core\Type\ChoiceType (Block prefix: "choice")
==============================================================================

2017-12-08T21:11:24+10:00 [error] Error thrown while running command "debug:form 'Symfony\Component\Form\Extension\Core\Type\ChoiceType' -v". Message: "Warning: strstr() expects parameter 1 to be string, array given"

In Table.php line 413:

  [ErrorException]
  Warning: strstr() expects parameter 1 to be string, array given


Exception trace:
 Symfony\Component\Console\Helper\Table->buildTableRows() at /tmp/tmp.3oyTrHIJZT/vendor/symfony/console/Helper/Table.php:277
 Symfony\Component\Console\Helper\Table->render() at /tmp/tmp.3oyTrHIJZT/vendor/symfony/console/Style/SymfonyStyle.php:189
 Symfony\Component\Console\Style\SymfonyStyle->table() at /tmp/tmp.3oyTrHIJZT/vendor/symfony/form/Console/Descriptor/TextDescriptor.php:86
 Symfony\Component\Form\Console\Descriptor\TextDescriptor->describeResolvedFormType() at /tmp/tmp.3oyTrHIJZT/vendor/symfony/form/Console/Descriptor/Descriptor.php:55
 Symfony\Component\Form\Console\Descriptor\Descriptor->describe() at /tmp/tmp.3oyTrHIJZT/vendor/symfony/console/Helper/DescriptorHelper.php:69
 Symfony\Component\Console\Helper\DescriptorHelper->describe() at /tmp/tmp.3oyTrHIJZT/vendor/symfony/form/Command/DebugCommand.php:137
 Symfony\Component\Form\Command\DebugCommand->execute() at /tmp/tmp.3oyTrHIJZT/vendor/symfony/console/Command/Command.php:252
 Symfony\Component\Console\Command\Command->run() at /tmp/tmp.3oyTrHIJZT/vendor/symfony/console/Application.php:872
 Symfony\Component\Console\Application->doRunCommand() at /tmp/tmp.3oyTrHIJZT/vendor/symfony/framework-bundle/Console/Application.php:83
 Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /tmp/tmp.3oyTrHIJZT/vendor/symfony/console/Application.php:233
 Symfony\Component\Console\Application->doRun() at /tmp/tmp.3oyTrHIJZT/vendor/symfony/framework-bundle/Console/Application.php:71
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /tmp/tmp.3oyTrHIJZT/vendor/symfony/console/Application.php:143
 Symfony\Component\Console\Application->run() at /tmp/tmp.3oyTrHIJZT/bin/console:39

debug:form [--format FORMAT] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command> [<class>] [<option>]
@Simperfit
Copy link
Contributor

@maidmaid I can reproduce but only on 4.0.*, on 4.1@dev it does not trigger an error. I don't see any differences in the code.

I'm will be trying to provide a fix, but it seems that we could do better than what I though, by searching to root cause instead of fixing the error directly. Creating the PR just now.

@Simperfit
Copy link
Contributor

Status: Reviewed

@yceruto
Copy link
Member

yceruto commented Dec 8, 2017

I can't reproduce the bug either. @maidmaid could you please show a full dump($options) output just before this line?:

@yceruto
Copy link
Member

yceruto commented Dec 8, 2017

@maidmaid does this problem happen only with ChoiceType?

@Simperfit
Copy link
Contributor

Simperfit commented Dec 8, 2017

The dump of options

array(4) {
  ["own"]=>
  array(11) {
    [0]=>
    string(25) "choice_translation_domain"
    [1]=>
    string(4) "days"
    [2]=>
    string(6) "format"
    [3]=>
    string(5) "html5"
    [4]=>
    string(5) "input"
    [5]=>
    string(14) "model_timezone"
    [6]=>
    string(6) "months"
    [7]=>
    string(11) "placeholder"
    [8]=>
    string(13) "view_timezone"
    [9]=>
    string(6) "widget"
    [10]=>
    string(5) "years"
  }
  ["overridden"]=>
  array(6) {
    [0]=>
    string(21) "<info>FormType</info>"
    [1]=>
    object(Symfony\Component\Console\Helper\TableSeparator)#154 (2) {
      ["value":"Symfony\Component\Console\Helper\TableCell":private]=>
      string(0) ""
      ["options":"Symfony\Component\Console\Helper\TableCell":private]=>
      array(2) {
        ["rowspan"]=>
        int(1)
        ["colspan"]=>
        int(1)
      }
    }
    [2]=>
    string(12) "by_reference"
    [3]=>
    string(8) "compound"
    [4]=>
    string(10) "data_class"
    [5]=>
    string(14) "error_bubbling"
  }
  ["parent"]=>
  array(21) {
    [0]=>
    string(21) "<info>FormType</info>"
    [1]=>
    object(Symfony\Component\Console\Helper\TableSeparator)#157 (2) {
      ["value":"Symfony\Component\Console\Helper\TableCell":private]=>
      string(0) ""
      ["options":"Symfony\Component\Console\Helper\TableCell":private]=>
      array(2) {
        ["rowspan"]=>
        int(1)
        ["colspan"]=>
        int(1)
      }
    }
    [2]=>
    string(6) "action"
    [3]=>
    string(4) "attr"
    [4]=>
    string(15) "auto_initialize"
    [5]=>
    string(10) "block_name"
    [6]=>
    string(4) "data"
    [7]=>
    string(8) "disabled"
    [8]=>
    string(10) "empty_data"
    [9]=>
    string(12) "inherit_data"
    [10]=>
    string(5) "label"
    [11]=>
    string(10) "label_attr"
    [12]=>
    string(12) "label_format"
    [13]=>
    string(6) "mapped"
    [14]=>
    string(6) "method"
    [15]=>
    string(21) "post_max_size_message"
    [16]=>
    string(13) "property_path"
    [17]=>
    string(8) "required"
    [18]=>
    string(18) "translation_domain"
    [19]=>
    string(4) "trim"
    [20]=>
    string(23) "upload_max_size_message"
  }
  ["extension"]=>
  &array(1) {
    [0]=>
    array(0) {
    }
  }
}

The whole stack with DateType :

Symfony\Component\Form\Extension\Core\Type\DateType (Block prefix: "date")
==========================================================================

2017-12-08T14:20:16+00:00 [error] Error thrown while running command "debug:form 'Symfony\Component\Form\Extension\Core\Type\DateType' -v". Message: "Warning: strstr() expects parameter 1 to be string, array given"

In Table.php line 413:
                                                                   
  [ErrorException]                                                 
  Warning: strstr() expects parameter 1 to be string, array given  
                                                                   

Exception trace:
 Symfony\Component\Console\Helper\Table->buildTableRows() at /Users/hamza/projet/workflow/vendor/symfony/console/Helper/Table.php:277
 Symfony\Component\Console\Helper\Table->render() at /Users/hamza/projet/workflow/vendor/symfony/console/Style/SymfonyStyle.php:189
 Symfony\Component\Console\Style\SymfonyStyle->table() at /Users/hamza/projet/workflow/vendor/symfony/form/Console/Descriptor/TextDescriptor.php:86
 Symfony\Component\Form\Console\Descriptor\TextDescriptor->describeResolvedFormType() at /Users/hamza/projet/workflow/vendor/symfony/form/Console/Descriptor/Descriptor.php:55
 Symfony\Component\Form\Console\Descriptor\Descriptor->describe() at /Users/hamza/projet/workflow/vendor/symfony/console/Helper/DescriptorHelper.php:69
 Symfony\Component\Console\Helper\DescriptorHelper->describe() at /Users/hamza/projet/workflow/vendor/symfony/form/Command/DebugCommand.php:137
 Symfony\Component\Form\Command\DebugCommand->execute() at /Users/hamza/projet/workflow/vendor/symfony/console/Command/Command.php:252
 Symfony\Component\Console\Command\Command->run() at /Users/hamza/projet/workflow/vendor/symfony/console/Application.php:872
 Symfony\Component\Console\Application->doRunCommand() at /Users/hamza/projet/workflow/vendor/symfony/framework-bundle/Console/Application.php:83
 Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /Users/hamza/projet/workflow/vendor/symfony/console/Application.php:233
 Symfony\Component\Console\Application->doRun() at /Users/hamza/projet/workflow/vendor/symfony/framework-bundle/Console/Application.php:71
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /Users/hamza/projet/workflow/vendor/symfony/console/Application.php:143
 Symfony\Component\Console\Application->run() at /Users/hamza/projet/workflow/bin/console:39

debug:form [--format FORMAT] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command> [<class>] [<option>]

@yceruto with the patch provided it does fix it, but I feels like it's not the right fix ;).

Do you want the $options on the 4.1 to compare ?

@yceruto
Copy link
Member

yceruto commented Dec 8, 2017

with the patch provided it does fix it, but I feels like it's not the right fix ;).

Yep, I also feel it. The great news is that I see the problem now:

  ["extension"]=>
  &array(1) {
    [0]=>
    array(0) {
    }
  }

So I'm working on the solution, thanks for the var_dump() output.

@yceruto
Copy link
Member

yceruto commented Dec 8, 2017

See #25404

@yceruto
Copy link
Member

yceruto commented Dec 8, 2017

Since the debug command was not registering with all the information it needs (fixed in #25396), we found this error, every cloud has a silver lining! :)

@Simperfit
Copy link
Contributor

@xabbuh This issue can be closed since the PR has been merged.

@yceruto
Copy link
Member

yceruto commented Dec 16, 2017

Still open #25404 which guarantees that there will be no empty groups in the future.

@fabpot fabpot closed this as completed Dec 31, 2017
fabpot added a commit that referenced this issue Dec 31, 2017
…mand (yceruto)

This PR was merged into the 3.4 branch.

Discussion
----------

[Form] Remove group options without data on debug:form command

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #25394
| License       | MIT
| Doc PR        | -

This also fix the normalization of the options column for text descriptor, regardless of changes in `collectOptions()` method (which is enough to fix the related bug).

@maidmaid could you confirm if these changes solve the problem?

Commits
-------

083c8af Remove group options without data and fix normalization
chalasr pushed a commit that referenced this issue Jan 25, 2018
…perfit)

This PR was merged into the 3.4 branch.

Discussion
----------

[Console] Provide a DX where an array could be passed

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md files -->
| Tests pass?   | yes
| Fixed tickets | #25394
| License       | MIT
| Doc PR        | none

![img_2941](https://user-images.githubusercontent.com/3451634/33766610-977f77ce-dc1e-11e7-93c1-38dd0038d7f5.jpeg)

I think that this is not fixing the root causes that does not appears in 4.1, so maybe there is something better to do. I did not find the root cause So I think it can bo good to fix the problem too.

Commits
-------

de502f7 [Console] Provide a bugfix where an array could be passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants