Antw: Re: [phplib] Sessions error - urgent help required please! From: Wilfried Wolf (Wilfried.Wolf <email protected>)
Date: 09/13/00

hi there,

> Yes - It's a very funny bug. If nothing changes in your session variables
> record in active_sessions the number of affected rows will equal zero. So
> ct_sql will insert a new row, causing the problem, because the row IS there
> already.
>
> Upgrade to phplib 7.2c and the problem is over.
>
> Brian

at least in my case (suse-linux 6.4, apache-1.3.12, php-3.0.16, mysql-23.23) that bugfix did not work.
i fixed it (but i don't know, my programming skills, and i do not know much about other sql databases...)

in ct_sql.ct

function ac_store

# in phplib-7.2c
#
$squery = sprintf("select count(*) as 'count' from %s where val='%s' and changed='%s' and sid='%s' and name='%s'",
<...>

# changed to:

$squery = sprintf("select count(*) as 'count' from %s where val='%s' and changed='%s' and sid='%s' and name='%s'",

and later on

# in phplib-7.2c
#

if ( $this->db->affected_rows() == 0
    && $this->db->query($squery)
    && $this->db->f(1) == 0
    && !$this->db->query($iquery)) {

# changed to:

if ( $this->db->affected_rows() == 0
    && $this->db->query($squery)
    && $this->db->next_record()
    && $this->db->f('count') == 0
    && !$this->db->query($iquery)) {

i noticed that problem earliert to, and programed a small workaround in phplib-7.2
allready, but unfortunately i didn't have time to post it to the list and then i forgot.
also i'not shure, whether this workaround could have strange side affects, because i'm not too deep in
sessions

i just changed (from phplib 7.2)

$iquery = sprintf("insert into %s ( sid, name, val, changed ) values ('%s', '%s', '%s', '%s')",

to

$iquery = sprintf("replace into %s ( sid, name, val, changed ) values ('%s','%s', '%s', '%s')",
 
which perfectly does the job, allthough there will be additional , maybe avoidable insert operations

your opinion?

best regards

willi

----------------------------------------------------
wilfried.wolf <email protected> tel.: +49-351 440 78 32

---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-unsubscribe <email protected>
For additional commands, e-mail: phplib-help <email protected>