Bug #17343: Resource encapsulation can break some functions
| From: | chris at thumbtack dot org | Date: | Tue, 21 May 2002 21:54:26 +0000 |
| Subject: | Bug #17343: Resource encapsulation can break some functions | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-8127@lists.php.net to get a copy of this message | ||
From: chris@thumbtack.org
Operating system: Linux
PHP version: 4.2.1
PHP Bug Type: Unknown/Other Function
Bug description: Resource encapsulation can break some functions
When using mysql_insert_id() if you've made a call using a wrapped function
(ie, my_database_query($query) wrapping mysql_query()) the database
resource may not be "set" to allow using the last connection.
Ex.
1) Call my_database_connect() and store the returned mysql Link as $res.
Note that it's a copy...
2) call my_database_query($query, $res) and insert something with an
auto_increment field.
3) call mysql_insert_id() and it'll fail.
4) call mysql_insert_id($res) and it'll work.
It appears that mysql_insert_id() looks for the last used connection, but
if that connection resource is "wrapped/copied" then the
ZEND_GET_RESOURCE-type method can't find it.
Storing a REFERENCE to the mysql link in (1) will allow proper usage, but
storing a copy does not.
This was exposed using mysql, but it may have deeper meaning to other
modules - hence the "Unknown/Other Function" category
chris@thumbtack.org
--
Edit bug report at http://bugs.php.net/?id=17343&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=17343&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=17343&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=17343&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=17343&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=17343&r=support
Expected behavior: http://bugs.php.net/fix.php?id=17343&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=17343&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=17343&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=17343&r=globals