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

[DI] Removes number of elements information in debug mode #31371

Merged
merged 1 commit into from May 9, 2019

Conversation

jschaedl
Copy link
Contributor

@jschaedl jschaedl commented May 3, 2019

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

With this services config:

my_service:
    class: stdClass
    arguments: [!tagged my_tag]

my_tagged_service_1:
    class: stdClass
    tags: [my_tag]

my_tagged_service_2:
    class: stdClass
    tags: [my_tag]

Executing ./bin/console debug:container my_service --show-arguments --env=dev resulted in

Information for Service "my_service"
====================================

 ---------------- -------------------------
  Option           Value
 ---------------- -------------------------
  Service ID       my_service
  Class            stdClass
  Tags             -
  Public           no
  Synthetic        no
  Lazy             no
  Shared           yes
  Abstract         no
  Autowired        yes
  Autoconfigured   yes
  Arguments        Iterator (0 element(s))
 ---------------- -------------------------

With this fix the output changed to:

Information for Service "my_service"
====================================

 ---------------- ------------
  Option           Value
 ---------------- ------------
  Service ID       my_service
  Class            stdClass
  Tags             -
  Public           no
  Synthetic        no
  Lazy             no
  Shared           yes
  Abstract         no
  Autowired        yes
  Autoconfigured   yes
  Arguments        Tagged Iterator for "my_tag"
 ---------------- ------------

and with ./bin/console debug:container my_service --show-arguments --env=prod

Information for Service "my_service_tagged_iterator"
====================================================

 ---------------- ---------------------------------------------
  Option           Value
 ---------------- ---------------------------------------------
  Service ID       my_service
  Class            stdClass
  Tags             -
  Public           no
  Synthetic        no
  Lazy             no
  Shared           yes
  Abstract         no
  Autowired        yes
  Autoconfigured   yes
  Arguments        Tagged Iterator for "my_tag" (2 element(s))
 ---------------- ---------------------------------------------

@jschaedl jschaedl force-pushed the fix-issue-31340 branch 2 times, most recently from 249920f to 7e71b96 Compare May 3, 2019 10:21
@xabbuh xabbuh added this to the 3.4 milestone May 4, 2019
if ($argument instanceof TaggedIteratorArgument) {
$argumentsInformation[] = sprintf('Tagged Iterator for "%s" %s', $argument->getTag(), !$options['is_debug'] ? sprintf('(%d element(s))', \count($argument->getValues())) : '');
} else {
$argumentsInformation[] = $options['is_debug'] ? 'Iterator' : sprintf('Iterator (%d element(s))', \count($argument->getValues()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We maybe want to be consistent wether we handle the debug or the non-debug case first.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adjusted

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

displaying useful info is more important than "consistency" here to me

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

displaying useful info is more important than "consistency" here to me

@@ -337,9 +338,13 @@ protected function describeContainerDefinition(Definition $definition, array $op
$argument = $argument->getValues()[0];
}
if ($argument instanceof Reference) {
$argumentsInformation[] = sprintf('Service(%s)', (string) $argument);
$argumentsInformation[] = sprintf('Service (%s)', (string) $argument);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is unrelated and should be reverted - it can break scripts that parse the output

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully, such script should use the json or XML output, but yes, I still vote for reverting.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverted

if ($argument instanceof TaggedIteratorArgument) {
$argumentsInformation[] = sprintf('Tagged Iterator for "%s"%s', $argument->getTag(), $options['is_debug'] ? '': sprintf(' (%d element(s))', \count($argument->getValues())));
} else {
$argumentsInformation[] = sprintf('Iterator%s', $options['is_debug'] ? '' : sprintf(' (%d element(s))', \count($argument->getValues())));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really need the ternary on this line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right we don't need the ternary. The array of services given for the Iterator is always filled. Will revert it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

@Tobion Tobion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to be careful when merging this to master due to #31353.
The is_debug option to the can be remove again I guess.

@nicolas-grekas
Copy link
Member

Thank you @jschaedl.

@nicolas-grekas nicolas-grekas merged commit 0da4b83 into symfony:3.4 May 9, 2019
nicolas-grekas added a commit that referenced this pull request May 9, 2019
…(jschaedl)

This PR was squashed before being merged into the 3.4 branch (closes #31371).

Discussion
----------

[DI] Removes number of elements information in debug mode

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

With this services config:

```yaml
my_service:
    class: stdClass
    arguments: [!tagged my_tag]

my_tagged_service_1:
    class: stdClass
    tags: [my_tag]

my_tagged_service_2:
    class: stdClass
    tags: [my_tag]
```
Executing `./bin/console debug:container my_service --show-arguments --env=dev` resulted in

```bash
Information for Service "my_service"
====================================

 ---------------- -------------------------
  Option           Value
 ---------------- -------------------------
  Service ID       my_service
  Class            stdClass
  Tags             -
  Public           no
  Synthetic        no
  Lazy             no
  Shared           yes
  Abstract         no
  Autowired        yes
  Autoconfigured   yes
  Arguments        Iterator (0 element(s))
 ---------------- -------------------------
```
 With this fix the output changed to:

```bash
Information for Service "my_service"
====================================

 ---------------- ------------
  Option           Value
 ---------------- ------------
  Service ID       my_service
  Class            stdClass
  Tags             -
  Public           no
  Synthetic        no
  Lazy             no
  Shared           yes
  Abstract         no
  Autowired        yes
  Autoconfigured   yes
  Arguments        Tagged Iterator for "my_tag"
 ---------------- ------------
```

and with `./bin/console debug:container my_service --show-arguments --env=prod`

```bash
Information for Service "my_service_tagged_iterator"
====================================================

 ---------------- ---------------------------------------------
  Option           Value
 ---------------- ---------------------------------------------
  Service ID       my_service
  Class            stdClass
  Tags             -
  Public           no
  Synthetic        no
  Lazy             no
  Shared           yes
  Abstract         no
  Autowired        yes
  Autoconfigured   yes
  Arguments        Tagged Iterator for "my_tag" (2 element(s))
 ---------------- ---------------------------------------------
```

Commits
-------

0da4b83 [DI] Removes number of elements information in debug mode
This was referenced May 22, 2019
@jschaedl jschaedl deleted the fix-issue-31340 branch February 23, 2020 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants