Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:63292 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 38271 invoked from network); 9 Oct 2012 05:00:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Oct 2012 05:00:07 -0000 Authentication-Results: pb1.pair.com header.from=tjerk.meesters@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=tjerk.meesters@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.210.42 as permitted sender) X-PHP-List-Original-Sender: tjerk.meesters@gmail.com X-Host-Fingerprint: 209.85.210.42 mail-da0-f42.google.com Received: from [209.85.210.42] ([209.85.210.42:46099] helo=mail-da0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 16/32-23861-25FA3705 for ; Tue, 09 Oct 2012 01:00:06 -0400 Received: by mail-da0-f42.google.com with SMTP id z17so2014381dal.29 for ; Mon, 08 Oct 2012 21:59:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=MAYIGnC+BGN3CVo3GHcf3+qnVechdxEi/DjClk/RZ7A=; b=qR5O84FPfIV8aWlG40IsWj+Ql1uKD8yB7kAN+lQQCxlGMk9RlaSDLzwashQpuYfoc5 5LpyNy27gHapZypnzccYNlCAXncNLSEP+dQAM4IY6fWr4G8jbhqrQ/sdjcJNoe3f6rB9 SNTMqZXp0y0eT8jiay96y081aBruLZy/x3YLRFYIgLk75QX6AKeZ0rGzTihGzadEWN5a eEWbTO0sIp52gOORNgFSNpAr/xBb7YDGZoETErH6b7cwkQJnCjN+STNHgX1g069lTBA8 PikzHm90L34hBowVqRnFgAjZLPeWm8MaVAFIz9CZVJwrtqQQ0oIiS2C6K/Mc5pJCwPeD ehbQ== MIME-Version: 1.0 Received: by 10.68.217.202 with SMTP id pa10mr60979849pbc.15.1349758799713; Mon, 08 Oct 2012 21:59:59 -0700 (PDT) Sender: tjerk.meesters@gmail.com Received: by 10.66.147.201 with HTTP; Mon, 8 Oct 2012 21:59:59 -0700 (PDT) In-Reply-To: References: Date: Tue, 9 Oct 2012 12:59:59 +0800 X-Google-Sender-Auth: o5mf-QZ9n1wCiCiEFUontCblF2c Message-ID: To: Nicolai Scheer Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=047d7b2ee657ca15db04cb993517 Subject: Re: [PHP-DEV] stream_get_line behaviour Bug #63240 From: datibbaw@php.net (Tjerk Anne Meesters) --047d7b2ee657ca15db04cb993517 Content-Type: text/plain; charset=ISO-8859-1 On Tue, Oct 9, 2012 at 12:14 AM, Nicolai Scheer wrote: > Hi! > > We switched from php 5.3.10 to 5.3.17 this weekend and stumbled upon a > behaviour of stream_get_line that is most likely a bug and breaks a > lot of our file processing code. > > The issue seems to have been introduced from 5.3.10 to 5.3.11. > > I opened a bug report: #63240. > I've managed to reduce the code to this; it's very specific: $file = __DIR__ . '/input_dummy.txt'; $delimiter = 'MM'; file_put_contents($file, str_repeat('.', 8189) . $delimiter . $delimiter); $fh = fopen($file, "rb"); stream_get_line($fh, 8192, $delimiter); var_dump($delimiter === stream_get_line($fh, 8192, $delimter)); fclose($fh); unlink($file); If the internal buffer length is 8192, after the first call to stream_get_line() the read position (x) and physical file pointer (y) should be positioned like so: .......MM(x)M(y)M The fact that (y) is in between the delimiter seems to cause an issue. > The issue seems to be related to #44607, but that one got fixed years ago. > > Is anybody able to confirm this behaviour or has stumbled upon this? > > Furthermore the behaviour of stream_get_line on an empty file seems to > have changed between php 5.3.10 and php 5.3.11: > > > $file = __DIR__ . 'empty.txt'; > file_put_contents( $file, '' ); > $fh = fopen( $file, 'rb' ); > $data = stream_get_line( $fh, 4096 ); > var_dump( $data ); > > result in > > string(0) "" > > for php 5.3.10 > > and in > > bool(false) > > for php > 5.3.10. I don't know if this should be considered a bug, but as far as I know > such a behaviour should not change during minor releases... > > Any insight is appreciated! > > Greetings > > Nico > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- -- Tjerk --047d7b2ee657ca15db04cb993517--