You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "David Sklar (JIRA)" <ji...@apache.org> on 2009/02/17 23:50:59 UTC

[jira] Created: (THRIFT-342) PHP: can't have sets of complex types

PHP: can't have sets of complex types
-------------------------------------

                 Key: THRIFT-342
                 URL: https://issues.apache.org/jira/browse/THRIFT-342
             Project: Thrift
          Issue Type: Bug
          Components: Compiler (PHP), Library (PHP)
         Environment: SVN trunk r743881
            Reporter: David Sklar


A setup like this:

struct alice {
  1: string bob
}

and another like this:

struct charlie {
   1: set<alice> david
}

causes problems because the generated PHP code looks like:

==
        case 1:
          if ($ftype == TType::SET) {
            $this->david = array();
            $_size0 = 0;
            $_etype3 = 0;
            $xfer += $input->readSetBegin($_etype3, $_size0);
            for ($_i4 = 0; $_i4 < $_size0; ++$_i4)
            {
              $elem5 = null;
              $elem5 = new alice();
              $xfer += $elem5->read($input);
              $this->david[$elem5] = true;
            }
            $xfer += $input->readSetEnd();
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
===

Using objects as array keys makes PHP cranky and the values can not be properly set. I think the solution to this is either:

1. Document that the PHP bindings do not support sets of complex types. (boooo!)

2. Modify the generated code so that the values are stored in array values not keys. (With some additional checks to ensure uniqueness, or perhaps just using spl_object_hash($theObject) as the array key.

This seems similar to the issues raised in THRIFT-231 and THRIFT-162
              $this->david[$elem5] = true;



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (THRIFT-342) PHP: can't have sets of complex types

Posted by "Bryan Duxbury (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-342?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryan Duxbury updated THRIFT-342:
---------------------------------

    Fix Version/s: 0.5
                       (was: 0.4)

> PHP: can't have sets of complex types
> -------------------------------------
>
>                 Key: THRIFT-342
>                 URL: https://issues.apache.org/jira/browse/THRIFT-342
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (PHP), Library (PHP)
>         Environment: SVN trunk r743881
>            Reporter: David Sklar
>             Fix For: 0.5
>
>
> A setup like this:
> struct alice {
>   1: string bob
> }
> and another like this:
> struct charlie {
>    1: set<alice> david
> }
> causes problems because the generated PHP code looks like:
> ==
>         case 1:
>           if ($ftype == TType::SET) {
>             $this->david = array();
>             $_size0 = 0;
>             $_etype3 = 0;
>             $xfer += $input->readSetBegin($_etype3, $_size0);
>             for ($_i4 = 0; $_i4 < $_size0; ++$_i4)
>             {
>               $elem5 = null;
>               $elem5 = new alice();
>               $xfer += $elem5->read($input);
>               $this->david[$elem5] = true;
>             }
>             $xfer += $input->readSetEnd();
>           } else {
>             $xfer += $input->skip($ftype);
>           }
>           break;
> ===
> Using objects as array keys makes PHP cranky and the values can not be properly set. I think the solution to this is either:
> 1. Document that the PHP bindings do not support sets of complex types. (boooo!)
> 2. Modify the generated code so that the values are stored in array values not keys. (With some additional checks to ensure uniqueness, or perhaps just using spl_object_hash($theObject) as the array key.
> This seems similar to the issues raised in THRIFT-231 and THRIFT-162
>               $this->david[$elem5] = true;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-342) PHP: can't have sets of complex types

Posted by "Bryan Duxbury (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-342?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12912493#action_12912493 ] 

Bryan Duxbury commented on THRIFT-342:
--------------------------------------

This just changes our implementation of "set" in PHP with an array, right? If there's no reliable set construct, this seems like the next best thing. 

Unless there are any objections, I'll commit this later today.

> PHP: can't have sets of complex types
> -------------------------------------
>
>                 Key: THRIFT-342
>                 URL: https://issues.apache.org/jira/browse/THRIFT-342
>             Project: Thrift
>          Issue Type: Bug
>          Components: PHP - Compiler, PHP - Library
>         Environment: SVN trunk r743881
>            Reporter: David Sklar
>         Attachments: thrift-342.patch
>
>
> A setup like this:
> struct alice {
>   1: string bob
> }
> and another like this:
> struct charlie {
>    1: set<alice> david
> }
> causes problems because the generated PHP code looks like:
> ==
>         case 1:
>           if ($ftype == TType::SET) {
>             $this->david = array();
>             $_size0 = 0;
>             $_etype3 = 0;
>             $xfer += $input->readSetBegin($_etype3, $_size0);
>             for ($_i4 = 0; $_i4 < $_size0; ++$_i4)
>             {
>               $elem5 = null;
>               $elem5 = new alice();
>               $xfer += $elem5->read($input);
>               $this->david[$elem5] = true;
>             }
>             $xfer += $input->readSetEnd();
>           } else {
>             $xfer += $input->skip($ftype);
>           }
>           break;
> ===
> Using objects as array keys makes PHP cranky and the values can not be properly set. I think the solution to this is either:
> 1. Document that the PHP bindings do not support sets of complex types. (boooo!)
> 2. Modify the generated code so that the values are stored in array values not keys. (With some additional checks to ensure uniqueness, or perhaps just using spl_object_hash($theObject) as the array key.
> This seems similar to the issues raised in THRIFT-231 and THRIFT-162
>               $this->david[$elem5] = true;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-342) PHP: can't have sets of complex types

Posted by "David Reiss (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-342?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12909396#action_12909396 ] 

David Reiss commented on THRIFT-342:
------------------------------------

array_unique doesn't actually work on complex types.  I don't think there is a clean solution to this problem, but one step might be to keep the current representation for sets of ints and strings and use the flat array for sets of complex types.  I think the user has to be responsible for uniqueness in that case.

> PHP: can't have sets of complex types
> -------------------------------------
>
>                 Key: THRIFT-342
>                 URL: https://issues.apache.org/jira/browse/THRIFT-342
>             Project: Thrift
>          Issue Type: Bug
>          Components: PHP - Compiler, PHP - Library
>         Environment: SVN trunk r743881
>            Reporter: David Sklar
>         Attachments: thrift-342.patch
>
>
> A setup like this:
> struct alice {
>   1: string bob
> }
> and another like this:
> struct charlie {
>    1: set<alice> david
> }
> causes problems because the generated PHP code looks like:
> ==
>         case 1:
>           if ($ftype == TType::SET) {
>             $this->david = array();
>             $_size0 = 0;
>             $_etype3 = 0;
>             $xfer += $input->readSetBegin($_etype3, $_size0);
>             for ($_i4 = 0; $_i4 < $_size0; ++$_i4)
>             {
>               $elem5 = null;
>               $elem5 = new alice();
>               $xfer += $elem5->read($input);
>               $this->david[$elem5] = true;
>             }
>             $xfer += $input->readSetEnd();
>           } else {
>             $xfer += $input->skip($ftype);
>           }
>           break;
> ===
> Using objects as array keys makes PHP cranky and the values can not be properly set. I think the solution to this is either:
> 1. Document that the PHP bindings do not support sets of complex types. (boooo!)
> 2. Modify the generated code so that the values are stored in array values not keys. (With some additional checks to ensure uniqueness, or perhaps just using spl_object_hash($theObject) as the array key.
> This seems similar to the issues raised in THRIFT-231 and THRIFT-162
>               $this->david[$elem5] = true;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-342) PHP: can't have sets of complex types

Posted by "Arya Goudarzi (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-342?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12909533#action_12909533 ] 

Arya Goudarzi commented on THRIFT-342:
--------------------------------------

+1 for Jake's patch.

> PHP: can't have sets of complex types
> -------------------------------------
>
>                 Key: THRIFT-342
>                 URL: https://issues.apache.org/jira/browse/THRIFT-342
>             Project: Thrift
>          Issue Type: Bug
>          Components: PHP - Compiler, PHP - Library
>         Environment: SVN trunk r743881
>            Reporter: David Sklar
>         Attachments: thrift-342.patch
>
>
> A setup like this:
> struct alice {
>   1: string bob
> }
> and another like this:
> struct charlie {
>    1: set<alice> david
> }
> causes problems because the generated PHP code looks like:
> ==
>         case 1:
>           if ($ftype == TType::SET) {
>             $this->david = array();
>             $_size0 = 0;
>             $_etype3 = 0;
>             $xfer += $input->readSetBegin($_etype3, $_size0);
>             for ($_i4 = 0; $_i4 < $_size0; ++$_i4)
>             {
>               $elem5 = null;
>               $elem5 = new alice();
>               $xfer += $elem5->read($input);
>               $this->david[$elem5] = true;
>             }
>             $xfer += $input->readSetEnd();
>           } else {
>             $xfer += $input->skip($ftype);
>           }
>           break;
> ===
> Using objects as array keys makes PHP cranky and the values can not be properly set. I think the solution to this is either:
> 1. Document that the PHP bindings do not support sets of complex types. (boooo!)
> 2. Modify the generated code so that the values are stored in array values not keys. (With some additional checks to ensure uniqueness, or perhaps just using spl_object_hash($theObject) as the array key.
> This seems similar to the issues raised in THRIFT-231 and THRIFT-162
>               $this->david[$elem5] = true;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-342) PHP: can't have sets of complex types

Posted by "David Reiss (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-342?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12909387#action_12909387 ] 

David Reiss commented on THRIFT-342:
------------------------------------

I think this breaks set semantics for integers and strings.  It's possible to have two copies of the same integer in a set with this patch.

> PHP: can't have sets of complex types
> -------------------------------------
>
>                 Key: THRIFT-342
>                 URL: https://issues.apache.org/jira/browse/THRIFT-342
>             Project: Thrift
>          Issue Type: Bug
>          Components: PHP - Compiler, PHP - Library
>         Environment: SVN trunk r743881
>            Reporter: David Sklar
>         Attachments: thrift-342.patch
>
>
> A setup like this:
> struct alice {
>   1: string bob
> }
> and another like this:
> struct charlie {
>    1: set<alice> david
> }
> causes problems because the generated PHP code looks like:
> ==
>         case 1:
>           if ($ftype == TType::SET) {
>             $this->david = array();
>             $_size0 = 0;
>             $_etype3 = 0;
>             $xfer += $input->readSetBegin($_etype3, $_size0);
>             for ($_i4 = 0; $_i4 < $_size0; ++$_i4)
>             {
>               $elem5 = null;
>               $elem5 = new alice();
>               $xfer += $elem5->read($input);
>               $this->david[$elem5] = true;
>             }
>             $xfer += $input->readSetEnd();
>           } else {
>             $xfer += $input->skip($ftype);
>           }
>           break;
> ===
> Using objects as array keys makes PHP cranky and the values can not be properly set. I think the solution to this is either:
> 1. Document that the PHP bindings do not support sets of complex types. (boooo!)
> 2. Modify the generated code so that the values are stored in array values not keys. (With some additional checks to ensure uniqueness, or perhaps just using spl_object_hash($theObject) as the array key.
> This seems similar to the issues raised in THRIFT-231 and THRIFT-162
>               $this->david[$elem5] = true;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (THRIFT-342) PHP: can't have sets of complex types

Posted by "Bryan Duxbury (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-342?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryan Duxbury updated THRIFT-342:
---------------------------------

    Fix Version/s: 0.4
                       (was: 0.3)

> PHP: can't have sets of complex types
> -------------------------------------
>
>                 Key: THRIFT-342
>                 URL: https://issues.apache.org/jira/browse/THRIFT-342
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (PHP), Library (PHP)
>         Environment: SVN trunk r743881
>            Reporter: David Sklar
>             Fix For: 0.4
>
>
> A setup like this:
> struct alice {
>   1: string bob
> }
> and another like this:
> struct charlie {
>    1: set<alice> david
> }
> causes problems because the generated PHP code looks like:
> ==
>         case 1:
>           if ($ftype == TType::SET) {
>             $this->david = array();
>             $_size0 = 0;
>             $_etype3 = 0;
>             $xfer += $input->readSetBegin($_etype3, $_size0);
>             for ($_i4 = 0; $_i4 < $_size0; ++$_i4)
>             {
>               $elem5 = null;
>               $elem5 = new alice();
>               $xfer += $elem5->read($input);
>               $this->david[$elem5] = true;
>             }
>             $xfer += $input->readSetEnd();
>           } else {
>             $xfer += $input->skip($ftype);
>           }
>           break;
> ===
> Using objects as array keys makes PHP cranky and the values can not be properly set. I think the solution to this is either:
> 1. Document that the PHP bindings do not support sets of complex types. (boooo!)
> 2. Modify the generated code so that the values are stored in array values not keys. (With some additional checks to ensure uniqueness, or perhaps just using spl_object_hash($theObject) as the array key.
> This seems similar to the issues raised in THRIFT-231 and THRIFT-162
>               $this->david[$elem5] = true;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-342) PHP: can't have sets of complex types

Posted by "David Reiss (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-342?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12912576#action_12912576 ] 

David Reiss commented on THRIFT-342:
------------------------------------

Using array keys as set elements *is* a reliable set construct for ints and strings.  We shouldn't break the few cases that already work.

> PHP: can't have sets of complex types
> -------------------------------------
>
>                 Key: THRIFT-342
>                 URL: https://issues.apache.org/jira/browse/THRIFT-342
>             Project: Thrift
>          Issue Type: Bug
>          Components: PHP - Compiler, PHP - Library
>         Environment: SVN trunk r743881
>            Reporter: David Sklar
>         Attachments: thrift-342.patch
>
>
> A setup like this:
> struct alice {
>   1: string bob
> }
> and another like this:
> struct charlie {
>    1: set<alice> david
> }
> causes problems because the generated PHP code looks like:
> ==
>         case 1:
>           if ($ftype == TType::SET) {
>             $this->david = array();
>             $_size0 = 0;
>             $_etype3 = 0;
>             $xfer += $input->readSetBegin($_etype3, $_size0);
>             for ($_i4 = 0; $_i4 < $_size0; ++$_i4)
>             {
>               $elem5 = null;
>               $elem5 = new alice();
>               $xfer += $elem5->read($input);
>               $this->david[$elem5] = true;
>             }
>             $xfer += $input->readSetEnd();
>           } else {
>             $xfer += $input->skip($ftype);
>           }
>           break;
> ===
> Using objects as array keys makes PHP cranky and the values can not be properly set. I think the solution to this is either:
> 1. Document that the PHP bindings do not support sets of complex types. (boooo!)
> 2. Modify the generated code so that the values are stored in array values not keys. (With some additional checks to ensure uniqueness, or perhaps just using spl_object_hash($theObject) as the array key.
> This seems similar to the issues raised in THRIFT-231 and THRIFT-162
>               $this->david[$elem5] = true;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (THRIFT-342) PHP: can't have sets of complex types

Posted by "Bryan Duxbury (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-342?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryan Duxbury updated THRIFT-342:
---------------------------------

    Fix Version/s: 0.2

> PHP: can't have sets of complex types
> -------------------------------------
>
>                 Key: THRIFT-342
>                 URL: https://issues.apache.org/jira/browse/THRIFT-342
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (PHP), Library (PHP)
>         Environment: SVN trunk r743881
>            Reporter: David Sklar
>             Fix For: 0.2
>
>
> A setup like this:
> struct alice {
>   1: string bob
> }
> and another like this:
> struct charlie {
>    1: set<alice> david
> }
> causes problems because the generated PHP code looks like:
> ==
>         case 1:
>           if ($ftype == TType::SET) {
>             $this->david = array();
>             $_size0 = 0;
>             $_etype3 = 0;
>             $xfer += $input->readSetBegin($_etype3, $_size0);
>             for ($_i4 = 0; $_i4 < $_size0; ++$_i4)
>             {
>               $elem5 = null;
>               $elem5 = new alice();
>               $xfer += $elem5->read($input);
>               $this->david[$elem5] = true;
>             }
>             $xfer += $input->readSetEnd();
>           } else {
>             $xfer += $input->skip($ftype);
>           }
>           break;
> ===
> Using objects as array keys makes PHP cranky and the values can not be properly set. I think the solution to this is either:
> 1. Document that the PHP bindings do not support sets of complex types. (boooo!)
> 2. Modify the generated code so that the values are stored in array values not keys. (With some additional checks to ensure uniqueness, or perhaps just using spl_object_hash($theObject) as the array key.
> This seems similar to the issues raised in THRIFT-231 and THRIFT-162
>               $this->david[$elem5] = true;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (THRIFT-342) PHP: can't have sets of complex types

Posted by "Bryan Duxbury (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-342?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryan Duxbury updated THRIFT-342:
---------------------------------

    Fix Version/s:     (was: 0.5)

> PHP: can't have sets of complex types
> -------------------------------------
>
>                 Key: THRIFT-342
>                 URL: https://issues.apache.org/jira/browse/THRIFT-342
>             Project: Thrift
>          Issue Type: Bug
>          Components: PHP - Compiler, PHP - Library
>         Environment: SVN trunk r743881
>            Reporter: David Sklar
>
> A setup like this:
> struct alice {
>   1: string bob
> }
> and another like this:
> struct charlie {
>    1: set<alice> david
> }
> causes problems because the generated PHP code looks like:
> ==
>         case 1:
>           if ($ftype == TType::SET) {
>             $this->david = array();
>             $_size0 = 0;
>             $_etype3 = 0;
>             $xfer += $input->readSetBegin($_etype3, $_size0);
>             for ($_i4 = 0; $_i4 < $_size0; ++$_i4)
>             {
>               $elem5 = null;
>               $elem5 = new alice();
>               $xfer += $elem5->read($input);
>               $this->david[$elem5] = true;
>             }
>             $xfer += $input->readSetEnd();
>           } else {
>             $xfer += $input->skip($ftype);
>           }
>           break;
> ===
> Using objects as array keys makes PHP cranky and the values can not be properly set. I think the solution to this is either:
> 1. Document that the PHP bindings do not support sets of complex types. (boooo!)
> 2. Modify the generated code so that the values are stored in array values not keys. (With some additional checks to ensure uniqueness, or perhaps just using spl_object_hash($theObject) as the array key.
> This seems similar to the issues raised in THRIFT-231 and THRIFT-162
>               $this->david[$elem5] = true;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (THRIFT-342) PHP: can't have sets of complex types

Posted by "Jake Farrell (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-342?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jake Farrell updated THRIFT-342:
--------------------------------

    Attachment: thrift-342.patch

Patch to allow for sets to be used within php to java/python/etc.

> PHP: can't have sets of complex types
> -------------------------------------
>
>                 Key: THRIFT-342
>                 URL: https://issues.apache.org/jira/browse/THRIFT-342
>             Project: Thrift
>          Issue Type: Bug
>          Components: PHP - Compiler, PHP - Library
>         Environment: SVN trunk r743881
>            Reporter: David Sklar
>         Attachments: thrift-342.patch
>
>
> A setup like this:
> struct alice {
>   1: string bob
> }
> and another like this:
> struct charlie {
>    1: set<alice> david
> }
> causes problems because the generated PHP code looks like:
> ==
>         case 1:
>           if ($ftype == TType::SET) {
>             $this->david = array();
>             $_size0 = 0;
>             $_etype3 = 0;
>             $xfer += $input->readSetBegin($_etype3, $_size0);
>             for ($_i4 = 0; $_i4 < $_size0; ++$_i4)
>             {
>               $elem5 = null;
>               $elem5 = new alice();
>               $xfer += $elem5->read($input);
>               $this->david[$elem5] = true;
>             }
>             $xfer += $input->readSetEnd();
>           } else {
>             $xfer += $input->skip($ftype);
>           }
>           break;
> ===
> Using objects as array keys makes PHP cranky and the values can not be properly set. I think the solution to this is either:
> 1. Document that the PHP bindings do not support sets of complex types. (boooo!)
> 2. Modify the generated code so that the values are stored in array values not keys. (With some additional checks to ensure uniqueness, or perhaps just using spl_object_hash($theObject) as the array key.
> This seems similar to the issues raised in THRIFT-231 and THRIFT-162
>               $this->david[$elem5] = true;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-342) PHP: can't have sets of complex types

Posted by "Bryan Duxbury (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-342?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12912593#action_12912593 ] 

Bryan Duxbury commented on THRIFT-342:
--------------------------------------

Can we work up a hybrid patch reasonably quickly then?

> PHP: can't have sets of complex types
> -------------------------------------
>
>                 Key: THRIFT-342
>                 URL: https://issues.apache.org/jira/browse/THRIFT-342
>             Project: Thrift
>          Issue Type: Bug
>          Components: PHP - Compiler, PHP - Library
>         Environment: SVN trunk r743881
>            Reporter: David Sklar
>         Attachments: thrift-342.patch
>
>
> A setup like this:
> struct alice {
>   1: string bob
> }
> and another like this:
> struct charlie {
>    1: set<alice> david
> }
> causes problems because the generated PHP code looks like:
> ==
>         case 1:
>           if ($ftype == TType::SET) {
>             $this->david = array();
>             $_size0 = 0;
>             $_etype3 = 0;
>             $xfer += $input->readSetBegin($_etype3, $_size0);
>             for ($_i4 = 0; $_i4 < $_size0; ++$_i4)
>             {
>               $elem5 = null;
>               $elem5 = new alice();
>               $xfer += $elem5->read($input);
>               $this->david[$elem5] = true;
>             }
>             $xfer += $input->readSetEnd();
>           } else {
>             $xfer += $input->skip($ftype);
>           }
>           break;
> ===
> Using objects as array keys makes PHP cranky and the values can not be properly set. I think the solution to this is either:
> 1. Document that the PHP bindings do not support sets of complex types. (boooo!)
> 2. Modify the generated code so that the values are stored in array values not keys. (With some additional checks to ensure uniqueness, or perhaps just using spl_object_hash($theObject) as the array key.
> This seems similar to the issues raised in THRIFT-231 and THRIFT-162
>               $this->david[$elem5] = true;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-342) PHP: can't have sets of complex types

Posted by "Jake Farrell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-342?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12909392#action_12909392 ] 

Jake Farrell commented on THRIFT-342:
-------------------------------------

correct it does break the semantics for sets, but since php does not have a set type then this allows for php to communicate with languages that do. php will send/recv a list which will be converted over to a set on the other clients end. if necessary could add array_unique() before send/recv in php generator to guarantee a better enforce set type is sent/recv

> PHP: can't have sets of complex types
> -------------------------------------
>
>                 Key: THRIFT-342
>                 URL: https://issues.apache.org/jira/browse/THRIFT-342
>             Project: Thrift
>          Issue Type: Bug
>          Components: PHP - Compiler, PHP - Library
>         Environment: SVN trunk r743881
>            Reporter: David Sklar
>         Attachments: thrift-342.patch
>
>
> A setup like this:
> struct alice {
>   1: string bob
> }
> and another like this:
> struct charlie {
>    1: set<alice> david
> }
> causes problems because the generated PHP code looks like:
> ==
>         case 1:
>           if ($ftype == TType::SET) {
>             $this->david = array();
>             $_size0 = 0;
>             $_etype3 = 0;
>             $xfer += $input->readSetBegin($_etype3, $_size0);
>             for ($_i4 = 0; $_i4 < $_size0; ++$_i4)
>             {
>               $elem5 = null;
>               $elem5 = new alice();
>               $xfer += $elem5->read($input);
>               $this->david[$elem5] = true;
>             }
>             $xfer += $input->readSetEnd();
>           } else {
>             $xfer += $input->skip($ftype);
>           }
>           break;
> ===
> Using objects as array keys makes PHP cranky and the values can not be properly set. I think the solution to this is either:
> 1. Document that the PHP bindings do not support sets of complex types. (boooo!)
> 2. Modify the generated code so that the values are stored in array values not keys. (With some additional checks to ensure uniqueness, or perhaps just using spl_object_hash($theObject) as the array key.
> This seems similar to the issues raised in THRIFT-231 and THRIFT-162
>               $this->david[$elem5] = true;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.