php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60809 TRAITS - PHPDoc Comment Style Bug
Submitted: 2012-01-19 18:41 UTC Modified: 2012-01-20 12:48 UTC
From: micronix at gmx dot net Assigned: pierrick
Status: Closed Package: *General Issues
PHP Version: 5.4.0RC5 OS: Windows
Private report: No CVE-ID:
 [2012-01-19 18:41 UTC] micronix at gmx dot net
Description:
------------
Hello,

if you created in an separated file a trait with phpdoc inside. The apache server reset the connection immediatly.

Test script:
---------------
/// Example.php
class Example
   use ExampleTrait;

   public function __construct()
   {
       echo $this->hello_world;
   }
}
/// END OF Example.php

/// ExampleTrait.php
trait ExampleTrait {
    /**
     *
     */
    public $hello_world = 'hello World ^^';
}
/// END OF ExampleTrait.php

Expected result:
----------------
The Apache server can not load the output of the page.
the connection was reset while the page was loading.


Patches

bug60809.phpt (last revision 2012-01-20 02:39 UTC) by pierrick@php.net)
60809.diff (last revision 2012-01-20 02:19 UTC) by pierrick@php.net)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-01-19 18:48 UTC] gron@php.net
-Status: Open +Status: Critical
 [2012-01-19 18:48 UTC] gron@php.net
I can confirm that.

smarr:~/svn/trunk$ sapi/cli/php  doctest.php 
[Thu Jan 19 19:45:13 2012]  Script:  'doctest.php'
---------------------------------------
/Users/smarr/Projects/PHP-Traits/svn/trunk/Zend/zend_compile.c(131) : Block 
0x1007c60e8 status:
Beginning:  	Cached
Freed (invalid)
    Start:	OK
      End:	OK
---------------------------------------


Looks like zend_destroy_property_info thinks it should free something, which might 
already have been freed.

Won't have time to look into that before the weekend.
Sorry.
 [2012-01-19 23:43 UTC] stas@php.net
Could you post what's in your doctest.php exactly?
 [2012-01-19 23:49 UTC] gron@php.net
Micronix was just a bit sloppy with typos etc.
I tested on a trunk from 14th of Jan.:

//doc.php
<?php
trait ExampleTrait {
   /**
    *
    */
   public $hello_world = 'hello World ^^';
}


//doctest.php
<?php
include('doc.php');
class Example {
  use ExampleTrait;

  public function __construct()
  {
      echo $this->hello_world;
  }
}
 [2012-01-20 02:19 UTC] pierrick@php.net
The following patch has been added/updated:

Patch Name: 60809.diff
Revision:   1327025994
URL:        https://bugs.php.net/patch-display.php?bug=60809&patch=60809.diff&revision=1327025994
 [2012-01-20 02:21 UTC] pierrick@php.net
Problem is because zend_do_traits_property_binding use zend_declare_property_ex 
without doing a estrndup of the doc_comment. I attached a patch please Stas or 
dsp confirm that I can commit it :)
 [2012-01-20 02:25 UTC] pierrick@php.net
-Assigned To: +Assigned To: pierrick
 [2012-01-20 02:26 UTC] laruence@php.net
pierrick, I suggest doing like:
char *doccomment = NULL;

if () {
   doccomment = estrndup();
}

thanks :)
 [2012-01-20 02:26 UTC] laruence@php.net
pierrick, I suggest doing like:
char *doccomment = NULL;

if () {
   doccomment = estrndup();
}

thanks :)
 [2012-01-20 02:28 UTC] pierrick@php.net
I can do it like that yes. I'll just have to declare the variable inside the loop 
to make sure the doc_comment is reinitialized and NULL if no doc_comment is 
there.
 [2012-01-20 02:32 UTC] laruence@php.net
ah, you are right, ingore my noise :)
 [2012-01-20 02:39 UTC] pierrick@php.net
The following patch has been added/updated:

Patch Name: bug60809.phpt
Revision:   1327027197
URL:        https://bugs.php.net/patch-display.php?bug=60809&patch=bug60809.phpt&revision=1327027197
 [2012-01-20 12:30 UTC] dmitry@php.net
Automatic comment from SVN on behalf of dmitry
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=322495
Log: Fixed Bug #60809 (TRAITS - PHPDoc Comment Style Bug)
Fixed some other traits related bugs (uninitialized variable, return =&gt; continue)
Removed some trait related redundant code and variables
 [2012-01-20 12:48 UTC] dmitry@php.net
-Status: Critical +Status: Closed
 [2012-01-20 12:48 UTC] dmitry@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 [2012-04-18 09:46 UTC] laruence@php.net
Automatic comment on behalf of dmitry
Revision: http://git.php.net/?p=php-src.git;a=commit;h=f9e6af5ef1406c66173814c90d52bc73a49c7265
Log: Fixed Bug #60809 (TRAITS - PHPDoc Comment Style Bug) Fixed some other traits related bugs (uninitialized variable, return =&gt; continue) Removed some trait related redundant code and variables
 [2012-07-24 23:37 UTC] rasmus@php.net
Automatic comment on behalf of dmitry
Revision: http://git.php.net/?p=php-src.git;a=commit;h=f9e6af5ef1406c66173814c90d52bc73a49c7265
Log: Fixed Bug #60809 (TRAITS - PHPDoc Comment Style Bug) Fixed some other traits related bugs (uninitialized variable, return =&gt; continue) Removed some trait related redundant code and variables
 [2013-11-17 09:34 UTC] laruence@php.net
Automatic comment on behalf of dmitry
Revision: http://git.php.net/?p=php-src.git;a=commit;h=f9e6af5ef1406c66173814c90d52bc73a49c7265
Log: Fixed Bug #60809 (TRAITS - PHPDoc Comment Style Bug) Fixed some other traits related bugs (uninitialized variable, return =&gt; continue) Removed some trait related redundant code and variables
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Sat Apr 19 17:01:54 2014 UTC