Bug #78077 [Opn->Dup]: move_uploaded_file ignores stream_flush return value of reg. streamWrapper

From: Date: Wed, 18 Aug 2021 11:10:25 +0000
Subject: Bug #78077 [Opn->Dup]: move_uploaded_file ignores stream_flush return value of reg. streamWrapper
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-235934@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78077&edit=1 ID: 78077 Updated by: cmb@php.net Reported by: daniel dot pernold at gmail dot com Summary: move_uploaded_file ignores stream_flush return value of reg. streamWrapper -Status: Open +Status: Duplicate Type: Bug Package: Streams related Operating System: Ubuntu 18.04 PHP Version: 7.2.18 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: Actually, this is a special case of bug #60110, so I'm closing this ticket as duplicate. Previous Comments: ------------------------------------------------------------------------ [2021-07-27 15:48:25] cmb@php.net When implicitly flushing on close, the return value is not checked[1]; that *might* be deliberate, given that almost none of the implicit flushes checks the return value. [1] <https://github.com/php/php-src/blob/php-7.4.21/main/streams/streams.c#L450> ------------------------------------------------------------------------ [2019-05-28 09:22:07] daniel dot pernold at gmail dot com Description: ------------ PHP 7.2.17-0ubuntu0.18.04.1 (cli) (built: Apr 18 2019 14:12:38) ( NTS ) When using move_uploaded_file with a stream wrapper url as destination, the return value of the method stream_flush is ignored. The function move_uploaded_file always returns true, even if stream_flush returns false. Test script: --------------- class MyStreamWrapper { ... public function stream_write($data) { return 1; } public function stream_flush() { return false; } ... } stream_wrapper_register('my-wrapper', \MyStreamWrapper::class, 0); $res = move_uploaded_file($_FILES['uploaded_file']['tmp_name'], 'my-wrapper://' . basename($_FILES['uploaded_file']['name'])); stream_wrapper_unregister('my-wrapper'); echo $res ? 'true' : 'false'; Expected result: ---------------- false Actual result: -------------- true ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=78077&edit=1

« previous php.bugs (#235934) next »