Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:27151 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 91818 invoked by uid 1010); 20 Dec 2006 18:01:48 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 91803 invoked from network); 20 Dec 2006 18:01:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Dec 2006 18:01:48 -0000 Authentication-Results: pb1.pair.com smtp.mail=andy.wharmby@googlemail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=andy.wharmby@googlemail.com; sender-id=pass; domainkeys=good Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 66.249.92.170 as permitted sender) DomainKey-Status: good X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: andy.wharmby@googlemail.com X-Host-Fingerprint: 66.249.92.170 ug-out-1314.google.com Linux 2.4/2.6 Received: from [66.249.92.170] ([66.249.92.170:34222] helo=ug-out-1314.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BE/28-36977-64A79854 for ; Wed, 20 Dec 2006 13:01:13 -0500 Received: by ug-out-1314.google.com with SMTP id 71so2550637ugh for ; Wed, 20 Dec 2006 10:00:36 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=googlemail.com; h=received:message-id:date:from:user-agent:mime-version:to:subject:content-type; b=DcYEkn4zirzqFi9kzNIg0LDWFf6dZduXqPRUecTKAJfZ3jO72rBzZUZ8CgEQLIqrGw6xLx0LRTB1rb/tXY7AJW2o7+z7QcdPUx+9oPsQqVar40ki13geXZ7oP7oS3NOkE9NJhMXTtF+17e4iGZvjvoGdHCL1SFpiqiMKEAljkXc= Received: by 10.66.248.5 with SMTP id v5mr9749243ugh.1166637635661; Wed, 20 Dec 2006 10:00:35 -0800 (PST) Received: from ?9.20.183.164? ( [195.212.29.92]) by mx.google.com with ESMTP id k28sm13036033ugd.2006.12.20.10.00.33; Wed, 20 Dec 2006 10:00:34 -0800 (PST) Message-ID: <45897A41.5060804@googlemail.com> Date: Wed, 20 Dec 2006 18:00:33 +0000 User-Agent: Thunderbird 1.5.0.9 (Windows/20061207) MIME-Version: 1.0 To: PHP internals list Content-Type: multipart/mixed; boundary="------------040509030108090503060709" Subject: Query on assert_options() api From: andy.wharmby@googlemail.com (Andy Wharmby) --------------040509030108090503060709 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi Internals A colleague of mine is currently working on creating new test cases to improve the coverage of the PHP test cases and whilst attempting to write new tests for the assert extension hit on a problem when attempting to query the current setting of ASSERT_CALLBACK. using the assert_options() api. With the following simple testcase : The expected result was that the old (if any) and new setting of the callback function name would be displayed but the actual results was old setting is 1 new setting is 1 Looking at the code this is no surprise as the code in assert.c which processes these requests unconditionally returns with RETURN_TRUE. For all other assert options other than assert_options() function returns the old value of the specified option as documented in the PHP manual. Further investigation uncovered that the code actually did behave in the way we expected until it was changed to accept the array(&$obj, "methodname") syntax back in July 2001 (revision 1.32 of assert.c). At this time the return was changed to be unconditionally TRUE. Unfortunately this makes writing a test case to query the current setting of the ASSERT_CALLBACK option impossible as assert_options() no longer returns any useable information for this option, i.e to code a testcase as above that sets a value and then checks its set as expected. If the code is modified as in the attached patch to instead return the ZVAL for the ASSERT_CALLBACK option then we are able create the new testcase to verify the assert_options() api. However, I am concerned there is a good reason this was not done when the code was changed back in 2001.Can anyone think of a good reason why returning the zval on this api is not a good idea ? Any comments on my proposed fix appreciated. Regards Andy Andy Wharmby IBM United Kingdom Limited --------------040509030108090503060709 Content-Type: text/plain; name="assert.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="assert.txt" --- assert.c 2006-12-03 17:30:54.000000000 +0000 +++ assert.c.new 2006-12-20 14:55:03.259056200 +0000 @@ -286,6 +286,11 @@ break; case ASSERT_CALLBACK: + if (ASSERTG(callback) != NULL) { + RETVAL_ZVAL(ASSERTG(callback), 1, 0); + } else { + RETVAL_NULL(); + } if (ac == 2) { if (ASSERTG(callback)) { zval_ptr_dtor(&ASSERTG(callback)); @@ -293,7 +298,7 @@ ASSERTG(callback) = *value; zval_add_ref(value); } - RETURN_TRUE; + return; break; default: --------------040509030108090503060709--