Dev Shed Lounge
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOtherDev Shed Lounge

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 19th, 2003, 04:25 PM
jpenn's Avatar
jpenn jpenn is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jun 2002
Location: Washington, DC
Posts: 2,693 jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 h 41 m 10 sec
Reputation Power: 16
Ok - I think this is a little rediculous (for all you php folks)

I reported a bug to the php bug database. This was the exact post:

Subject:
Code:
Problem with session_set_save_handler() when connecting to db outside of obj

Message:
Code:
When connecting to the database inside the class object, everything
works fine with session_set_save_handler(). But, when connecting outside
of the class that holds the methods, php does'nt recognize there is an
active connection to the DB. Is this a known problem that I have
overlooked in the bug db?

I have tried everything, including passing the res id of the connection
into the session handler class but to no avail.

~ Thanks



How many people here can see from this message what is going on - or be able to tell from this what I am getting at - this is the simplest of all things to understand, is it not?

-----------------------------------------------------------

Post your replies and I will post what they came back with.
__________________
~ Joe Penn

Reply With Quote
  #2  
Old June 19th, 2003, 04:57 PM
bcyde's Avatar
bcyde bcyde is offline
Me likey breadsticks...
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jan 2003
Location: Los Angeles
Posts: 1,189 bcyde User rank is Sergeant (500 - 2000 Reputation Level)bcyde User rank is Sergeant (500 - 2000 Reputation Level)bcyde User rank is Sergeant (500 - 2000 Reputation Level)bcyde User rank is Sergeant (500 - 2000 Reputation Level)bcyde User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 Days 1 h 12 m 58 sec
Reputation Power: 12
Send a message via AIM to bcyde Send a message via Yahoo to bcyde
Sounds like:
1)you're using a class that stores your session vars in a DB
2)when your db connection code is in that class sessions work fine
3)when you open a db connection outside your class and try and pass the connection ID into the class so that it can be used for storing your info it doesn't work.

Is that right?

Reply With Quote
  #3  
Old June 19th, 2003, 06:05 PM
Hero Zzyzzx's Avatar
Hero Zzyzzx Hero Zzyzzx is offline
11
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Jul 2001
Location: Lynn, MA
Posts: 4,635 Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 4 Days 23 h 44 m 19 sec
Reputation Power: 77
Send a message via AIM to Hero Zzyzzx
They are connecting out of scope and expecting it to work. Correct?

Reply With Quote
  #4  
Old June 19th, 2003, 06:35 PM
Viper_SB's Avatar
Viper_SB Viper_SB is offline
Psycho Canadian
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Jan 2001
Location: Canada
Posts: 4,793 Viper_SB User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Viper_SB User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Viper_SB User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Viper_SB User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Viper_SB User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Viper_SB User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Viper_SB User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Viper_SB User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Viper_SB User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Viper_SB User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Viper_SB User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 4 Weeks 22 h 50 m 49 sec
Reputation Power: 437
Ya it's clear

Reply With Quote
  #5  
Old June 19th, 2003, 08:19 PM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 13
Send a message via AIM to rod k
Quote:
They are connecting out of scope and expecting it to work
It SHOULD work. Scope has no meaning to DB connections. (Except in this case, evidently).

jpenn,
it really shouldn't matter... PHP should internally return the same connection on a subsequent connection to the same host,username & password (& database depending on the RDBMS used).

Check what resource ID is being returned in each and compare.
__________________
FSBO (For Sale By Owner) Realty

Reply With Quote
  #6  
Old June 19th, 2003, 09:37 PM
jpenn's Avatar
jpenn jpenn is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jun 2002
Location: Washington, DC
Posts: 2,693 jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 h 41 m 10 sec
Reputation Power: 16
Quote:
It SHOULD work. Scope has no meaning to DB connections. (Except in this case, evidently).

jpenn,
it really shouldn't matter... PHP should internally return the same connection on a subsequent connection to the same host,username & password (& database depending on the RDBMS used).

Check what resource ID is being returned in each and compare.

hehe - thats the bug Rod - it should'nt matter, but, it is not working when connecting outside of the class. So, this is how the sess_open() method looks (being the first arg to session_set_save_handler()) -
PHP Code:
function sess_open$a$b )
    {
        
$this->resource = @$this->db['connection']( $this->db['host'], $this->db['user'], $this->db['pass'] ) or 
        
$this->errormysql_error() );
        @
mysql_select_db$this->db['dbas'], $this->resource ) or $this->error'Could Not Select DB' );
        return( 
$this->resource );
    } 

Ok - that is the open method that is passed to the function for setting the custom session handler - every thing works fine on this, as the connection is explicitly made within the method itself.

Now, if removing the db connection outside this method (even if it is still in the same class) it will not register the session handler.

So - the bug is this. How, can one use a db abstraction/connection library while using the custom session handling capabilities.

This is the thing - the custom session handler needs to work with sub classes depending on what database is being used ->
PHP Code:
class session
{

}
class 
mysql_session extends session
{

}
class 
fb_session extends session
{

}
class 
pgre_session extends session
{




I am sure it is nothing to do with the connection resource - for some reason if the connection is not made within the sess_open() method - the whole session handler fails.

To get an idea of what I mean - you can get the class -> http://www.cheetah-soft.com/csh/ - remove the connection functions to outside the class and watch it not work.

-----------------------------------

Hehe - I had asked if it was a clear question becuase the yahoo in the bug department seems to think it was not clear - I thought it was

Reply With Quote
  #7  
Old June 19th, 2003, 09:41 PM
jpenn's Avatar
jpenn jpenn is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jun 2002
Location: Washington, DC
Posts: 2,693 jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 h 41 m 10 sec
Reputation Power: 16
PS: bcyde - that is exactly what it is. Apparently the guy that reviewed the bug does'nt understand english maybe...

Reply With Quote
  #8  
Old June 19th, 2003, 10:49 PM
a.koepke's Avatar
a.koepke a.koepke is offline
Second highest poster :p
Dev Shed God 5th Plane (7000 - 7499 posts)
 
Join Date: Jul 2001
Posts: 7,323 a.koepke User rank is Sergeant (500 - 2000 Reputation Level)a.koepke User rank is Sergeant (500 - 2000 Reputation Level)a.koepke User rank is Sergeant (500 - 2000 Reputation Level)a.koepke User rank is Sergeant (500 - 2000 Reputation Level)a.koepke User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 8 h 11 m 27 sec
Reputation Power: 27
Hehe, just looked up the bug - what a tool

Reply With Quote
  #9  
Old July 7th, 2003, 08:16 PM
jpenn's Avatar
jpenn jpenn is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jun 2002
Location: Washington, DC
Posts: 2,693 jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 h 41 m 10 sec
Reputation Power: 16
%&#$*# - WTH - man, I can not understand these people. How can you have people working on bugs that can't even understand a simple dam post.

Man - I am fustrated about this. This thing is still going on and I am still trying to explain to this guy what the problem is. I feel like I am trying to explain the difference between single quotes and double quotes to a newbie.

Look at the bug in full and give me your take on it: http://bugs.php.net/bug.php?id=24252


Reply With Quote
  #10  
Old July 8th, 2003, 12:29 AM
SammyK's Avatar
SammyK SammyK is offline
Happy Monkey
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Nov 2001
Location: UK (University of Kentucky)
Posts: 1,810 SammyK User rank is Sergeant Major (2000 - 5000 Reputation Level)SammyK User rank is Sergeant Major (2000 - 5000 Reputation Level)SammyK User rank is Sergeant Major (2000 - 5000 Reputation Level)SammyK User rank is Sergeant Major (2000 - 5000 Reputation Level)SammyK User rank is Sergeant Major (2000 - 5000 Reputation Level)SammyK User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 22 h 49 m 14 sec
Reputation Power: 41
I don't know what session_set_save_handler() means, but let me see if I understand:

If you connect to the DB out side of the class that session_set_save_handler() is in, then session_set_save_handler() no workie. HOWEVER, if you connect to the DB inside of the class that session_set_save_handler() is in, it workie.

Is that right?
__________________

Reply With Quote
  #11  
Old July 8th, 2003, 07:20 AM
jpenn's Avatar
jpenn jpenn is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jun 2002
Location: Washington, DC
Posts: 2,693 jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 h 41 m 10 sec
Reputation Power: 16
You got farther than he did by reading the bug for the first time. Yes, that is pretty much correct. session_set_save_handler() takes 6 arguments - they are all function names or method names. open,close,read,write,destroy,gc - if you do not connect to the db within the open method, it will fail.

I still can not understand what is so hard to understand about the bug post.

Reply With Quote
  #12  
Old July 8th, 2003, 08:00 AM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,840 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Days 36 m 16 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
Just face it, those two are complete morons.
The post is simple and to the point. You couldn't do much more explaining than what you already have with it.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherDev Shed Lounge > Ok - I think this is a little rediculous (for all you php folks)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump