php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #11924 problem with ibase_execute called through call_user_func_array()
Submitted: 2001-07-06 06:03 UTC Modified: 2003-07-09 19:17 UTC
From: flying at dom dot natm dot ru Assigned:
Status: Closed Package: InterBase related
PHP Version: 4.3.0-dev OS: Windows 2000
Private report: No CVE-ID: None
 [2001-07-06 06:03 UTC] flying at dom dot natm dot ru
It seems to be a problem when ibase_execute called indirectly, through call_user_func_array().

Look at the following piece of code:

$args = array('some text','amother text');
$query = ibase_prepare($conn,"insert into MY_TABLE (INT_FIELD, STR_FIELD) values (?,?)");
array_unshift($args,$query);
print_r($args);
$rs = call_user_func_array('ibase_execute',$args);
print_r($args);
ibase_free_query($query);

MY_TABLE table contains two columns:
INT_FIELD INTEGER,
STR_FIELD VARCHAR(50)

 Imagine, that we're make an error, and pass string values for both fields. 
No error will be given, but at second print_r() first item inro $args array 
will be equal to 0 instead of 'some text'.

 As I can understand, all query parameters are replaced by values, actually 
stored into database (like they are passed by reference, 
but allow_call_time_pass_reference options is turned off). 
 If it is not a bug, but a "feature", it must be documented, to avoid future misunderstandings.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-25 09:21 UTC] derick@php.net
Who would you want to do something like this?
 [2002-05-25 09:27 UTC] flying at dom dot natm dot ru
Sorry, but i don't understand your question...
 [2002-05-25 09:41 UTC] derick@php.net
ok, nm :)

I'd like to know the output of:

var_dump (get_func_args()) in ibase_execute... this is your own function, isn't it?

Derick
 [2002-05-25 09:54 UTC] flying at dom dot natm dot ru
> I'd like to know the output of:
> var_dump (get_func_args()) in ibase_execute... this is your > own function, isn't it?

 No, it is InterBase module function :)
http://www.php.net/manual/en/function.ibase-execute.php

 This bug is still present in 4.2.1, that code example returns me:

Array
(
    [0] => Resource id #2
    [1] => some text
    [2] => amother text
)
Array
(
    [0] => Resource id #2
    [1] => 0
    [2] => amother text
)

As you can see - contents of array with index 1 is changes, while they should not.
 [2002-05-26 04:35 UTC] derick@php.net
Which code example exactly? Can you show me the full script (As short as possible).

Derick
 [2002-05-26 04:51 UTC] flying at dom dot natm dot ru
Here is full information, test database creation script included:

test.sql
========
SET SQL DIALECT 3;

SET NAMES NONE;

CREATE DATABASE 'C:\TEST.GDB'
USER 'SYSDBA' PASSWORD 'masterkey'
PAGE_SIZE 4096
DEFAULT CHARACTER SET NONE;

CREATE GENERATOR GEN_MY_TABLE_ID;

CREATE TABLE MY_TABLE (
    ID INTEGER NOT NULL,
    STR_FIELD VARCHAR(50),
    INT_FIELD INTEGER);

ALTER TABLE MY_TABLE ADD CONSTRAINT PK__MY_TABLE PRIMARY KEY (ID);

SET TERM ^ ;

CREATE TRIGGER MY_TABLE_BI FOR MY_TABLE
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
  IF (NEW.ID IS NULL) THEN
    NEW.ID = GEN_ID(GEN_MY_TABLE_ID,1);
END
^

SET TERM ; ^

test.php
========
<?php
ibase_connect('localhost:c:\test.gdb','SYSDBA','masterkey');
$args = array('some text','another text');
$query = ibase_prepare('insert into MY_TABLE (INT_FIELD, STR_FIELD) values (?,?)');
array_unshift($args,$query);
print_r($args);
$rs = call_user_func_array('ibase_execute',$args);
print_r($args);
ibase_free_query($query);
ibase_close();
?>

Expected results:
=================
Array
(
    [0] => Resource id #2
    [1] => some text
    [2] => another text
)
Array
(
    [0] => Resource id #2
    [1] => some text
    [2] => another text
)

Actual results:
===============
Array
(
    [0] => Resource id #2
    [1] => some text
    [2] => another text
)
Array
(
    [0] => Resource id #2
    [1] => 0
    [2] => another text
)

---------------------------------------
As you can see - after calling call_user_func_array() data into $args[1] has been changed, while it should stay the same.
 [2002-06-27 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2002-06-27 03:40 UTC] flying at dom dot natm dot ru
I looks like i forget to set 'Open' status for this bug month ago... :)
 [2002-06-27 21:06 UTC] sniper@php.net
Please try this snapshot:

http://snaps.php.net/win32/php4-win32-latest.zip

There have been some fixes lately, maybe this was fixed too?
(I don't have interbase installed, can't test it.)

 [2002-06-28 06:28 UTC] flying at dom dot natm dot ru
No, it isn't fixed in latest snapshot build. Testcase give me same results as before.
 [2002-06-28 06:30 UTC] sniper@php.net
version update
 [2003-05-05 16:28 UTC] moriyoshi@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip

Give it another try.

 [2003-05-07 04:45 UTC] flying at dom dot natm dot ru
Checked again with php4-win32-STABLE-200305060030.zip
Testcase, i've post easlier gives me same result as before.
 [2003-07-09 19:17 UTC] sniper@php.net
This is now fixed in CVS.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 03:01:28 2024 UTC