php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17343 Resource encapsulation can break some functions
Submitted: 2002-05-21 17:54 UTC Modified: 2002-06-17 16:24 UTC
From: chris at thumbtack dot org Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 4.2.1 OS: Linux
Private report: No CVE-ID: None
 [2002-05-21 17:54 UTC] chris at thumbtack dot org
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



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-21 17:56 UTC] szii at sziisoft dot com
This used to work (calling against a copy of the link) in PHP 4.0pl1.

-Szii
 [2002-06-17 15:10 UTC] hholzgra@php.net
resources are just numbers used to lookup
the actual resource data internaly, so
passing by value or reference should make no differecne ...
 [2002-06-17 16:24 UTC] sniper@php.net
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PHP.



 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 07 09:01:31 2024 UTC