php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31685 Some postgres features fail when used with $_SESSION superglobal
Submitted: 2005-01-25 09:11 UTC Modified: 2008-02-12 13:56 UTC
From: rich at tallman dot org Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.3.9 OS: Linux
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: rich at tallman dot org
New email:
PHP Version: OS:

 

 [2005-01-25 09:11 UTC] rich at tallman dot org
Description:
------------
pg_last_notice() fails in very specific circumstances. The failure seems to happen under only a very specific set of circumstances.

- The $_SESSION superglobal is used to hold a db connection resource.
- There is an active session.
- The database connection is made in an included file.

Reproduce code:
---------------
<? // filename - thisworks.php
session_start();
$_SESSION["dbconn"]=pg_connect("dbname=meridican user=postgres password=");
$result=pg_query($_SESSION["dbconn"],$sql);
echo pg_last_notice($_SESSION["dbconn"]); ?>

<? // filename - thisdoesntwork.php
session_start();
include("dbconn.php");
$result=pg_query($_SESSION["dbconn"],$sql);
echo pg_last_notice($_SESSION["dbconn"]); ?>

<? // filename - dbconn.php
$_SESSION["dbconn"]=pg_connect("dbname=meridican user=postgres password="); ?>


Expected result:
----------------
In the example, the output from thisworks.php is the notice raised by postgres. The same result could be expected from the nearly identical code run in thisdoesntwork.php.

Actual result:
--------------
In actuality, thisdoesntwork.php outputs a blank. 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-25 14:30 UTC] sniper@php.net
DB connection resources can not be passed along within sessions -> We're not gonna 'fix' anything here.

 [2005-01-26 03:58 UTC] rich at tallman dot org
I am not suggesting that database resource should be valid later in a session. I am simply pointing out that the value is corrupted within the execution of the same page. This is definitely a bug.

You can choose not to fix it, but perhaps then you can document that the $_SESSION variable is not ACTUALLY superglobal, and may not retain values between included pages.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 17 16:01:28 2024 UTC