|  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
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 (profile)
Status: Closed Package: Readline related
PHP Version: 7.1.4 OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
27 + 36 = ?
Subscribe to this entry?

 [2017-04-22 16:26 UTC] webmaster_20170422 at cubiclesoft dot com
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 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:
echo "Name:  ";

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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-05-14 00:35 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: ab
 [2017-05-14 00:35 UTC]
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.

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Fri Dec 08 10:01:28 2023 UTC