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

Extract the profiler to a new component #2

Closed
wants to merge 1 commit into from
Closed

Extract the profiler to a new component #2

wants to merge 1 commit into from

Conversation

jelte
Copy link
Owner

@jelte jelte commented May 27, 2015

This pull request is a replacement for symfony#10374

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? yes
Tests pass? yes
Fixed tickets n/a
License MIT
Doc PR not use how to handle documentation

This pull request extracts the HTTP profiler from the HttpKernel component to a new dedicated component: Profiler.

The goals are to improve the general architecture and usability of the component as stated by @webmozart ( symfony#10374 (comment) )
as it stands now no BC is broken as the original DataCollectors are still supported by the new Profiler.

New DataCollectors and Profiler no longer require a Request and Response.
DataCollectors are should be able to collect data from other sources, which will prevent some ugly hacks that were previously required, they will still require to listen to events to collect the data, I don't see a way around this, but this doesn't seem a big issue.

If a DataCollector requires the Request, it should have the RequestStack and get it from there, the Responses can be added just like Controllers are added, by subscribing to the Kernel Events.

$httpProfiler = new HttpProfiler($requestStack, $storageInterface);
$httpProfiler->addCollector(new RequestDataCollector($requestStack));
$httpProfiler->addCollector(new ExceptionDataCollector());
$httpProfiler->addCollector(new FormDataCollector());

// Runtime data is collected
$profile = $httpProfiler->collect();

$requestData = $profile->get('request');

// Late data is collected
$httpProfiler->save($profile);

To debate:

  • rename Profiler::collect() to Profiler::profile() or other name that makes slightly more sense. (+ would help on BC)
  • provide ConsoleProfiler, will require some interface changes to the WebProfiler or a console version

Todo's:

  • add additional tests especially for DataCollectors.
  • submit changes to the documentation
  • add significant readme
  • gather feedback for my changes

@jelte jelte closed this May 27, 2015
jelte pushed a commit that referenced this pull request Mar 14, 2016
…eprecation on-demand (nicolas-grekas)

This PR was merged into the 2.8 branch.

Discussion
----------

[Bridge\PhpUnit] Display the stack trace of a deprecation on-demand

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

This PR has been essential into making symfony#16708, and I think everyone working on a 3.0 migration will need this.

Example:

```
$ SYMFONY_DEPRECATIONS_HELPER=/FormExtensionBootstrap3LayoutTest/ ./phpunit src/Symfony/Bridge/Twig/
PHPUnit 4.8.18 by Sebastian Bergmann and contributors.

Testing src/Symfony/Bridge/Twig/
................................................
Remaining deprecation triggered by Symfony\Bridge\Twig\Tests\Extension\FormExtensionBootstrap3LayoutTest::testSingleChoiceGrouped:
The value "false" for the "choices_as_values" option is deprecated since version 2.8 and will not be supported anymore in 3.0. Set this option to "true" and flip the contents of the "choices" option instead.
Stack trace:
#0 src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php(286): trigger_error()
#1 src/Symfony/Component/OptionsResolver/OptionsResolver.php(962): Symfony\Component\Form\Extension\Core\Type\ChoiceType->Symfony\Component\Form\Extension\Core\Type\{closure}()
#2 src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php(277): Symfony\Component\OptionsResolver\OptionsResolver->offsetGet()
#3 src/Symfony/Component/OptionsResolver/OptionsResolver.php(962): Symfony\Component\Form\Extension\Core\Type\ChoiceType->Symfony\Component\Form\Extension\Core\Type\{closure}()
#4 src/Symfony/Component/OptionsResolver/OptionsResolver.php(791): Symfony\Component\OptionsResolver\OptionsResolver->offsetGet()
#5 src/Symfony/Component/Form/ResolvedFormType.php(156): Symfony\Component\OptionsResolver\OptionsResolver->resolve()
symfony#6 src/Symfony/Component/Form/FormFactory.php(119): Symfony\Component\Form\ResolvedFormType->createBuilder()
symfony#7 src/Symfony/Component/Form/FormFactory.php(48): Symfony\Component\Form\FormFactory->createNamedBuilder()
symfony#8 src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php(540): Symfony\Component\Form\FormFactory->createNamed()
symfony#9 [internal function]: Symfony\Component\Form\Tests\AbstractBootstrap3LayoutTest->testSingleChoiceGrouped()
symfony#10 {main}
KO src/Symfony/Bridge/Twig/
```

Commits
-------

5a88fb6 [Bridge\PhpUnit] Display the stack trace of a deprecation on-demand
jelte pushed a commit that referenced this pull request Mar 14, 2016
[Serializer] Use $context['cache_key'] to enhance caching
jelte pushed a commit that referenced this pull request Mar 14, 2016
…ble data (dunglas, nicolas-grekas)

This PR was merged into the 2.8 branch.

Discussion
----------

[Serializer] Allow context to contain not serializable data

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

Allow the context to contain not serializable data even for the `ObjectNormalizer` (BC break fix).

Commits
-------

996f69d Merge pull request #2 from nicolas-grekas/ser-cache
8560c13 [Serializer] Use $context['cache_key'] to enhance caching
c1740fc [Serializer] ObjectNormalizer: context can contain not serializable data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant