Skip to content

Commit 49d00f6

Browse files
committed
Merge branch '7.0' into 7.1
* 7.0: fix tests [FrameworkBundle] Fix profiling commands without router [FrameworkBundle] Fix profiling command in web context [WebProfilerBundle] Fix Copy as Curl [SecurityBundle] Fix redeclaration of `InternalSecurity` class when opcache preload is active
2 parents 5ae3df5 + c568d4f commit 49d00f6

File tree

5 files changed

+54
-44
lines changed

5 files changed

+54
-44
lines changed

src/Symfony/Bundle/FrameworkBundle/EventListener/ConsoleProfilerListener.php

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ public function __construct(
4242
private readonly Profiler $profiler,
4343
private readonly RequestStack $requestStack,
4444
private readonly Stopwatch $stopwatch,
45-
private readonly UrlGeneratorInterface $urlGenerator,
45+
private readonly bool $cliMode,
46+
private readonly ?UrlGeneratorInterface $urlGenerator = null,
4647
) {
4748
$this->profiles = new \SplObjectStorage();
4849
$this->parents = new \SplObjectStorage();
@@ -59,6 +60,10 @@ public static function getSubscribedEvents(): array
5960

6061
public function initialize(ConsoleCommandEvent $event): void
6162
{
63+
if (!$this->cliMode) {
64+
return;
65+
}
66+
6267
$input = $event->getInput();
6368
if (!$input->hasOption('profile') || !$input->getOption('profile')) {
6469
$this->profiler->disable();
@@ -78,12 +83,16 @@ public function initialize(ConsoleCommandEvent $event): void
7883

7984
public function catch(ConsoleErrorEvent $event): void
8085
{
86+
if (!$this->cliMode) {
87+
return;
88+
}
89+
8190
$this->error = $event->getError();
8291
}
8392

8493
public function profile(ConsoleTerminateEvent $event): void
8594
{
86-
if (!$this->profiler->isEnabled()) {
95+
if (!$this->cliMode || !$this->profiler->isEnabled()) {
8796
return;
8897
}
8998

@@ -131,12 +140,14 @@ public function profile(ConsoleTerminateEvent $event): void
131140
$p = $this->profiles[$r];
132141
$this->profiler->saveProfile($p);
133142

134-
$token = $p->getToken();
135-
$output?->writeln(sprintf(
136-
'See profile <href=%s>%s</>',
137-
$this->urlGenerator->generate('_profiler', ['token' => $token], UrlGeneratorInterface::ABSOLUTE_URL),
138-
$token
139-
));
143+
if ($this->urlGenerator && $output) {
144+
$token = $p->getToken();
145+
$output->writeln(sprintf(
146+
'See profile <href=%s>%s</>',
147+
$this->urlGenerator->generate('_profiler', ['token' => $token], UrlGeneratorInterface::ABSOLUTE_URL),
148+
$token
149+
));
150+
}
140151
}
141152

142153
$this->profiles = new \SplObjectStorage();

src/Symfony/Bundle/FrameworkBundle/Resources/config/profiling.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
service('profiler'),
4444
service('.virtual_request_stack'),
4545
service('debug.stopwatch'),
46-
service('router'),
46+
param('kernel.runtime_mode.cli'),
47+
service('router')->nullOnInvalid(),
4748
])
4849
->tag('kernel.event_subscriber')
4950

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
constructor() {
1414
this.#createTabs();
1515
this.#createToggles();
16+
this.#createCopyToClipboard();
1617
this.#convertDateTimesToUserTimezone();
1718
}
1819
@@ -161,18 +162,41 @@
161162
});
162163
});
163164
164-
/* Prevents from disallowing clicks on "copy to clipboard" elements inside toggles */
165-
const copyToClipboardElements = toggle.querySelectorAll('span[data-clipboard-text]');
166-
copyToClipboardElements.forEach((copyToClipboardElement) => {
167-
copyToClipboardElement.addEventListener('click', (e) => {
168-
e.stopPropagation();
169-
});
170-
});
171-
172165
toggle.setAttribute('data-processed', 'true');
173166
});
174167
}
175168
169+
#createCopyToClipboard() {
170+
if (!navigator.clipboard) {
171+
return;
172+
}
173+
174+
const copyToClipboardElements = document.querySelectorAll('[data-clipboard-text]');
175+
176+
copyToClipboardElements.forEach((copyToClipboardElement) => {
177+
copyToClipboardElement.classList.remove('hidden');
178+
179+
copyToClipboardElement.addEventListener('click', (e) => {
180+
/* Prevents from disallowing clicks on "copy to clipboard" elements inside toggles */
181+
e.stopPropagation();
182+
183+
navigator.clipboard.writeText(copyToClipboardElement.getAttribute('data-clipboard-text'));
184+
185+
let oldContent = copyToClipboardElement.textContent;
186+
187+
copyToClipboardElement.textContent = `✅ Copied!`;
188+
copyToClipboardElement.disabled = true;
189+
copyToClipboardElement.classList.add('status-success');
190+
191+
setTimeout(() => {
192+
copyToClipboardElement.textContent = oldContent;
193+
copyToClipboardElement.disabled = false;
194+
copyToClipboardElement.classList.remove('status-success');
195+
}, 7000);
196+
});
197+
});
198+
}
199+
176200
#convertDateTimesToUserTimezone() {
177201
const userTimezoneName = Intl.DateTimeFormat().resolvedOptions().timeZone;
178202

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_js.html.twig

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -50,33 +50,6 @@
5050
};
5151
}
5252
53-
if (navigator.clipboard) {
54-
document.addEventListener('readystatechange', () => {
55-
if (document.readyState !== 'complete') {
56-
return;
57-
}
58-
59-
document.querySelectorAll('[data-clipboard-text]').forEach(function (element) {
60-
removeClass(element, 'hidden');
61-
element.addEventListener('click', function () {
62-
navigator.clipboard.writeText(element.getAttribute('data-clipboard-text'));
63-
64-
if (element.classList.contains("label")) {
65-
let oldContent = element.textContent;
66-
67-
element.textContent = "✅ Copied!";
68-
element.classList.add("status-success");
69-
70-
setTimeout(() => {
71-
element.textContent = oldContent;
72-
element.classList.remove("status-success");
73-
}, 7000);
74-
}
75-
});
76-
});
77-
});
78-
}
79-
8053
var request = function(url, onSuccess, onError, payload, options, tries) {
8154
var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
8255
options = options || {};

src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolver/RequestPayloadValueResolverTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use Symfony\Component\HttpKernel\Event\ControllerArgumentsEvent;
2222
use Symfony\Component\HttpKernel\Exception\HttpException;
2323
use Symfony\Component\HttpKernel\HttpKernelInterface;
24+
use Symfony\Component\PropertyAccess\Exception\InvalidTypeException;
2425
use Symfony\Component\Serializer\Encoder\JsonEncoder;
2526
use Symfony\Component\Serializer\Encoder\XmlEncoder;
2627
use Symfony\Component\Serializer\Exception\PartialDenormalizationException;

0 commit comments

Comments
 (0)