[prev in list] [next in list] [prev in thread] [next in thread] 

List:       twig-devel
Subject:    Re: [twig-devel] Re: [twig] userperms + postgres bug in 2.7.4 (fix included)
From:       "Craig Foster" <craig () wiw ! org>
Date:       2001-09-03 15:08:45
[Download RAW message or body]

I say commit it, send the fixed postgres library files (don't forget to fix 
both of them) to Lee Revell <rlrevell@dca.net>, asking for feedback, and 
release 2.7.5.  If it's broken, well, it was broken before anyway, and there 
is always 2.7.6.  Let's keep these bugfixes rolling out the door until 2.7.x 
is stable enough to move on to bigger and better things.

Okay...I'm back to my vacation now! ;-)

-- 
Craig Foster
craig@wiw.org


Aaron Stone <aaron@engr.Paly.NET> said:

> I've confirmed that this is the correct thing to do, but I don't have 
Postgres 
> to test with, and it would be good to fit this in for the 2.7.5 release. 
Can 
> someone step in and check the proper coding ASAP?
> 
> Aaron
> 
> Aaron Stone <aaron@engr.Paly.NET> said:
> 
> > This thread is being moved to the development list because we're talking 
> code
> > now.
> > --
> > 
> > So the problem is twofold:
> > 
> > 1) we're asking Postgres for the wrong data 
> > 2) even if it gave us what we thought we were asking for, its the wrong 
data
> > anyhow (id vs groupid)
> > 
> > With respect to 2), it looks like the right thing is happening. We're 
asking
> > for the id from groups_table and using it as the groupid in members_table.
> > 
> > With respect to 1), and some reading on that page you linked, I'm thinking
> > that the dbLastInserID function for Postgres can be modified like this:
> > 
> > $lastoid = get_last_oid( $result );
> > SELECT id FROM $table WHERE oid = $lastoid;
> > 
> > Does that sounds reasonable?
> > 
> > Aaron
> > 
> > 
> > Lee Revell <rlrevell@dca.net> said:
> > 
> > > The Postgres OID is a unique identifier used internally by Postgres.  
See
> > > http://www.php.net/manual/en/function.pg-getlastoid.php.  TWIG doesn't 
use
> > these
> > > as primary keys; it has a sequence for each table and uses nextval to 
> create
> > its
> > > own unique identifier when doing an INSERT.  The TWIGGroupsCreateMember
> > function
> > > confuses the id field of the row that was just inserted (obtained from
> > nextval
> > > ('groupid')) with the Postgres OID (assigned by Postgres).  
dbLastInsertID
> > > *does* return the OID of the row just inserted - the problem is that
> > > TWIGGroupsCreateMember expects the TWIG groupid, which is different.
> > > 
> > > On Fri, 31 Aug 2001, Aaron Stone wrote:
> > > 
> > > > If the Postgres OID is not the id of the row, then what the heck is 
it,
> > and
> > > > why is there a function to retrieve it !?
> > > >
> > > > dbLastInsertID is supposed to get the id of the row last inserted, and
> > works
> > > > for MySQL, and should work for Sybase and Oracle (IIRC). I thought it
> > worked
> > > > right for Postgres, but you're saying that the OID is not what I want,
> > huh...
> > > >
> > > > I appreciate the fix, but a function for getting the last inserted ID 
in 
> a
> > > > general mechanism is very imporant, and since this function is also 
used
> > in
> > > > Meetings and for Recurring Schedules, I would rather see a fix for the
> > > > dbLastInsertID function.
> > > >
> > > > BTW, the two arguments are there for various database functionality; 
> mysql
> > > > doesn't need either argument, postgres needs the result, oracle and 
> sybase
> > > > need the table name.
> > > >
> > > > Aaron
> > > >
> > > >
> > > > Lee Revell <rlrevell@dca.net> said:
> > > >
> > > > > Hey,
> > > > >
> > > > > I'm really surprised that no one has noticed this, but there's a 
bug 
> in
> > TWIG
> > > > > that renders userperms groups essentially useless with Postgres.  In
> > > > > lib/groups/userperms/userperms.inc.php3, the last line in
> > > > TWIGGroupsCreateGroup
> > > > > is as such:
> > > > >
> > > > > TWIGGroupsCreateMember( dbLastInsertID( $result,
> > $dbconfig["groups_table"]
> > > > ), $admin, $fullperms );,
> > > > >
> > > > > dbLastInsertID returns the postgres OID of the tuple that was just
> > inserted
> > > > (no
> > > > > idea why the table is passed as an argument, as it isn't used), 
while 
> we
> > > > > actually want the value of the id field for that row, which was 
> obtained
> > > > from
> > > > > the sequence groupid.  The upshot of all this is that it's now
> > impossible to
> > > > > associate members with groups, so the just-created group doesn't 
show 
> up
> > in
> > > > the
> > > > > listing.
> > > > >
> > > > > Here's what we really want:
> > > > >
> > > > > TWIGGroupsCreateMember( dbResult( dbQuery ( "SELECT id FROM " .
> > > > > $dbconfig["groups_table"] . " WHERE groupname='$groupname'"), 0, 
id),
> > > > $admin,
> > > > > $fullperms );
> > > > >
> > > > > There's probably a better way to fix this, but the above works.
> > > > >
> > > > > Lee Revell <rlrevell@dca.net>
> > > > > Internetworking Engineer
> > > > > DCANet / Consult Dynamics, Inc.
> > > > > 215.440.1500 x163
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > >
> > > >
> > > >
> > > 
> > > Lee Revell <rlrevell@dca.net>
> > > Internetworking Engineer
> > > DCANet / Consult Dynamics, Inc.
> > > 215.440.1500 x163
> > > 
> > 
> > 
> > 
> > -- 
> > 
> > 
> > 
> 
> 
> 
> -- 
> 
> 
> 

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic