Unserialize Bug #17728 and Re: [PHP-DEV] Data Hiding Implementation in PHP Classes

From: Date: Sat, 17 Aug 2002 00:25:10 +0000
Subject: Unserialize Bug #17728 and Re: [PHP-DEV] Data Hiding Implementation in PHP Classes
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-86918@lists.php.net to get a copy of this message
Thanks so much for your help Brad and Sander. I've downloaded the newest Zend2 from cvs and compiled it into Php-4.3.0-dev. All of the features of data hiding which I would need for this project look nicely implemented in this engine! But now I'm running a bit of a dilemna. I'm saving serialized objects in a database, but it seems as though the unserialize function is not liking the string that the function serialize outputs. It results in a segmentation fault. I did a gdb trace on it and looked at the zend_hash.c file for maybe a little bit of insight, but nothing jumped out at me as I'm not very familier with php's internal structure. I've attached the trace and code below. I've noticed a bug in the bug tracking system http://bugs.php.net/bug.php?id=17728, that looks related and unresolved. Any help would be appreciated! Thank you! Ben Dischinger Here is the code that produces the fault: /** * getObject - Returns the object associated with oid from the database **/ function getObject($oid){
     //Get Serialization String and unserialize it
     if($result = $this->getSingleResult("select serialization from phpflux_lang_object where oid=$oid")){
         $serial = $result['serialization'];
         echo $serial;
         return unserialize($serial);
     }
     return null;
} Here is the gdb output: Starting program: /usr/local/bin/php index.php In fluxInclude(): $Class=phpflux.lang.* In include_dir(): $dirStr=/home/disching/Projects/phpflux/classes/phpflux/lang/ In putObject(): In getSingleResult: $query=select serialization from phpflux_lang_object where oid=16 O:10:"testobject":9:{s:7:"package";s:12:"phpflux.lang";s:11:"objectoid";N;s:11:"objectuid";N;s:11:"objectgid";N;s:11:"objectmod";N;s:16:"objectcomments";N;s:1:"A";s:8:"Object A";s:1:"B";s:8:"Object B";s:1:"C";s:8:"Object C";} Program received signal SIGSEGV, Segmentation fault. zend_hash_copy (target=0x400b9814, source=0x81d2b3c, pCopyConstructor=0x811d200 <zval_add_ref>, tmp=0xbfffc048, size=4) at /root/php4/Zend/zend_hash.c:777
777            if (p->nKeyLength) {
(gdb) bt #0 zend_hash_copy (target=0x400b9814, source=0x81d2b3c, pCopyConstructor=0x811d200 <zval_add_ref>, tmp=0xbfffc048, size=4) at /root/php4/Zend/zend_hash.c:777 #1 0x0811f2c9 in _object_and_properties_init (arg=0x400c75f8, class_type=0x81d2afc, properties=0x0) at /root/php4/Zend/zend_API.c:600 #2 0x0811f307 in _object_init_ex (arg=0x400c75f8, class_type=0x81d2afc) at /root/php4/Zend/zend_API.c:610 #3 0x080de205 in php_var_unserialize (rval=0xbfffc214, p=0xbfffc1f8, max=0x400b99cb "", var_hash=0xbfffc1fc) at var_unserializer.re:196 #4 0x080d74e9 in zif_unserialize (ht=1, return_value=0x400c75f8, this_ptr=0x0, return_value_used=1) at /root/php4/ext/standard/var.c:667 #5 0x08130153 in execute (op_array=0x400b456c) at /root/php4/Zend/zend_execute.c:2079 #6 0x08130245 in execute (op_array=0x400aca14) at /root/php4/Zend/zend_execute.c:2103 #7 0x0811e304 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /root/php4/Zend/zend.c:832 #8 0x080fd169 in php_execute_script (primary_file=0xbffffa80) at /root/php4/main/main.c:1504 #9 0x08136a60 in main (argc=2, argv=0xbffffb24) at /root/php4/sapi/cli/php_cli.c:683 #10 0x42017499 in __libc_start_main () from /lib/i686/libc.so.6 Brad LaFountain wrote:
That .txt only talks about private members. Zend2 also implements protected data members. - brad --- Sander Roobol <sander@php.net> wrote:
The Zend Engine 2 implements this. See http://www.php.net/ZEND_CHANGES.txt Sander On Fri, Aug 16, 2002 at 03:13:57AM -0500, Ben Dischinger wrote:
Hello, My question is if there is anyone working on an implementation of data
hiding in php? IE Public, private, and protected data types within php classes. I can not find anywhere mentioning this besides very few websites that say it is on the "TODO" list.
The research that I'm doing involves dynamically programming php from the
internet collectively with many users, of which some would have restricted access rights to specific objects. All objects would have certain data that I would need to be of type private, ie owner id, permission mode, etc... in order for the object security model to be safe. Without data hiding any user using this system could simply type $Current_User->UID=0 which would then change the owner of this object, which happens to be a user to 0, or god. There may be a different way to implement this that I'm not seeing, but any model that I come up with in php I can circumvent by some simular means.
I may need to implement a servlet in java that keeps track of currently
logged in users and objects in memory, but this would be more overhead than wanted. If data hiding was implemented in PHP I would be very excited. If there is not already someone working on it, perhaps I will roll up my sleeves and get my elbows dirty.
Thank you so much for reading. Ben Dischinger NDSU Computer Science
-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php
__________________________________________________ Do You Yahoo!? HotJobs - Search Thousands of New Jobs http://www.hotjobs.com


« previous php.dev (#86918) next »