# [VOTE] fsync function

- Thread: https://externals.io/message/113234
- Original archive: https://news-web.php.net/php.internals/113234
- Started by David Gebler on 2021-02-23T17:15:29+00:00
- Messages: 8
- RFC: fsync() Function (Implemented (PHP 8.1)) — https://externals.io/rfc/fsync_function.md
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #113234 — David Gebler — 2021-02-23T17:15:29+00:00

URL: https://externals.io/message/113234#113234

Hi internals,
As there appear to be no objections or concerns, I intend to open voting on
https://wiki.php.net/rfc/fsync_function tomorrow and voting will remain
open for two weeks.

The RFC and its implementation

- Adds functions `fsync()` and `fdatasync()` for plain file streams on Unix
systems.
- Adds function `fsync()` on Windows with `fdatasync()` available as an alias

PR ref https://github.com/php/php-src/pull/6650

Regards,
David Gebler

---

## #113250 — David Gebler — 2021-02-24T17:15:16+00:00

URL: https://externals.io/message/113234#113250 · In reply to: #113234

Voting is now open for 2 weeks on https://wiki.php.net/rfc/fsync_function

Regards,
David Gebler



> Hi internals,
> As there appear to be no objections or concerns, I intend to open voting
> on https://wiki.php.net/rfc/fsync_function tomorrow and voting will
> remain open for two weeks.
>
> The RFC and its implementation
>
> - Adds functions `fsync()` and `fdatasync()` for plain file streams on Unix
> systems.
> - Adds function `fsync()` on Windows with `fdatasync()` available as an alias
>
> PR ref https://github.com/php/php-src/pull/6650
>
> Regards,
> David Gebler

---

## #113259 — Marco Pivetta — 2021-02-25T11:43:45+00:00

URL: https://externals.io/message/113234#113259 · In reply to: #113250

Hey David,
<http://ocramius.github.com/>




> Voting is now open for 2 weeks on https://wiki.php.net/rfc/fsync_function
>
> Regards,
> David Gebler
>
> On Tue, Feb 23, 2021 at 5:15 PM David Gebler <davidgebler@gmail.com>
> wrote:
>
> > […]
>

Just clarifying on my "NO" vote: I'm opposed to having more `E_WARNING` 
raised by the language.

We have better approaches for that:

 * exceptions
 * union types
 * Maybe/Either types

I don't see a reason to introduce a warning here, and it makes the function
unusable unless some poor soul implements a library that gets rid of the
warning.

Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/

---

## #113260 — Christoph M. Becker — 2021-02-25T12:00:38+00:00

URL: https://externals.io/message/113234#113260 · In reply to: #113259

> Hey David,
> <http://ocramius.github.com/>
>
>
> 
>
> > […]
>
> Just clarifying on my "NO" vote: I'm opposed to having more `E_WARNING` 
> raised by the language.
>
> We have better approaches for that:
>
>  * exceptions
>  * union types
>  * Maybe/Either types
>
> I don't see a reason to introduce a warning here, and it makes the function
> unusable unless some poor soul implements a library that gets rid of the
> warning.

Note that *this* warning is never supposed to occur in production,
because it is a programming error to pass a wrong resource *type*.
Rasing a warning for wrong resource types is standard behavior of
zend_fetch_resource() (unless no resource type name is passed).  I don't
see why these new functions should use a non standard mechanism.

Of course, in the long run resources should go away, which would resolve
this issue for these functions as well.

--
Christoph

---

## #113261 — Nikita Popov — 2021-02-25T12:03:57+00:00

URL: https://externals.io/message/113234#113261 · In reply to: #113260

On Thu, Feb 25, 2021 at 1:01 PM Christoph M. Becker <cmbecker69@gmx.de>
wrote:

> 
> > […]
> wrote:
> > […]
> https://wiki.php.net/rfc/fsync_function
> > […]
> voting
> > […]
> alias
> > […]
> function
> > […]
>
> Note that *this* warning is never supposed to occur in production,
> because it is a programming error to pass a wrong resource *type*.
> Rasing a warning for wrong resource types is standard behavior of
> zend_fetch_resource() (unless no resource type name is passed).  I don't
> see why these new functions should use a non standard mechanism.
>
> Of course, in the long run resources should go away, which would resolve
> this issue for these functions as well.
>

A wrong resource type will throw a TypeError as usual -- the warning is
thrown if the resource is of the correct type (stream), but does not
support sync operations. For example, if you tried to do an fsync on an
http:// stream.

Throwing a warning in such a case is consistent with how functions for
other optional stream operations work.

Regards,
Nikita

---

## #113262 — Christoph M. Becker — 2021-02-25T12:12:46+00:00

URL: https://externals.io/message/113234#113262 · In reply to: #113261

> On Thu, Feb 25, 2021 at 1:01 PM Christoph M. Becker <cmbecker69@gmx.de>
> wrote:
>
> > […]
>
> A wrong resource type will throw a TypeError as usual -- the warning is
> thrown if the resource is of the correct type (stream), but does not
> support sync operations. For example, if you tried to do an fsync on an
> http:// stream.

Ah, thanks for the correction!  (I'm doing too much PHP 7, still.)

> Throwing a warning in such a case is consistent with how functions for
> other optional stream operations work.

ACK.

--
Christoph

---

## #113265 — Marco Pivetta — 2021-02-25T13:38:36+00:00

URL: https://externals.io/message/113234#113265 · In reply to: #113261

Het Nikita,



>
> Throwing a warning in such a case is consistent with how functions for
> other optional stream operations work.
>

I understand that, and I'm OK with being **against** it.

Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/

---

## #113266 — David Gebler — 2021-02-25T14:13:21+00:00

URL: https://externals.io/message/113234#113266 · In reply to: #113265

Thanks Marco, objection understood. I think Nikita's already said what I
would say, from my view I can only reiterate I felt it was more appropriate
to keep the behaviour consistent with how similar stream ops work.

Regards
David Gebler



> Het Nikita,
>
> 
>
> > […]
>
> I understand that, and I'm OK with being **against** it.
>
> Marco Pivetta
>
> http://twitter.com/Ocramius
>
> http://ocramius.github.com/
