php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37777 shm_put_var does not work with resource vars
Submitted: 2006-06-11 00:44 UTC Modified: 2006-06-11 16:47 UTC
From: matthias dot etienne at gmail dot com Assigned:
Status: Not a bug Package: Semaphore related
PHP Version: 5.1.4 OS: Debian 3.1
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: matthias dot etienne at gmail dot com
New email:
PHP Version: OS:

 

 [2006-06-11 00:44 UTC] matthias dot etienne at gmail dot com
Description:
------------
You cannot store var of type resource or retrieve a var of type resource with shm_put_var or shm_get_var.
It always returns a int(0).

Reproduce code:
---------------
<?php
$SHM_KEY = ftok(__FILE__, chr( 4 ) );
$data =  shm_attach($SHM_KEY, 1024, 0666);

$test1 = array("hello","world","1","2","3");
$test2 = array("hello","world","4","5","6");
$test3 = fopen('t.bla', 'w');

shm_put_var($data, 1, $test1);
shm_put_var($data, 2,$test2);
shm_put_var($data, 3,$test3);

print_r(shm_get_var($data, 1));
print_r(shm_get_var($data, 2));
var_dump(shm_get_var($data, 3));

fclose($test3);
shm_detach($data);
?>

Expected result:
----------------
Array
(
    [0] => hello
    [1] => world
    [2] => 1
    [3] => 2
    [4] => 3
)
Array
(
    [0] => hello
    [1] => world
    [2] => 4
    [3] => 5
    [4] => 6
)
resource(6) of type (stream)

Actual result:
--------------
Array
(
    [0] => hello
    [1] => world
    [2] => 1
    [3] => 2
    [4] => 3
)
Array
(
    [0] => hello
    [1] => world
    [2] => 4
    [3] => 5
    [4] => 6
)
int(0)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-06-11 15:46 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

You cannot store resources in shared memory.
 [2006-06-11 16:47 UTC] matthias dot etienne at gmail dot com
I did double-check the documentation and it tells:

shm_put_var() inserts or updates the variable with the given variable_key. *All* variable-types are supported.

See: http://fr.php.net/manual/en/function.shm-put-var.php

So the documentation is wrong.
 [2011-04-18 15:45 UTC] kjakobi at goodgamestudios dot com
The documentation is still wrong..
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jan 15 10:01:29 2025 UTC