Bug #21089
closedPrompt for keyboard input does not get displayed in CLI scripts
0%
Description
When running the lowlevel_cleaner script with --AUTOFIX or -i options, validation is requested from the user. In my setup the prompt does not get displayed.
Simply adding:
ob_flush();
after:
echo $msg.' (Yes/No + return): ';
in class.t3lib_cli.php (around line 225) solves the issue.
This is an example command that I tried to run:
/path/to/php /path/to/website/typo3/cli_dispatch.phpsh lowlevel_cleaner orphan_records -r --refindex update --AUTOFIX
Running this command, you should be prompted with the following question:
NOW Running --AUTOFIX on result. OK? (Yes/No + return):
I don't get anything. I tried with TYPO3 4.1 running PHP 4.4.8 and TYPO3 4.2 and Trunk running PHP 5.2.6. The problem is the same no matter the configuration.
(issue imported from #M11995)
Files
Updated by Andreas Wolf about 15 years ago
I think we would need a more general approach here. There are some extensions which start output caching with ob_start(), which usually leads to confusion when running CLI scripts. This is not only a source of errors like these, but also leads to confusion when scripts do not output anything while running.
Perhaps we can run ob_end_flush() before running the extension CLI script?
Updated by Francois Suter about 15 years ago
Thanks for the pointer Andreas. I searched for ob_start() through the whole source code and found an ob_start() call right near the beginning of typo3/init.php. That must be the one blocking everything. It was added in revision 4564 to solve problem during gzip-compressed output.
So your solution seems to be the right one: call ob_end_flush() in cli_dispatch.php after the inclusion of init.php.
It also explains why I remembered having been able to run CLI scripts in the past. On older TYPO3 installs it would work, before revision 4564.
Thanks for solving the mystery. I'll submit the patch now.
Updated by Francois Suter about 15 years ago
Changing the title to reflect the true nature of the issue.
Updated by Francois Suter about 15 years ago
Raising priority as this block all CLI output
Updated by Francois Suter about 15 years ago
Committed to trunk in revision 6013.
Committed to 4.2 in revision 6014.
Committed to 4.1 in revision 6015.