8000 feature #28939 [WebProfilerBundle] Remove application name (ro0NL) · symfony/symfony@07c46a2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 07c46a2

Browse files
feature #28939 [WebProfilerBundle] Remove application name (ro0NL)
This PR was squashed before being merged into the 4.2-dev branch (closes #28939). Discussion ---------- [WebProfilerBundle] Remove application name | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | yes | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | yes | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | #... <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> This fixes a regression in master, i think after #28809 (or something related) There's still a "application name" concept out there today, and it's `ConfigDataCollector::getApplicationName()` 🤔 In my case the service resolved to ```php $e = new \Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector(\basename('/app')); ``` Causing the app name to be, well, `app` (again :P). It was really confusing. Before: ![image](https://user-images.githubusercontent.com/1047696/47264761-fcb01980-d51c-11e8-9a3b-14a43d18b179.png) (the "a" is from "app" here) After: ![image](https://user-images.githubusercontent.com/1047696/47264767-16516100-d51d-11e8-8a5d-4c20d4911861.png) or ![image](https://user-images.githubusercontent.com/1047696/47264774-28cb9a80-d51d-11e8-8fe6-de0f46b06a1d.png) I think we need to deprecate the argument for real? cc @fabpot Commits ------- f5c355e [WebProfilerBundle] Remove application name
2 parents 73032f3 + f5c355e commit 07c46a2

File tree

7 files changed

+94
-100
lines changed

7 files changed

+94
-100
lines changed

UPGRADE-4.2.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,15 @@ HttpFoundation
111111
will respectively change from "false" to "null" and from "null" to "lax" in Symfony
112112
5.0, you should define their values explicitly or use "Cookie::create()" instead.
113113

114+
HttpKernel
115+
----------
116+
117+
* The `Kernel::getRootDir()` and the `kernel.root_dir` parameter have been deprecated
118+
* The `KernelInterface::getName()` and the `kernel.name` parameter have been deprecated
119+
* Deprecated the first and second constructor argument of `ConfigDataCollector`
120+
* Deprecated `ConfigDataCollector::getApplicationName()`
121+
* Deprecated `ConfigDataCollector::getApplicationVersion()`
122+
114123
FrameworkBundle
115124
---------------
116125

UPGRADE-5.0.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ HttpKernel
182182

183183
* The `Kernel::getRootDir()` and the `kernel.root_dir` parameter have been removed
184184
* The `KernelInterface::getName()` and the `kernel.name` parameter have been removed
185+
* Removed the first and second constructor argument of `ConfigDataCollector`
186+
* Removed `ConfigDataCollector::getApplicationName()`
187+
* Removed `ConfigDataCollector::getApplicationVersion()`
185188

186189
Monolog
187190
-------

src/Symfony/Bundle/FrameworkBundle/Resources/config/collectors.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@
1010
<service id="data_collector.config" class="Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector">
1111
<tag name="data_collector" template="@WebProfiler/Collector/config.html.twig" id="config" priority="-255" />
1212
<call method="setKernel"><argument type="service" id="kernel" on-invalid="ignore" /></call>
13-
<argument type="service">
14-
<service class="string">
15-
<factory function="basename" />
16-
<argument>%kernel.project_dir%</argument>
17-
</service>
18-
</argument>
1913
</service>
2014

2115
<service id="data_collector.request" class="Symfony\Component\HttpKernel\DataCollector\RequestDataCollector">

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig

Lines changed: 46 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,14 @@
1919
{% endif %}
2020

2121
{% set icon %}
22-
{% if collector.applicationname %}
23-
<span class="sf-toolbar-label">{{ collector.applicationname }}</span>
24-
<span class="sf-toolbar-value">{{ collector.applicationversion }}</span>
25-
{% elseif collector.symfonyState is defined %}
26-
<span class="sf-toolbar-label">
27-
{{ include('@WebProfiler/Icon/symfony.svg') }}
28-
</span>
29-
<span class="sf-toolbar-value">{{ collector.symfonyversion }}</span>
30-
{% endif %}
22+
<span class="sf-toolbar-label">
23+
{{ include('@WebProfiler/Icon/symfony.svg') }}
24+
</span>
25+
<span class="sf-toolbar-value">{{ collector.symfonyState is defined ? collector.symfonyversion : 'n/a' }}</span>
3126
{% endset %}
3227

3328
{% set text %}
3429
<div class="sf-toolbar-info-group">
35-
{% if collector.applicationname %}
36-
<div class="sf-toolbar-info-piece">
37-
<b>{{ collector.applicationname }}</b>
38-
<span>{{ collector.applicationversion }}</span>
39-
</div>
40-
{% endif %}
41-
4230
<div class="sf-toolbar-info-piece">
4331
<b>Profiler token</b>
4432
<span>
@@ -92,15 +80,9 @@
9280
<div class="sf-toolbar-info-piece">
9381
<b>Resources</b>
9482
<span>
95-
{% if 'Silex' == collector.applicationname %}
96-
<a href="https://silex.symfony.com/documentation" rel="help">
97-
Read Silex Docs
98-
</a>
99-
{% else %}
100-
<a href="https://symfony.com/doc/{{ collector.symfonyversion }}/index.html" rel="help">
101-
Read Symfony {{ collector.symfonyversion }} Docs
102-
</a>
103-
{% endif %}
83+
<a href="https://symfony.com/doc/{{ collector.symfonyversion }}/index.html" rel="help">
84+
Read Symfony {{ collector.symfonyversion }} Docs
85+
</a>
10486
</span>
10587
</div>
10688
<div class="sf-toolbar-info-piece">
@@ -126,74 +108,53 @@
126108
{% endblock %}
127109

128110
{% block panel %}
129-
{% if collector.applicationname %}
130-
{# this application is not the Symfony framework #}
131-
<h2>Project Configuration</h2>
111+
<h2>Symfony Configuration</h2>
132112

133-
<div class="metrics">
134-
<div class="metric">
135-
<span class="value">{{ collector.applicationname }}</span>
136-
<span class="label">Application name</span>
137-
</div>
113+
<div class="metrics">
114+
<div class="metric">
115+
<span class="value">{{ collector.symfonyversion }}</span>
116+
<span class="label">Symfony version</span>
117+
</div>
138118

119+
{% if 'n/a' != collector.env %}
139120
<div class="metric">
140-
<span class="value">{{ collector.applicationversion }}</span>
141-
<span class="label">Application version</span>
121+
<span class="value">{{ collector.env }}</span>
122+
<span class="label">Environment</span>
142123
</div>
143-
</div>
144-
145-
<p>
146-
Based on <a class="text-bold" href="https://symfony.com">Symfony {{ collector.symfonyversion }}</a>
147-
</p>
148-
{% else %}
149-
<h2>Symfony Configuration</h2>
124+
{% endif %}
150125

151-
<div class="metrics">
126+
{% if 'n/a' != collector.debug %}
152127
<div class="metric">
153-
<span class="value">{{ collector.symfonyversion }}</span>
154-
<span class="label">Symfony version</span>
128+
<span class="value">{{ collector.debug ? 'enabled' : 'disabled' }}</span>
129+
<span class="label">Debug</span>
155130
</div>
131+
{% endif %}
132+
</div>
156133

157-
{% if 'n/a' != collector.env %}
158-
<div class="metric">
159-
<span class="value">{{ collector.env }}</span>
160-
<span class="label">Environment</span>
161-
</div>
162-
{% endif %}
163-
164-
{% if 'n/a' != collector.debug %}
165-
<div class="metric">
166-
<span class="value">{{ collector.debug ? 'enabled' : 'disabled' }}</span>
167-
<span class="label">Debug</span>
168-
</div>
169-
{% endif %}
170-
</div>
171-
172-
{% set symfony_status = { dev: 'Unstable Version', stable: 'Stable Version', eom: 'Maintenance Ended', eol: 'Version Expired' } %}
173-
{% set symfony_status_class = { dev: 'warning', stable: 'success', eom: 'warning', eol: 'error' } %}
174-
<table>
175-
<thead class="small">
176-
<tr>
177-
<th>Symfony Status</th>
178-
<th>Bugs {{ collector.symfonystate in ['eom', 'eol'] ? 'were' : 'are' }} fixed until</th>
179-
<th>Security issues {{ collector.symfonystate == 'eol' ? 'were' : 'are' }} fixed until</th>
180-
<th></th>
181-
</tr>
182-
</thead>
183-
<tbody>
184-
<tr>
185-
<td class="font-normal">
186-
<span class="label status-{{ symfony_status_class[collector.symfonystate] }}">{{ symfony_status[collector.symfonystate]|upper }}</span>
187-
</td>
188-
<td class="font-normal">{{ collector.symfonyeom }}</td>
189-
<td class="font-normal">{{ collector.symfonyeol }}</td>
190-
<td class="font-normal">
191-
<a href="https://symfony.com/roadmap?version={{ collector.symfonyminorversion }}#checker">View roadmap</a>
192-
</td>
193-
</tr>
194-
</tbody>
195-
</table>
196-
{% endif %}
134+
{% set symfony_status = { dev: 'Unstable Version', stable: 'Stable Version', eom: 'Maintenance Ended', eol: 'Version Expired' } %}
135+
{% set symfony_status_class = { dev: 'warning', stable: 'success', eom: 'warning', eol: 'error' } %}
136+
<table>
137+
<thead class="small">
138+
<tr>
139+
<th>Symfony Status</th>
140+
<th>Bugs {{ collector.symfonystate in ['eom', 'eol'] ? 'were' : 'are' }} fixed until</th>
141+
<th>Security issues {{ collector.symfonystate == 'eol' ? 'were' : 'are' }} fixed until</th>
142+
<th></th>
143+
</tr>
144+
</thead>
145+
<tbody>
146+
<tr>
147+
<td class="font-normal">
148+
<span class="label status-{{ symfony_status_class[collector.symfonystate] }}">{{ symfony_status[collector.symfonystate]|upper }}</span>
149+
</td>
150+
<td class="font-normal">{{ collector.symfonyeom }}</td>
151+
<td class="font-normal">{{ collector.symfonyeol }}</td>
152+
<td class="font-normal">
153+
<a href="https://symfony.com/roadmap?version={{ collector.symfonyminorversion }}#checker">View roadmap</a>
154+
</td>
155+
</tr>
156+
</tbody>
157+
</table>
197158

198159
<h2>PHP Configuration</h2>
199160

src/Symfony/Component/HttpKernel/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ CHANGELOG
66

77
* deprecated `KernelInterface::getRootDir()` and the `kernel.root_dir` parameter
88
* deprecated `KernelInterface::getName()` and the `kernel.name` parameter
9+
* deprecated the first and second constructor argument of `ConfigDataCollector`
10+
* deprecated `ConfigDataCollector::getApplicationName()`
11+
* deprecated `ConfigDataCollector::getApplicationVersion()`
912

1013
4.1.0
1114
-----

src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,15 @@ class ConfigDataCollector extends DataCollector implements LateDataCollectorInte
3030
private $version;
3131
private $hasVarDumper;
3232

33-
/**
34-
* @param string $name The name of the application using the web profiler
35-
* @param string $version The version of the application using the web profiler
36-
*/
3733
public function __construct(string $name = null, string $version = null)
3834
{
35+
if (1 <= \func_num_args()) {
36+
@trigger_error(sprintf('The "$name" argument in method "%s()" is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
37+
}
38+
if (2 <= \func_num_args()) {
39+
@trigger_error(sprintf('The "$version" argument in method "%s()" is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
40+
}
41+
3942
$this->name = $name;
4043
$this->version = $version;
4144
$this->hasVarDumper = class_exists(LinkStub::class);
@@ -105,13 +108,23 @@ public function lateCollect()
105108
$this->data = $this->cloneVar($this->data);
106109
}
107110

111+
/**
112+
* @deprecated since Symfony 4.2
113+
*/
108114
public function getApplicationName()
109115
{
116+
@trigger_error(sprintf('The method "%s()" is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
117+
110118
return $this->data['app_name'];
111119
}
112120

121+
/**
122+
* @deprecated since Symfony 4.2
123+
*/
113124
public function getApplicationVersion()
114125
{
126+
@trigger_error(sprintf('The method "%s()" is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
127+
115128
return $this->data['app_version'];
116129
}
117130

src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,26 @@ public function testCollect()
4141
$this->assertSame(\extension_loaded('Zend OPcache') && ini_get('opcache.enable'), $c->hasZendOpcache());
4242
$this->assertSame(\extension_loaded('apcu') && ini_get('apc.enabled'), $c->hasApcu());
4343
}
44-
}
4544

46-
class KernelForTest extends Kernel
47-
{
48-
public function getName()
45+
/**
46+
* @group legacy
47+
* @expectedDeprecation The "$name" argument in method "Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector::__construct()" is deprecated since Symfony 4.2.
48+
* @expectedDeprecation The "$version" argument in method "Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector::__construct()" is deprecated since Symfony 4.2.
49+
* @expectedDeprecation The method "Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector::getApplicationName()" is deprecated since Symfony 4.2.
50+
* @expectedDeprecation The method "Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector::getApplicationVersion()" is deprecated since Symfony 4.2.
51+
*/
52+
public function testLegacy()
4953
{
50-
return 'testkernel';
54+
$c = new ConfigDataCollector('name', null);
55+
$c->collect(new Request(), new Response());
56+
57+
$this->assertSame('name', $c->getApplicationName());
58+
$this->assertNull($c->getApplicationVersion());
5159
}
60+
}
5261

62+
class KernelForTest extends Kernel
63+
{
5364
public function registerBundles()
5465
{
5566
}

0 commit comments

Comments
 (0)
0