Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87490 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 69168 invoked from network); 2 Aug 2015 06:42:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Aug 2015 06:42:10 -0000 Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.48 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.220.48 mail-pa0-f48.google.com Received: from [209.85.220.48] ([209.85.220.48:34631] helo=mail-pa0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3B/10-63984-0CBBDB55 for ; Sun, 02 Aug 2015 02:42:09 -0400 Received: by pacan13 with SMTP id an13so67103581pac.1 for ; Sat, 01 Aug 2015 23:42:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type:content-transfer-encoding; bh=n+ZdMAg9WX7qeFhrNqkY0ORQBddEl2LWj0vKucCxN0o=; b=CWw5iwmOJGNDFHEAfbFAGtp4UW6eJjVWovj+/o70iHJyiX72tV9xa+ttXtWdPOtd1J Dl9bRx2bpi8iPNRweqEU5OUSDjGA8JMqh4Mlr3e4uMK64YI6Qop/AmxIeliCLqWrHy6u zXpmPxNTDV1QdWpDne/LPyRylYO1/cieOyaVwnF9Tim/hoAEhD3OFD8j60bPDyT6L37M CWUcPaMKKicMlyIAEIwabXk+2YMFPJXV01gxvopudMw9AeTeUyDsSh3eo7owY+KYk+oC vu6wMpbJJ5RpupF9arE9Q5DtN2uavTHg8AwWdxl/alpPJPHRfWk1Wjuzw7j6HkJW0S91 2Klw== X-Received: by 10.69.12.229 with SMTP id et5mr12010896pbd.107.1438497724521; Sat, 01 Aug 2015 23:42:04 -0700 (PDT) Received: from Stas-Air.local (108-66-6-48.lightspeed.sntcca.sbcglobal.net. [108.66.6.48]) by smtp.gmail.com with ESMTPSA id em1sm3863633pbd.42.2015.08.01.23.42.03 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 01 Aug 2015 23:42:03 -0700 (PDT) To: Julien Pauli , PHP Internals References: X-Enigmail-Draft-Status: N1110 Message-ID: <55BDBBB5.1000207@gmail.com> Date: Sat, 1 Aug 2015 23:41:57 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Exposing object handles to userland From: smalyshev@gmail.com (Stanislav Malyshev) Hi! > I've been pinged many times to add a new spl_object_id() function to PHP, > that would return the internal object handle of an object. What would be the use of this? > Today, spl_object_hash() partially allows that, but adds many randomness to > the result, which is not very cool to use later (why does it even add > randomness ?). So that people would be less inclined to use these hashes as if they mean something. And to not reveal internal memory details if these IDs are leaked externally for some reason (which they shouldn't be but sigh...) > There has been topics about this subject. > For example, at http://marc.info/?l=php-internals&m=141814350920452&w=2 > > > Beeing able to get the object handle back in PHP userland would ease many > tools, mainly debug-oriented tools. I would say debug tools probably need extensions which can access internal data structures. Exposing internal data creates bad dependencies, then we can't fix bugs or refactor stuff because somebody used internal API in wrong way and now depends on it (like object unserialization problem where people started using unserialization for purposes it was never intended to). Let's say in 8.x we remove handles altogether and replace them with pointers or some other magic? What these tools would be doing then? By creating this function, we put values of object IDs (not even their existence, but also their values!) into public API, which means not we take BC obligations on them. I don't think it is a good thing. > I also know people that print_r($an_object) and parse the output just to > extract the object handle from there... Crazy isn't it ? Yes, they should not be using object handles for any practical purposes, it's an implementation detail depending on which is a bad idea. > Why couldn't we help those people by simply adding a new function that does > the job ? I'm not sure that is the job that should be done. -- Stas Malyshev smalyshev@gmail.com