php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32350 call_user_func_array() with parent causing loop and calls incorrect method
Submitted: 2005-03-17 12:56 UTC Modified: 2005-03-18 19:18 UTC
From: wb at pro-net dot co dot uk Assigned:
Status: Closed Package: *General Issues
PHP Version: 5.0.3 OS: FreeBSD 5.2.1
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: wb at pro-net dot co dot uk
New email:
PHP Version: OS:

 

 [2005-03-17 12:56 UTC] wb at pro-net dot co dot uk
Description:
------------
When trying to use call_user_func_array() to call a parent method php calls the current class method and therefore goes into a loop.

Reproduce code:
---------------
<?php
class a {
    public function xyz () {
        $args = func_get_args();
        print("\n\na:\n");
        var_export($args);
    }
}
class b extends a {
    public function xyz () {
        $args = func_get_args();
        print("\n\nb:\n");
        var_export($args);
        call_user_func_array(array('parent', 'xyz'), $args);   
    }   
}
$b = new b();
$b->xyz('zero', 'one', 'two', 'three', 'four');
?>

Expected result:
----------------
b:
array (
  0 => 'zero',
  1 => 'one',
  2 => 'two',
  3 => 'three',
  4 => 'four',
)

a:
array (
  0 => 'zero',
  1 => 'one',
  2 => 'two',
  3 => 'three',
  4 => 'four',
)

Actual result:
--------------
b:
array (
  0 => 'zero',
  1 => 'one',
  2 => 'two',
  3 => 'three',
  4 => 'four',
)

b:
array (
  0 => 'zero',
  1 => 'one',
  2 => 'two',
  3 => 'three',
  4 => 'four',
)

b:
array (
  0 => 'zero',
  1 => 'one',
  2 => 'two',
  3 => 'three',
  4 => 'four',
)

... [Inf loop]

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-18 19:18 UTC] sniper@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Sep 11 20:01:27 2024 UTC