Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60946 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66870 invoked from network); 23 Jun 2012 19:24:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Jun 2012 19:24:48 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@googlemail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@googlemail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 209.85.217.170 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@googlemail.com X-Host-Fingerprint: 209.85.217.170 mail-lb0-f170.google.com Received: from [209.85.217.170] ([209.85.217.170:37628] helo=mail-lb0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EA/30-64697-EF716EF4 for ; Sat, 23 Jun 2012 15:24:47 -0400 Received: by lbgc1 with SMTP id c1so5614829lbg.29 for ; Sat, 23 Jun 2012 12:24:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=imu6etJ9gFFmg3knt+dXjRdZSo1SfuqgdoUPYnW7IN4=; b=QJ3wfh+svGjQJhO9SlkpJ2SgVKp0yvx+yOyM94tUtETEs4yCsQLfL+GmnCgDPS4MHY b6vf2wKg9h4qJGcP+xqq+N5d6oYxpcIXmtvkXjzBw4ABWSGPg4SFTdtZ+YdkP2wAo+sw W2NpJ8Lf0CV++XkOvUFZDxQPkS1+93QlL1Do6ARQWSONS2EDhs4Zb/rjZOJH4ownsVX9 L7bbpaTFxU6ptIwTNeMl8dWGmRFKg/mvlfgvSq4quIN+0acelXudCue+1SeW9a/JpKBa UXzF6KjRrDU6McW4LtJnt3iQQNH+xuE9aLyacVv6hSfma7jKdrXC1WbhEhBaMeqD0/jB O2Wg== MIME-Version: 1.0 Received: by 10.152.148.170 with SMTP id tt10mr6347691lab.48.1340479483302; Sat, 23 Jun 2012 12:24:43 -0700 (PDT) Received: by 10.152.114.70 with HTTP; Sat, 23 Jun 2012 12:24:43 -0700 (PDT) In-Reply-To: References: <20120621141241.GA25789@analysisandsolutions.com> <4FE33EDF.2000409@lerdorf.com> Date: Sat, 23 Jun 2012 21:24:43 +0200 Message-ID: To: Sherif Ramadan Cc: Rasmus Lerdorf , Daniel Convissor , PHP internals Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] json_encode() behavior for incorrectly encoded strings From: nikita.ppv@googlemail.com (Nikita Popov) I applied a few changes in https://github.com/php/php-src/commit/84fe2cc890e49f40bac7c3ba74b3cfc6dc4cef2f and https://github.com/php/php-src/commit/36fa17a5fae84ab332366a202f0a709279a2466a. From the commit message: <<<<< json_encode() now returns bool(false) for all possible errors, throws the respective warning and also sets the respective json_last_error() error code. Three new error codes have been added: * JSON_ERROR_RECURSION * JSON_ERROR_INF_OR_NAN * JSON_ERROR_UNSUPPORTED_TYPE To get a partial JSON output instead of bool(false) the option JSON_PARTIAL_OUTPUT_ON_ERROR can be specified. In this case the invalid segments will be replaced either by null (for recursion, unsupported type and invalid JSON) or 0 (for Inf and NaN). The warning for invalid UTF-8 stays intact and is thrown also with display_errors = On. If this behavior is undesired this can be remedied later. >>>>> So all branches now behave the same: bool(false) is returned, a warning is thrown and an error code is set. For now I chose to always throw the warning, but if something else comes out in conclusion to this discussion I'll gladly change it to some other behavior. Nikita On Sat, Jun 23, 2012 at 12:50 PM, Sherif Ramadan wrote: > So in other words this patch I submitted should be fine? > > https://github.com/php/php-src/pull/111 > > This particular patch doesn't raise any controversy since it doesn't > touch any of that other stuff and simply puts the defined behavior > back in place as it should have been.