php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28163 Method calls fail on DOM document objects passed as session variables
Submitted: 2004-04-26 18:30 UTC Modified: 2004-04-26 22:33 UTC
From: phil3862 at hotmail dot com Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 4.3.6 OS: Redhat 9, 2.4.20-30.9
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: phil3862 at hotmail dot com
New email:
PHP Version: OS:

 

 [2004-04-26 18:30 UTC] phil3862 at hotmail dot com
Description:
------------
Method calls fail on DOM document objects passed as session variables.  This happens whether you pass the DOM document object itself or a reference to the object as a session variable.  If you serialize and unserialize an object reference to a DOM document object without passing it as a session variable, it works fine:

<?php

  /**
   * This test shows that a reference to a DOM object can be
   * serialized and unserialized and still be used.
   */
$xml = "<?xml version='1.0' ?><foo><bar>Hoot!</bar></foo>";
$foo =& domxml_open_mem($xml);
$foo = unserialize(serialize($foo));
print $foo->dump_mem();

?>


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

session_start();

/**
 * This code tests method calls on a reference to a DOM object that
 * has been passed as a session variable.
 */

if (session_is_registered('foo')) {
    $_SESSION['foo']->dump_mem();
    session_unregister('foo');
 } else {
    print "Creating reference to new DOM object as a session variable...";
    session_register('foo');
    $xml = "<?xml version='1.0' ?><foo><bar>Hoot!</bar></foo>";
    $_SESSION['foo'] =& domxml_open_mem($xml);
 }

?>

<?php

session_start();

/**
 * This code tests method calls on a DOM object that has been passed
 * as a session variable.
 */

if (session_is_registered('foo')) {
    $_SESSION['foo']->dump_mem();
    session_unregister('foo');
 } else {
    print "Creating new DOM object as a session variable...";
    session_register('foo');
    $xml = "<?xml version='1.0' ?><foo><bar>Hoot!</bar></foo>";
    $_SESSION['foo'] = domxml_open_mem($xml);
 }

?>


Expected result:
----------------
Both of these scripts should print the original xml source.


Actual result:
--------------
Both fail with "Warning: dump_mem(): Underlying object missing or of invalid type" followed by "Warning: dump_mem():  Cannot fetch DOM object" error.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-04-26 20:10 UTC] derick@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

.
 [2004-04-26 21:04 UTC] phil3862 at hotmail dot com
From the information that I have available to me now, I believe this is a bug with the experimental DOM XML extension that ships with php 4.3.6.  I reduced the issue to two short scripts in the "Reproduce code" section that each reproduce the behavior.

In order to reproduce the behavior, take either one of the scripts, run it in a web browser, click reload, and observe the behavior.
 [2004-04-26 21:56 UTC] phil3862 at hotmail dot com
In the reproduce code, there should be a print before each dump_mem(), so the reproduce code should be:

<?php

session_start();

/**
 * This code tests method calls on a reference to a DOM object that
 * has been passed as a session variable.
 */

if (session_is_registered('foo')) {
    print $_SESSION['foo']->dump_mem();
    session_unregister('foo');
 } else {
    print "Creating reference to new DOM object as a session variable...";
    session_register('foo');
    $xml = "<?xml version='1.0' ?><foo><bar>Hoot!</bar></foo>";
    $_SESSION['foo'] =& domxml_open_mem($xml);
 }

?>

<?php

session_start();

/**
 * This code tests method calls on a DOM object that has been passed
 * as a session variable.
 */

if (session_is_registered('foo')) {
    print $_SESSION['foo']->dump_mem();
    session_unregister('foo');
 } else {
    print "Creating new DOM object as a session variable...";
    session_register('foo');
    $xml = "<?xml version='1.0' ?><foo><bar>Hoot!</bar></foo>";
    $_SESSION['foo'] = domxml_open_mem($xml);
 }

?>
 [2004-04-26 22:33 UTC] derick@php.net
It's not a bug, you can't put objects that rely on libraries in sessions.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 04:01:28 2024 UTC