Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68305 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 51372 invoked from network); 25 Jul 2013 17:19:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Jul 2013 17:19:13 -0000 Authentication-Results: pb1.pair.com header.from=jakub.php@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=jakub.php@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.128.41 as permitted sender) X-PHP-List-Original-Sender: jakub.php@gmail.com X-Host-Fingerprint: 209.85.128.41 mail-qe0-f41.google.com Received: from [209.85.128.41] ([209.85.128.41:35268] helo=mail-qe0-f41.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FD/65-05798-F0E51F15 for ; Thu, 25 Jul 2013 13:19:11 -0400 Received: by mail-qe0-f41.google.com with SMTP id b4so485493qen.0 for ; Thu, 25 Jul 2013 10:19:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type; bh=b3HyjoAdfNikwkcoejtMQC9c+Wp7oL2oLaclTGc6uXk=; b=x8EWdeY3w932s789Gji/cL5SxK0zUTjP6V84wD9H7fXjXJU4+MBeqZFWaIC+Py8iQd SoJfRoi4jt4gJTsll/+JmPEiaz6bvcREJtsFNxl53yTHaZj4EJg+J3rNuMtRm3EHZ8aL dAEtBAdRuQuloHPzPmL/VhbIop91K4We4NFs+16MJDIm0UoX/Cuwnou7mROxtFkMyvO7 ZweL4SAqIf9hUp/Z32EhuEgH5lXW7cTr5LvN/DKwlFmpqnFyTwRukYWs0BJIi5x70QFF ufKmmsgbAuloshMTCb0uGMHc/XJ4dmNguDry8IFgX4HVWjttqjY0ihO1v9e/zNOneKW2 vlEw== MIME-Version: 1.0 X-Received: by 10.224.15.205 with SMTP id l13mr24738164qaa.67.1374772746888; Thu, 25 Jul 2013 10:19:06 -0700 (PDT) Sender: jakub.php@gmail.com Received: by 10.224.178.69 with HTTP; Thu, 25 Jul 2013 10:19:06 -0700 (PDT) Date: Thu, 25 Jul 2013 18:19:06 +0100 X-Google-Sender-Auth: aK-qLafbLU5K9ci_HChaKa3nG9E Message-ID: To: PHP internals list , Derick Rethans , nikic@php.net Content-Type: multipart/alternative; boundary=047d7bdc8e1c39aa0104e2593943 Subject: Bug #60873: DateTime properties From: bukka@php.net (Jakub Zelenka) --047d7bdc8e1c39aa0104e2593943 Content-Type: text/plain; charset=ISO-8859-1 Hi, This is not only about https://bugs.php.net/bug.php?id=60873 :) First of all, I don't think that this bug is a bug. :) It's about accessing undocumented properties that are created as a side effect of calling get_properties DateTime object handler. The properties are probably created to allow debugging and mainly serialization of the object. The problem is that these properties (date, timezone, timezone_type) are publicly available only after calling print_r or serialize or other function that internally uses get_properties handler. This is not exactly a consistent behavior of the object... There are few possible solution to the problem: 1. Making these properties always available. This was my initial idea that is BC and actually fix the "bug". The properties would be retrieved using read_property handler. This is implemented in the PR: https://github.com/php/php-src/pull/393 . It would make sense to also add write_property handler and add warning if the user try to write to the property as this should be done by set* method. The properties would have to be documented of course. It would be sort of similar as xml_dom object read-only props. 2. Making these properties always hidden. There are two solutions for this: 2.1 Retrieving a copy of properties hash table in get_properties: https://github.com/bukka/php-src/compare/date_props . There was actually a props HashTable in php_date_obj that wasn't used so I used it here... 2.2 Using a new serialize handler that I have just requested for addition and get_debug_info. Then return a copy of HashTable (the same as properties). The patch: https://github.com/bukka/php-src/compare/date_serialize I was talking only about DateTime but exactly the same problem is in other objects (DateTimeZone...). I will be happy to write patches for other objects as well after we make a decision which solution is the best! What do you think? Jakub --047d7bdc8e1c39aa0104e2593943--