@Ken Brown
>I don't think you wrote what you meant. You're not saying that explicitly 
>specifying the default value changes the behavior, are you? Maybe you meant to 
>say that the default mode is "r"?

sorry about that, i meant "ab" makes the code work.

@Andrey Repin
>php -d 'display_errors=stderr'
>?

adding -d 'display_errors=stderr'  does not make any difference. still
int(0) NULL


On Sun, 2 Oct 2022 at 15:50, Andrey Repin <anrdae...@yandex.ru> wrote:
>
> Greetings, Hans Henrik Bergan!
>
> > ... actually i forgot that the default fopen mode is "rb" ... anyhow, here
> > is what's supposed to happen:
> > $ touch bug.txt; chmod 0777 bug.txt; php -r '$o=new
> > SplFileObject("bug.txt");var_dump($o->fwrite("test"));var_dump(error_get_last());'
> > PHP Notice:  SplFileObject::fwrite(): Write of 4 bytes failed with errno=9
> > Bad file descriptor in Command line code on line 1
> > bool(false)
> > array(4) {
> >   ["type"]=>
> >   int(8)
> >   ["message"]=>
> >   string(81) "SplFileObject::fwrite(): Write of 4 bytes failed with errno=9
> > Bad file descriptor"
> >   ["file"]=>
> >   string(17) "Command line code"
> >   ["line"]=>
> >   int(1)
> > }
>
> > changing the code to SplFileObject("bug.txt", "rb");
> > makes the code work, but there's still the issue with cygwin's php's
> > SplFileObject::fwrite() not noticing the write error
>
> php -d 'display_errors=stderr'
> ?
>
> > On Sat, 1 Oct 2022 at 18:47, Hans Henrik Bergan <divinit...@gmail.com>
> > wrote:
>
> >> running PHP 7.3.7 in Cygwin 3.3.6, and SplFileObject::fwrite seems
> >> completely broken.
> >> to reproduce:
> >> $ touch bug.txt; chmod 0777 bug.txt; php -r '$o=new
> >> SplFileObject("bug.txt");var_dump($o->fwrite("test"));var_dump(error_get_last());'
> >> int(0)
> >> NULL
> >>
> >> so both fwrite() and error_get_last() failed to pick up that there was an
> >> error,
> >> but strace reveals:
> >> 67 487251 [main] php 1693 __set_errno: ssize_t write(int, const void*,
> >> size_t):1350 setting errno 9
> >> 60 487311 [main] php 1693 write: -1 = write(3, 0x6FFFFFE65BF8, 4), errno 9
> >>
> >> errno 9 probably means: 9 EBADF Bad file descriptor.
> >>
>
>
>
> --
> With best regards,
> Andrey Repin
> Sunday, October 2, 2022 16:49:02
>
> Sorry for my terrible english...
>

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

Reply via email to