php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32749 shm_put_var/shm_get_var does not work on objects with __sleep defined
Submitted: 2005-04-18 20:38 UTC Modified: 2005-04-19 15:54 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: cr at speedofmind dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.0.3 OS: Linux 2.4.26
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: cr at speedofmind dot com
New email:
PHP Version: OS:

 

 [2005-04-18 20:38 UTC] cr at speedofmind dot com
Description:
------------
When defining a __sleep funtion in a class, it is not possible to successfully save and retrieve objects of this class using shm_put_var and shm_get_var. shm_get_var simple returns NULL.

Reproduce code:
---------------
<?php

class Fruit {
    var $kind;
    var $foo = 'not';
    function Fruit($kind) { $this->kind = $kind; }
    function __wakeup() { $this->foo = 'bar1'; }
    function __sleep() { $this->foo = 'bar2'; } // BREAKS shm_put_var/shm_get_var                                         
}

$var = new Fruit('apple');
$key = 1;

$shmId = shm_attach(24187);
shm_put_var($shmId, $key, $var);
$out = shm_get_var($shmId, $key);  

var_dump($out);

?>

Expected result:
----------------
Expected output:

object(Fruit)#2 (2) {
  ["kind"]=>
  string(5) "apple"
  ["foo"]=>
  string(4) "bar1"
}

Actual result:
--------------
Actual output:

NULL

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-04-19 15:54 UTC] sniper@php.net
Try adding 'error_reporting(E_ALL);' as first line in your script..your code is wrong.

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 19 16:00:02 2025 UTC