Skip to content

Fix raw Console markup rendered by ConsoleSectionOutput::overwrite()#1221

Merged
veewee merged 2 commits into
phpro:v2.xfrom
mitrpaka:fix/raw-console-markup-in-task-results-reporter
May 22, 2026
Merged

Fix raw Console markup rendered by ConsoleSectionOutput::overwrite()#1221
veewee merged 2 commits into
phpro:v2.xfrom
mitrpaka:fix/raw-console-markup-in-task-results-reporter

Conversation

@mitrpaka
Copy link
Copy Markdown
Contributor

@mitrpaka mitrpaka commented May 22, 2026

Q A
Branch 2.x
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Documented? yes (documentation already exists)
Fixed tickets Did not create a separate bug report for this

While updating recent Drupal core security fix (Symfony were updated to 7.4.12) noticed that markup in the console did not render correctly in a decorated (ANSI) terminal:

Before:

GrumPHP is sniffing your code!

Running tasks with priority 0!
==============================

Running task 1/6: composer... ✔
Running task 2/6: phplint... ✔
Running task 3/6: yamllint... ✔
Running task 4/6: phpcs... ✔

After:

GrumPHP is sniffing your code!

Running tasks with priority 0!
==============================

Running task 1/6: composer... <fg=green>✔</fg=green>
Running task 2/6: phplint... <fg=green>✔</fg=green>
Running task 3/6: yamllint... <fg=green>✔</fg=green>
Running task 4/6: phpcs... <fg=green>✔</fg=green>

Symfony's ConsoleSectionOutput::overwrite() does not pass content through the output formatter. When report() calls overwrite() with raw markup strings like <fg=green>✔</fg=green>, they render as literal text instead of ANSI colour codes.

It seems that the bug was already present but hidden — report() only calls overwrite() when $this->content is non-empty (i.e. after the first task result). The first call always falls back to writeln(), which formats correctly. With 2 or more tasks in a decorated terminal, subsequent calls hit the overwrite() path with unformatted markup.

@veewee veewee merged commit df7e39b into phpro:v2.x May 22, 2026
23 of 26 checks passed
@veewee
Copy link
Copy Markdown
Contributor

veewee commented May 22, 2026

Thanks! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants