Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94835 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 32769 invoked from network); 4 Aug 2016 19:30:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Aug 2016 19:30:14 -0000 Authentication-Results: pb1.pair.com smtp.mail=yohgaki@ohgaki.net; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=yohgaki@ohgaki.net; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ohgaki.net designates 180.42.98.130 as permitted sender) X-PHP-List-Original-Sender: yohgaki@ohgaki.net X-Host-Fingerprint: 180.42.98.130 ns1.es-i.jp Received: from [180.42.98.130] ([180.42.98.130:39424] helo=es-i.jp) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 44/CA-53111-3C793A75 for ; Thu, 04 Aug 2016 15:30:13 -0400 Received: (qmail 91362 invoked by uid 89); 4 Aug 2016 19:30:08 -0000 Received: from unknown (HELO mail-qt0-f175.google.com) (yohgaki@ohgaki.net@209.85.216.175) by 0 with ESMTPA; 4 Aug 2016 19:30:08 -0000 Received: by mail-qt0-f175.google.com with SMTP id x25so163910144qtx.2 for ; Thu, 04 Aug 2016 12:30:07 -0700 (PDT) X-Gm-Message-State: AEkoouseCfE5Y07DphoA7/Qo+ZLjcfg/4EsBD88L9xeGtfwntIKluNs608PNHZZjh7XYp0Y1mpd/V33mJKKbTQ== X-Received: by 10.200.45.181 with SMTP id p50mr8013748qta.31.1470339001984; Thu, 04 Aug 2016 12:30:01 -0700 (PDT) MIME-Version: 1.0 Received: by 10.140.85.242 with HTTP; Thu, 4 Aug 2016 12:29:21 -0700 (PDT) In-Reply-To: References: Date: Fri, 5 Aug 2016 04:29:21 +0900 X-Gmail-Original-Message-ID: Message-ID: To: Christian Stadler Cc: "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Adding validate_var_array()/validate_input_array() to which version? From: yohgaki@ohgaki.net (Yasuo Ohgaki) Hi Christian, On Thu, Aug 4, 2016 at 8:27 PM, Christian Stadler wrote: > Am 04.08.2016 um 12:10 schrieb Yasuo Ohgaki: >> Hi Christian and all, >> >> On Thu, Aug 4, 2016 at 10:07 AM, Christian Stadler wrote: >>> Am 01.08.2016 um 10:23 schrieb Yasuo Ohgaki: >>>> P.S. It's possible to return array that contains offending values. It >>>> is not included since users can store whole offending input array. >>>> Whole input is more useful for attack analysis. >>> Actually I wanted to suggest exactly that for ppl. who want to give >>> Feedback to their users, what values failed to validate to the users. >>> Probably with a fourth optional param, like `$return_invalid = false`? >>> Of course logging is a different topic and should always use the whole >>> offending input array. >> I can set offending value to filter globals so that it can be >> retrieved later in catch block. I cannot return or modify referenced >> parameter because of raised exception. > > Well, since some people have objections about raising exceptions here, > this should probably be either in a seperate vote or additional options > in the main vote. Probably something, like: > Yes, either | Yes, without the exception | Yes, with the exception | No > Personally I would vote for 'Yes, either'. If I could, that is. One of my objective is following best practices. Prefer exception over error is one of them. Although, I strongly suggest to use exception for validation errors, I will have choices. (Exception should be used error cases that should not happen usually, but usual error handling would work. Error message could be more user friendly because php_error_docref() supports va arg) > >> I don't mind adding this feature. It requires an API like >> validate_get_offending_value(). (The name should be nicer) >> How many of us are interested in this feature? > > Then this new function should have an offset param. With this I could > check, if the array has any offending values and then continue with the > rest ... mmh, now that I think of it, this isn't really necessary. > > Uhm, well anyway: I'd suggest, that the ind(ex/ices) should be returned > rather, than the actual value names. OK. Thank you. I'll add this. The reason why I said store "value" is the code. To get index, it has to store index somewhere or change many lines of code. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net