Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88485 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66764 invoked from network); 24 Sep 2015 20:49:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Sep 2015 20:49:53 -0000 Authentication-Results: pb1.pair.com header.from=zardozrocks@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=zardozrocks@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.171 as permitted sender) X-PHP-List-Original-Sender: zardozrocks@gmail.com X-Host-Fingerprint: 209.85.213.171 mail-ig0-f171.google.com Received: from [209.85.213.171] ([209.85.213.171:35586] helo=mail-ig0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 84/71-58589-EE164065 for ; Thu, 24 Sep 2015 16:49:51 -0400 Received: by igbkq10 with SMTP id kq10so274399igb.0 for ; Thu, 24 Sep 2015 13:49:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=CC4fRQOdCBTTWv6AitoIGhxVnX4eJTvlYiyhnWPH33I=; b=CnNDZIrOP5xBH8GG4A3+kc0W6R0G/Ksb+tahhlPnINcEeNAKqfiQH/YL8RegTlkpor 6GLcxNEBnldMPoQjp4zL247MRM64bJme9/7LA6GH5bReiMIXNhPfuQa8sNIkZeIio1HW 112u/NVSf+1ZpeuA0mRO4zYM8oOGpCKGNxgSlwFjpLD7sCNa3UUgh25dzZpbjbzrDVgr e7dgER+6es6CDgmsJjovb2/9UuAbeG+qwclrb3ij2lXW0MowmE3IThymdOl01jnjKObl a8HiolZQ2KK2zcLYCWBY5m48UVi/LsaCJFP6AFlywwwvq5PTV3DROkm6IfwWzAh62Eld ofGw== MIME-Version: 1.0 X-Received: by 10.50.3.71 with SMTP id a7mr3072073iga.9.1443127788085; Thu, 24 Sep 2015 13:49:48 -0700 (PDT) Received: by 10.107.31.148 with HTTP; Thu, 24 Sep 2015 13:49:47 -0700 (PDT) In-Reply-To: <56045E4C.1040407@gmail.com> References: <5601F58A.7000602@php.net> <64233ECB-7422-4D7C-A8A5-E77FC98C09E2@gmail.com> <56045E4C.1040407@gmail.com> Date: Thu, 24 Sep 2015 13:49:47 -0700 Message-ID: To: internals Content-Type: multipart/alternative; boundary=089e013c6fa82caa7b0520845f4a Subject: Re: [PHP-DEV] Data serialization of objects, want to iterate 'sealed' properties then dynamic ones From: zardozrocks@gmail.com (j adams) --089e013c6fa82caa7b0520845f4a Content-Type: text/plain; charset=UTF-8 Thanks, Rowan, for the clarification! And no, this is not my primary question. At the risk of irritating everyone, here are the questions I need answered: 1) Is there not any way to first iterate through the default properties and then iterate through *only the dynamic properties* ? zend_object->properties appears to contain ALL properties if the object has a single dynamically-assigned property. If so, please advise? If not, please confirm? 2) Will the code below ALWAYS return the properties in the same sequence? E.g., if I am iterating through N objects of type MyClass, will each instance iterate the properties in the same order? 3) Will the code below ALWAYS iterate over default properties (i.e., "sealed" properties, those explicitly defined by class definitinos) FIRST and then iterate any dynamically assigned properties? CODE: zobj = zend_objects_get_address(*val TSRMLS_CC); if (!zobj->properties) { php_printf("***No dynamic properties!\n"); } else { php_printf("***we got dynamic properties...sadly, this will also iterate through default properties too\n"); zend_hash_internal_pointer_reset_ex(zobj->properties, &pos); while (zend_hash_get_current_data_ex(zobj->properties, (void **) &value, &pos) == SUCCESS) { if (zend_hash_get_current_key_ex(zobj->properties, &key, &key_len, &num_index, 0, &pos) == HASH_KEY_IS_STRING) { if (zend_check_property_access(zobj, key, key_len-1 TSRMLS_CC) == SUCCESS) { zend_unmangle_property_name(key, key_len - 1, &class_name, &prop_name); php_printf("dynamic property is %s, key_len is %d\n", prop_name, key_len); } } zend_hash_move_forward_ex(zobj->properties, &pos); } } On Thu, Sep 24, 2015 at 1:34 PM, Rowan Collins wrote: > On 23/09/2015 22:16, j adams wrote: > >> Not my intention to be combative, but what abouthttp://php.net/pcntl_fork >> ? I've used that before in a robust distributed application that runs >> without any intervention for months. It's my understanding that PHP is >> thread safe, but not itself multithreaded. I believe there are some >> extensions which aren't thread safe. Also correct me if I'm wrong but >> Apache 2 should be run in it's prefork mode when using PHP. >> > > Process forking is very different from multi-threading. Your original > question was whether a central object store could cause problems, but as I > understand it a forked process shares no memory with its parent, so that's > not a problem. > > The internal thread safety mode ("ZTS") does indeed have to duplicate the > object store for each thread, though. The general idea (in Zend Engine 2 / > PHP 5, at least) being that a structure is passed around via TSRM* macros > and ultimately used by the EG macro in place of a true global: > http://lxr.php.net/xref/PHP_5_6/Zend/zend_globals_macros.h#45 > > All of this is something of an aside from what you really wanted to know, > though. :) > > > Regards, > > -- > Rowan Collins > [IMSoP] > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --089e013c6fa82caa7b0520845f4a--