Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions system/CLI/InputOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ public function input(?string $prefix = null): string
// @codeCoverageIgnoreStart
$prompt = $this->readlinePrompt($prefix, readline_info('library_version'));

if ($prompt !== null) {
return readline($prompt);
if ($prompt === null) {
// The library cannot render the prompt, so write it ourselves and let readline() only read the line.
self::fwrite(STDOUT, $prefix ?? '');
}

// The library cannot render the prompt, so write it ourselves and let readline() only read the line.
self::fwrite(STDOUT, $prefix ?? '');
$input = readline($prompt);

return readline();
return $input === false ? '' : $input;
// @codeCoverageIgnoreEnd
}

Expand Down
1 change: 1 addition & 0 deletions user_guide_src/source/changelogs/v4.7.5.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Bugs Fixed
- **CLI:** Fixed a bug where pressing backspace in a ``CLI::prompt()`` erased the prompt text when the ``readline`` extension is enabled. The prompt is now passed to ``readline()`` so line redraws repaint it.
ANSI color codes in the prompt (e.g., option defaults) are wrapped in readline's non-printing markers under GNU readline so cursor positioning stays accurate.
On Windows, where the ``readline`` extension is built on WinEditLine, the prompt is written to STDOUT first because WinEditLine reports no library version and prints ANSI sequences literally.
- **CLI:** Fixed a bug where ``CLI::input()`` and ``CLI::prompt()`` threw a ``TypeError`` when STDIN reached end-of-file (e.g., Ctrl+D) with the ``readline`` extension enabled. An empty string is now returned, matching the behavior without ``readline``.
- **CLIRequest:** Fixed a bug where ``parseCommand()`` could throw a TypeError when ``argv`` is missing.
- **CodeIgniter:** Fixed a bug where ``gatherOutput()`` could be called twice when ``startController()`` returned a ``ResponseInterface`` (e.g., from filter attributes or closure routes).
- **Content Security Policy:** Fixed a bug where empty ``Content-Security-Policy``, ``Content-Security-Policy-Report-Only``, and ``Reporting-Endpoints`` response headers were generated when no corresponding values existed.
Expand Down
Loading