Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to read entity IDs from standard input #21

Merged
merged 1 commit into from
Oct 12, 2017

Conversation

lucaswerkmeister
Copy link
Contributor

@lucaswerkmeister lucaswerkmeister commented Apr 21, 2017

Specifying /dev/stdin as filename does not work on Linux if standard input is a pipe, since PHP does not open(2) the symlink directly, but instead follows it using readlink(2), and the Linux kernel returns a non-filename description for readlink(2) on /proc/[pid]/fd/ entries corresponding to pipes and sockets (see proc(5)):

readlink("/dev/stdin") -> /proc/self/fd/0
readlink("/proc/self/fd/0") -> pipe:[INODE]
/* ... resolve /proc/self ... */
open("/proc/PID/fd/pipe:[INODE]") -> ENOENT

*/
public function getEntityIds( $input ) {
$entityIds = [];
while ( $line = fgets( STDIN ) ) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it does not fit this interface, though this code make me think yield

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, that would look nice, but I don’t think it’s currently possible here, all the surrounding code expects arrays.

@lucaswerkmeister
Copy link
Contributor Author

The context for this feature request is change 349894 – this feature allows you to automatically import all the entities that the WikibaseQualityConstraints extension needs (see README.md there, line 68).

@filbertkm
Copy link
Owner

can you please add documentation for the new option in the README ?

Specifying /dev/stdin as filename does not work on Linux if standard
input is a pipe, since PHP does not open(2) the symlink directly, but
instead follows it using readlink(2), and the Linux kernel returns a
non-filename description for readlink(2) on /proc/[pid]/fd/ entries
corresponding to pipes and sockets (see proc(5)):

    readlink("/dev/stdin") -> /proc/self/fd/0
    readlink("/proc/self/fd/0") -> pipe:[INODE]
    /* ... resolve /proc/self ... */
    open("/proc/PID/fd/pipe:[INODE]") -> ENOENT
@lucaswerkmeister
Copy link
Contributor Author

I wasn’t sure what example to use for the pipe, but a simple printf is probably good enough. (cat presidents.csv would also work, I guess.)

@filbertkm
Copy link
Owner

@lucaswerkmeister yeah, think either works as an example

@lucaswerkmeister
Copy link
Contributor Author

Could this perhaps be merged? The option is already used in the WBQC README

@lucaswerkmeister
Copy link
Contributor Author

Is there anything blocking this from getting merged?

@filbertkm filbertkm merged commit dde40a5 into filbertkm:master Oct 12, 2017
@filbertkm
Copy link
Owner

looks good

@lucaswerkmeister
Copy link
Contributor Author

Thank you ♥

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.

None yet

3 participants