Skip to content

Commit 32df1ab

Browse files
authored
Merge pull request #8523 from kenjis/fix-debugbar-View-DEBUG-VIEW
[4.5] fix: DEBUG-VIEW comments are not output
2 parents 846466e + 72240a7 commit 32df1ab

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

system/Filters/Filters.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ class Filters
7070
* The processed filters that will
7171
* be used to check against.
7272
*
73+
* This does not include "Required Filters".
74+
*
7375
* @var array<string, array>
7476
*/
7577
protected $filters = [
@@ -81,6 +83,8 @@ class Filters
8183
* The collection of filters' class names that will
8284
* be used to execute in each position.
8385
*
86+
* This does not include "Required Filters".
87+
*
8488
* @var array<string, array>
8589
*/
8690
protected $filtersClass = [
@@ -252,7 +256,7 @@ private function runAfter(array $filterClasses): ResponseInterface
252256
}
253257

254258
/**
255-
* Runs required filters for the specified position.
259+
* Runs "Required Filters" for the specified position.
256260
*
257261
* @return RequestInterface|ResponseInterface|string|null
258262
*
@@ -289,7 +293,7 @@ public function runRequired(string $position = 'before')
289293
}
290294

291295
/**
292-
* Returns required filters for the specified position.
296+
* Returns "Required Filters" for the specified position.
293297
*
294298
* @phpstan-param 'before'|'after' $position
295299
*
@@ -423,6 +427,7 @@ public function reset(): self
423427

424428
/**
425429
* Returns the processed filters array.
430+
* This does not include "Required Filters".
426431
*/
427432
public function getFilters(): array
428433
{
@@ -431,6 +436,7 @@ public function getFilters(): array
431436

432437
/**
433438
* Returns the filtersClass array.
439+
* This does not include "Required Filters".
434440
*/
435441
public function getFiltersClass(): array
436442
{

system/View/View.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,19 @@ public function render(string $view, ?array $options = null, ?bool $saveData = n
261261
$this->renderVars['view']
262262
);
263263

264-
$afterFilters = service('filters')->getFiltersClass()['after'];
264+
// Check if DebugToolbar is enabled.
265+
$filters = Services::filters();
266+
$requiredAfterFilters = $filters->getRequiredFilters('after')[0];
267+
if (in_array('toolbar', $requiredAfterFilters, true)) {
268+
$debugBarEnabled = true;
269+
} else {
270+
$afterFilters = $filters->getFiltersClass()['after'];
271+
$debugBarEnabled = in_array(DebugToolbar::class, $afterFilters, true);
272+
}
273+
265274
if (
266-
($this->debug && (! isset($options['debug']) || $options['debug'] === true))
267-
&& in_array(DebugToolbar::class, $afterFilters, true)
275+
$this->debug && $debugBarEnabled
276+
&& (! isset($options['debug']) || $options['debug'] === true)
268277
) {
269278
$toolbarCollectors = config(Toolbar::class)->collectors;
270279

tests/system/Helpers/FormHelperTest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,10 @@ public function testValidationShowError(): void
10221022

10231023
$html = validation_show_error('id');
10241024

1025-
$this->assertSame('<span class="help-block">The ID field is required.</span>' . "\n", $html);
1025+
$this->assertSame('<!-- DEBUG-VIEW START 1 SYSTEMPATH/Validation/Views/single.php -->
1026+
<span class="help-block">The ID field is required.</span>
1027+
1028+
<!-- DEBUG-VIEW ENDED 1 SYSTEMPATH/Validation/Views/single.php -->' . "\n", $html);
10261029
}
10271030

10281031
public function testValidationShowErrorForWildcards(): void
@@ -1041,7 +1044,10 @@ public function testValidationShowErrorForWildcards(): void
10411044

10421045
$html = validation_show_error('user.*.name');
10431046

1044-
$this->assertSame('<span class="help-block">The Name field is required.</span>' . "\n", $html);
1047+
$this->assertSame('<!-- DEBUG-VIEW START 1 SYSTEMPATH/Validation/Views/single.php -->
1048+
<span class="help-block">The Name field is required.</span>
1049+
1050+
<!-- DEBUG-VIEW ENDED 1 SYSTEMPATH/Validation/Views/single.php -->' . "\n", $html);
10451051
}
10461052

10471053
public function testFormParseFormAttributesTrue(): void

0 commit comments

Comments
 (0)