Skip to content

[FrameworkBundle] add --deprecations on debug:container command #32584

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

Conversation

Simperfit
Copy link
Contributor

@Simperfit Simperfit commented Jul 17, 2019

Q A
Branch? 4.4
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #30089
License MIT
Doc PR todo

Two question for this:

  • is a table output enough ?
  • do we need to create a trait to share the code to the cache:warmup ? or maybe add a notice if there deprecation to check them with this command ?

Edit: new output
Capture d’écran de 2019-07-17 23-15-27

@Simperfit Simperfit force-pushed the feature/add-debug-deprecations-command branch 2 times, most recently from e504ade to 2728a8d Compare July 17, 2019 17:07
@yceruto yceruto added this to the next milestone Jul 17, 2019
@Simperfit Simperfit force-pushed the feature/add-debug-deprecations-command branch 3 times, most recently from 5f14174 to ad4acac Compare July 17, 2019 17:49
Copy link
Member

@yceruto yceruto left a comment

Choose a reason for hiding this comment

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

When the deprecation message is too large, the output is unreadable. Could we format that message? or do we have an option in the table helper to set the width of the column?

BTW very useful command, thanks!

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Jul 17, 2019

I would remove the table and take inspiration from the reports from the bridge if that makes sense.
Also, the name might be confusing: this is only about deprecations triggered during compile+warmup. There can be many more.

@Simperfit
Copy link
Contributor Author

Simperfit commented Jul 17, 2019 via email

@Simperfit Simperfit force-pushed the feature/add-debug-deprecations-command branch 3 times, most recently from ed04eb3 to b21cc72 Compare July 17, 2019 21:23
@Simperfit
Copy link
Contributor Author

@nicolas-grekas updated according to the bridge

@Simperfit Simperfit changed the title [FrameworkBundle] add debug:deprecations command [FrameworkBundle] add debug:warmed-deprecations command Jul 17, 2019
@Simperfit Simperfit changed the title [FrameworkBundle] add debug:warmed-deprecations command [FrameworkBundle] add debug:deprecations:warmed command Jul 18, 2019
@Simperfit Simperfit force-pushed the feature/add-debug-deprecations-command branch 3 times, most recently from 4f156ea to 43f18cd Compare July 18, 2019 11:48
@Simperfit
Copy link
Contributor Author

cc @yceruto WDYT ?

@Simperfit Simperfit force-pushed the feature/add-debug-deprecations-command branch from 43f18cd to c27ad7a Compare July 23, 2019 06:50
@nicolas-grekas
Copy link
Member

nicolas-grekas commented Jul 23, 2019

Wait, are deprecations triggered during warmup really added to Deprecations.log?

@Simperfit
Copy link
Contributor Author

Simperfit commented Jul 23, 2019

@nicolas-grekas I've taken this finally close into account in order to get the serialized data and the path of the file I wanted to use:

if ($this->debug && true !== $previousHandler) {
restore_error_handler();
if (file_exists($this->deprecationLogsFilepath)) {
$previousLogs = unserialize(file_get_contents($this->deprecationLogsFilepath));
$collectedLogs = array_merge($previousLogs, $collectedLogs);
}
file_put_contents($this->deprecationLogsFilepath, serialize(array_values($collectedLogs)));

I think this is really the deprecation collected during cache warmup.

@nicolas-grekas
Copy link
Member

Oh, sorry I forgot about that :)
So, does this contains deprecations for container compilation too?

@Simperfit
Copy link
Contributor Author

Since we collect the same logs during container compilations, I think it does too

@nicolas-grekas
Copy link
Member

So do, debug:container --deprecations ?

@Simperfit Simperfit force-pushed the feature/add-debug-deprecations-command branch from c27ad7a to 77d5061 Compare July 23, 2019 12:12
@Simperfit Simperfit force-pushed the feature/add-debug-deprecations-command branch from 8ba1bda to 6f00187 Compare August 9, 2019 11:39
@Simperfit
Copy link
Contributor Author

PR rebased and comments fixed.

@Simperfit
Copy link
Contributor Author

cc @yceruto

@Simperfit
Copy link
Contributor Author

Simperfit commented Aug 14, 2019

PR updated and ready !

@fabpot
Copy link
Member

fabpot commented Aug 18, 2019

Why don't we supported all formats (JSON, Markdown and XML)?

@Simperfit
Copy link
Contributor Author

I don't see the need of getting this information in JSON for example ATM.

@fabpot
Copy link
Member

fabpot commented Aug 19, 2019

The support for many formats is for integration with third-party tools.

@fabpot
Copy link
Member

fabpot commented Sep 27, 2019

@Simperfit Do you have to finish this PR? We won't merge it if we don't support all formats. Or maybe someone else can take over to finish it, it should not be too time consuming.

@nicolas-grekas nicolas-grekas force-pushed the feature/add-debug-deprecations-command branch from 4b62442 to 9a97e33 Compare September 27, 2019 16:46
@nicolas-grekas
Copy link
Member

FYI, I rebased your branch
Small remaining details: when I run the command,the output shows
To search for a specific service, [...] at the end, that should be removed.

$formattedLogs = [];
$remainingCount = 0;
foreach ($logs as $log) {
$formattedLogs[] = sprintf("%sx: %s \n in %s:%s", $log['count'], $log['message'], $log['file'], $log['line']);
Copy link
Member

Choose a reason for hiding this comment

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

we should use <href=%s>%s:%d</> here, to generate IDE links (which means using the FileLinkFormatter service to compute it)

@@ -143,6 +146,11 @@ protected function write($content, $decorated = false)
*/
abstract protected function describeContainerServices(ContainerBuilder $builder, array $options = []);

/**
* Describes container deprecations.
*/
Copy link
Member

Choose a reason for hiding this comment

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

can be removed

@@ -149,6 +154,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
} elseif ($name = $input->getArgument('name')) {
$name = $this->findProperServiceName($input, $errorIo, $object, $name, $input->getOption('show-hidden'));
$options = ['id' => $name];
} elseif ($input->getOption('deprecations')) {
$options = ['deprecations' => true];
Copy link
Member

Choose a reason for hiding this comment

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

validateInput() needs to be updated to forbid combining this option with others.

@nicolas-grekas nicolas-grekas added the Help wanted Issues and PRs which are looking for volunteers to complete them. label Feb 4, 2020
@fabpot
Copy link
Member

fabpot commented Feb 4, 2020

Any news here? Anyone willing to take over?

@nicolas-grekas
Copy link
Member

Closing as stale, anyone willing to help, please start from this PR.

@noemi-salaun
Copy link
Contributor

I'll try implementing missing formats (md, json and xml)

nicolas-grekas added a commit that referenced this pull request Mar 13, 2020
…r command (Simperfit, noemi-salaun)

This PR was merged into the 5.1-dev branch.

Discussion
----------

[FrameworkBundle] add --deprecations on debug:container command

| Q             | A
| ------------- | ---
| Branch?       | master (5.1)
| Bug fix?      | no
| New feature?  | yes <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | #30089  <!-- prefix each issue number with "Fix #", if any -->
| License       | MIT
| Doc PR        | todo

_I apologize in advance, I am not fluent in English_

Continuity of @Simperfit work from his PR #32584

I added support for XML, JSON and markdown formats as well as unit tests for all formats.

## XML format

```xml
<?xml version="1.0" encoding="UTF-8"?>
<deprecations remainingCount="5">
  <deprecation count="3">
    <message>Some deprecation message.</message>
    <file>/path/to/some/file.php</file>
    <line>39</line>
  </deprecation>
  <deprecation count="2">
    <message>An other deprecation message.</message>
    <file>/path/to/an/other/file.php</file>
    <line>25</line>
  </deprecation>
</deprecations>
```

## JSON format

```json
{
  "remainingCount": 5,
  "deprecations": [
    {
      "message": "Some deprecation message.",
      "file": "\/path\/to\/some\/file.php",
      "line": 39,
      "count": 3
    },
    {
      "message": "An other deprecation message.",
      "file": "\/path\/to\/an\/other\/file.php",
      "line": 25,
      "count": 2
    }
  ]
}
```

## Markdown format

## Remaining deprecations (5)

- 3x: "Some deprecation message." in /path/to/some/file.php:39
- 2x: "An other deprecation message." in /path/to/an/other/file.php:25

I added a new commit on top of @Simperfit 's one, but I don't know how you would like to have the git history writed.

Commits
-------

ee6391e [FrameworkBundle] add all formats support for debug:container --deprecations command
161f659 [FrameworkBundle] add --deprecations on debug:container command
@nicolas-grekas nicolas-grekas modified the milestones: next, 5.1 May 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature FrameworkBundle Help wanted Issues and PRs which are looking for volunteers to complete them. Status: Needs Work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants