Bug #76605 [Opn]: stream_notification_callback is not being called

From: Date: Tue, 10 Jul 2018 19:59:09 +0000
Subject: Bug #76605 [Opn]: stream_notification_callback is not being called
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-216266@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76605&edit=1

 ID:                 76605
 Updated by:         requinix@php.net
 Reported by:        gbuza at inviqa dot com
 Summary:            stream_notification_callback is not being called
 Status:             Open
 Type:               Bug
 Package:            Streams related
 Operating System:   ArchLinux, kernel 4.17.4
 PHP Version:        7.2.7
 Block user comment: N
 Private report:     N

 New Comment:

It's only used for actual streams like FTP and HTTP. Note half of the STREAM_NOTIFYs don't
make sense for files.

Either
a) This is a request to add notifications to other stream types, like files
b) This is a doc bug and the stream_notification_callback() or assorted stream *:// pages should be
amended to specify how/when a notification callback is used


Previous Comments:
------------------------------------------------------------------------
[2018-07-10 13:29:51] gbuza at inviqa dot com

Description:
------------
When stream notification callback is used with fopen() function, it does not get called at all.

Test script:
---------------
<?php

file_put_contents('/tmp/input.txt', 'foo bar baz');

function stream_notification_callback($notification_code, $severity, $message, $message_code,
$bytes_transferred, $bytes_max) {
	die('It made progress.');
}

$context = stream_context_create();
stream_context_set_params($context, ['notification' =>
'stream_notification_callback']);
$input = fopen('/tmp/input.txt', 'r', false, $context);
$output = fopen('/tmp/output.txt', 'w');
stream_copy_to_stream($input, $output);
fclose($input);
fclose($output);


Expected result:
----------------
I expect to see the message "It made progress." on the standard output and the file
/tmp/output.txt should not exist.

Actual result:
--------------
No message is displayed and the file /tmp/output.txt is created.


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=76605&edit=1


Thread (5 messages)

« previous php.bugs (#216266) next »