Bug #79060 [Fbk->Opn]: fgets errno=22

From: Date: Fri, 03 Jan 2020 15:20:45 +0000
Subject: Bug #79060 [Fbk->Opn]: fgets errno=22
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224690@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79060&edit=1 ID: 79060 User updated by: namiltd at yahoo dot com Reported by: namiltd at yahoo dot com Summary: fgets errno=22 -Status: Feedback +Status: Open Type: Bug Package: *General Issues Operating System: Debian GNU/Linux 9 PHP Version: 7.4.1 Block user comment: N Private report: N New Comment: But is_readable("/sys/class/net/lo/speed") returns true Try: <?php $fname = "/sys/class/net/lo/speed"; $file = fopen($fname, "r"); if (is_readable($fname)) { echo ">".fgets($file, 2048)."<"; } else { echo "File is not readable"; } fclose($file); Previous Comments: ------------------------------------------------------------------------ [2020-01-03 14:43:19] nikic@php.net What is the bug here? The fgets() fails because the "file" is not readable. Since PHP 7.4, file system read/write failures result in a notice and false return value (this is noted in the upgrading notes). ------------------------------------------------------------------------ [2020-01-03 13:24:07] namiltd at yahoo dot com E-mail change ------------------------------------------------------------------------ [2020-01-03 13:18:57] namiltd at yahoo dot com Description: ------------ Unexpected notice: Notice: fgets(): read of 8192 bytes failed with errno=22 Invalid argument in /home/www/test.php on line 3 Interestingly, the buffer is 2048 but indicates 8192 Test script: --------------- <?php $file = fopen("/sys/class/net/lo/speed","r"); echo ">".fgets($file, 2048)."<"; fclose($file); ?> Expected result: ---------------- >< Actual result: -------------- Notice: fgets(): read of 8192 bytes failed with errno=22 Invalid argument in /home/www/test.php on line 3 >< ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79060&edit=1

« previous php.bugs (#224690) next »