reactphp / filesystem

Evented filesystem access.
MIT License
135 stars 40 forks source link

Undefined constant EIO_O_FSYNC #34

Closed valVk closed 5 years ago

valVk commented 6 years ago

PHP : 7.2.6 EIO: 2.0.3 the code above produce the following output

<?php

$flagMapping = [
  '+' => EIO_O_RDWR,
  'a' => EIO_O_APPEND,
  'c' => EIO_O_CREAT,
  'e' => EIO_O_EXCL,
  'f' => EIO_O_SYNC,
  'n' => EIO_O_NONBLOCK,
  'r' => EIO_O_RDONLY,
  't' => EIO_O_TRUNC,
  'w' => EIO_O_WRONLY,
];
print_r($flagMapping);
 $ docker exec -it react-cli sh -c 'php ./a.php'                                                                                                            [17:56:51]

Warning: Use of undefined constant EIO_O_SYNC - assumed 'EIO_O_SYNC' (this will throw an Error in a future version of PHP) in /var/www/html/a.php on line 8

Call Stack:
    0.0002     387648   1. {main}() /var/www/html/a.php:0

Array
(
    [+] => 2
    [a] => 1024
    [c] => 64
    [e] => 128
    [f] => EIO_O_SYNC
    [n] => 2048
    [r] => 0
    [t] => 512
    [w] => 1
)

List of defined constants for EIO

<?php

print_r(get_defined_constants(true));

...
    [eio] => Array
        (
            [EIO_SEEK_SET] => 0
            [EIO_SEEK_CUR] => 1
            [EIO_SEEK_END] => 2
            [EIO_PRI_MIN] => -4
            [EIO_PRI_DEFAULT] => 0
            [EIO_PRI_MAX] => 4
            [EIO_READDIR_DENTS] => 1
            [EIO_READDIR_DIRS_FIRST] => 2
            [EIO_READDIR_STAT_ORDER] => 4
            [EIO_READDIR_FOUND_UNKNOWN] => 128
            [EIO_DT_UNKNOWN] => 0
            [EIO_DT_FIFO] => 1
            [EIO_DT_CHR] => 2
            [EIO_DT_MPC] => 3
            [EIO_DT_DIR] => 4
            [EIO_DT_NAM] => 5
            [EIO_DT_BLK] => 6
            [EIO_DT_MPB] => 7
            [EIO_DT_REG] => 8
            [EIO_DT_NWK] => 9
            [EIO_DT_CMP] => 9
            [EIO_DT_LNK] => 10
            [EIO_DT_SOCK] => 12
            [EIO_DT_DOOR] => 13
            [EIO_DT_WHT] => 14
            [EIO_DT_MAX] => 15
            [EIO_O_RDONLY] => 0
            [EIO_O_WRONLY] => 1
            [EIO_O_RDWR] => 2
            [EIO_O_NONBLOCK] => 2048
            [EIO_O_APPEND] => 1024
            [EIO_O_CREAT] => 64
            [EIO_O_TRUNC] => 512
            [EIO_O_EXCL] => 128
            [EIO_S_IRUSR] => 256
            [EIO_S_IWUSR] => 128
            [EIO_S_IXUSR] => 64
            [EIO_S_IRGRP] => 32
            [EIO_S_IWGRP] => 16
            [EIO_S_IXGRP] => 8
            [EIO_S_IROTH] => 4
            [EIO_S_IWOTH] => 2
            [EIO_S_IXOTH] => 1
            [EIO_S_IFREG] => 32768
            [EIO_S_IFCHR] => 8192
            [EIO_S_IFBLK] => 24576
            [EIO_S_IFIFO] => 4096
            [EIO_S_IFSOCK] => 49152
            [EIO_SYNC_FILE_RANGE_WAIT_BEFORE] => 1
            [EIO_SYNC_FILE_RANGE_WRITE] => 2
            [EIO_SYNC_FILE_RANGE_WAIT_AFTER] => 4
            [EIO_FALLOC_FL_KEEP_SIZE] => 1
        )
...

What kind of version EIO must be used for this library?

UPD.

https://pecl.php.net/package-changelog.php?package=eio&release=2.0.3


2.0.2 | Fixed build error due to undefined O_FSYNC in musl libc
valVk commented 6 years ago

@WyriHaximus What do you think about this issue?

WyriHaximus commented 6 years ago

@valVk I'd 1.0 and 2.0 but this has to be fixed. Either by removing the use of that constant or by adding a polyfill. Not sure yet, leaning torwards the former

valVk commented 6 years ago

Thanks for your clarification. I think, that information about EIO's version has to be added to the Readme.

WyriHaximus commented 5 years ago

@valVk dropping it in v0.1.2/v0.2 as f isn't supported by PHP either and EIO also dropped it. PR is up at #44

kelunik commented 4 years ago

@WyriHaximus It's conditionally defined, it didn't get dropped: https://github.com/rosmanov/pecl-eio/commit/65e8b5433992c77c5290d23d8ae33b58499c44a1#diff-0cc087e71ac0c866a224fb4846b3314dR932