Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68715 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 12763 invoked from network); 30 Aug 2013 10:44:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Aug 2013 10:44:23 -0000 Authentication-Results: pb1.pair.com smtp.mail=ellison.terry@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ellison.terry@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.180 as permitted sender) X-PHP-List-Original-Sender: ellison.terry@gmail.com X-Host-Fingerprint: 74.125.82.180 mail-we0-f180.google.com Received: from [74.125.82.180] ([74.125.82.180:53196] helo=mail-we0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 54/D8-64695-68770225 for ; Fri, 30 Aug 2013 06:44:23 -0400 Received: by mail-we0-f180.google.com with SMTP id q58so1416233wes.39 for ; Fri, 30 Aug 2013 03:44:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type; bh=pOxql0EtcmCE0v2Z19PDPuUbdEw0GrIYRhDlh4AIBnQ=; b=jlS87K7gpwVHGldYb809woqzI0m4aVmOYEYxQWZlvUJJHU5cTihqne9AvI9sqfyP8y XFUA+TirGlirCJhTdomRzg1/T4Qm4WhZiKZ8KsUSJKuxfsvzQGhqn9dtvhEXk8pSi3VI skuBStTsS4SdhCwatU+0+quwmH4kL+lXOBlyz6QiS8qKYnWkUySOZ5eRCDGxM1YjdnMq ezshXvS/LNlw3xzRxxDvAfODV1BX0tllGx2P2W3TKXg+KeOJTiPyj/j0y3mw0tIAMvWf xEc7wn6EoIn9ZKwWEaK+/ONPhNVKAuoZsF5Y9p+IJlMKogYHv0tP238HUpTUf3obM+59 3bCA== X-Received: by 10.194.201.131 with SMTP id ka3mr10109908wjc.22.1377859459560; Fri, 30 Aug 2013 03:44:19 -0700 (PDT) Received: from [192.168.1.66] (host81-129-189-210.range81-129.btcentralplus.com. [81.129.189.210]) by mx.google.com with ESMTPSA id a8sm3196906wie.6.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 30 Aug 2013 03:44:19 -0700 (PDT) Message-ID: <52207782.5050204@gmail.com> Date: Fri, 30 Aug 2013 11:44:18 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130803 Thunderbird/17.0.8 MIME-Version: 1.0 To: Julien Pauli CC: Nikita Popov , PHP internals References: <521FE78E.3060900@gmail.com> In-Reply-To: Content-Type: multipart/alternative; boundary="------------010504010107000703040202" Subject: Re: [PHP-DEV] Re: Always set return_value_ptr? From: ellison.terry@gmail.com (Terry Ellison) --------------010504010107000703040202 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 30/08/13 10:43, Julien Pauli wrote: > On Fri, Aug 30, 2013 at 2:30 AM, Terry Ellison > > wrote: > > > There's another one in string.c, in PHP_FUNCTION(pathinfo), that > could be applied as well, though there's little performance gain > in avoiding the copy of a 4 element string array. > > BTW, looking at this pathinfo code, it doesn't do what the > documentation says it does -- or at least this states that the > optional argument if present should be _one_ of PATHINFO_DIRNAME, > PATHINFO_BASENAME, PATHINFO_EXTENSION or PATHINFO_FILENAME. > However, if a bitmask is supplied then this function returns the > element corresponding to the lowest bit value rather than an error > return, for example: > > $ php -r 'echo pathinfo("/tmp/x.fred", > PATHINFO_FILENAME|PATHINFO_EXTENSION),"\n";' > fred > > This is a bizarre behaviour. At a minimum the documentation > should actually state what the function does. Or do we bother to > raise a patch to fix this sort of thing, given that returning an > empty string (or more consistently with other functions, NULL) in > this case could create a BC break with existing buggy code? > > > This is weird, yes. > It's not the lowest bit value that is returned, but the first element > put in the array (as zend_hash_get_current_data() is used with no > HashPosition) , which is even more confusing. > > How to explain that in the documentation ? :| Yes I understand that, but the code processes the elements in this dirname, basename, filename, extension order so the two statements are equivalent in implementation. I am an experienced developer but a newbie-ish to the PHP developer community, and I come back to my Q. What do we typically do if we come across such weird functional behaviour outside the documented use of a standard function? * Shrug our shoulders and say "That's PHP for you. BC rules" * Fix the documentation to say what the code actually does * Fix the code at the next major release, say 5.6 to have sensible error behaviour. Just interested in understanding the consensus policy here. Do I post a fix to the doc; post a fix to the code; or move on to other issues? Regards Terry --------------010504010107000703040202--