php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74490 readline() moves the cursor to the beginning of the line
Submitted: 2017-04-22 16:26 UTC Modified: 2017-05-14 00:35 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: webmaster_20170422 at cubiclesoft dot com Assigned: ab
Status: Closed Package: Readline related
PHP Version: 7.1.4 OS: Windows
Private report: No CVE-ID:
 [2017-04-22 16:26 UTC] webmaster_20170422 at cubiclesoft dot com
Description:
------------
As of PHP 7.1, the readline extension is compiled into PHP for Windows.  Unfortunately, calling readline() results in the keyboard caret moving to the beginning of the line and clears any output on the line when the first key is pressed on the keyboard.  For example, running the test script on Ubuntu Linux via a SSH terminal session (PHP run from Bash) works as expected (the caret is not moved nor the start of the line changed).

This behavior is most likely a bug in the upstream WinEditLine library.  Documenting it here in bugs.php.net so the author of that library and the larger PHP community are aware of the issue.

This bug may be related to PHP Bug #74489, which describes a similar problem with WinEditLine's readline() most likely not accepting a null value for the prompt parameter.

Keyboard caret positioning information is available via the Windows Console API GetConsoleScreenBufferInfo().

Test script:
---------------
<?php
echo "Name:  ";
readline("");
?>

Expected result:
----------------
Similar behavior to *NIXes.  The "Name:  " string output to the terminal via echo and the keyboard caret correctly appears at the end of the string.

Actual result:
--------------
The "Name:  " string appears but the keyboard caret is placed at the start of the line.  The first keypress results in the displayed text being removed.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-05-14 00:35 UTC] ab@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: ab
 [2017-05-14 00:35 UTC] ab@php.net
These issues are fixed with the upgraded WinEditline library, which is going to be included in the next regular 7.1 release. Please check latest 7.1 or master snapshots.

Thanks.
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Mon Jun 26 20:01:38 2017 UTC