Skip to content

Commit

Permalink
Fixed bug #37812 aggregate_methods_by_list fails to take certain methods
Browse files Browse the repository at this point in the history
Add test
  • Loading branch information
bjori committed Aug 26, 2006
1 parent 22caa93 commit d74d887
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ PHP 4 NEWS
stream wrappers). (Tony)
- Fixed bug #38378 (wddx_serialize_value() generates no wellformed xml).
(sj at sjaensch dot org, grzegorz dot nosek at netart dot pl, Tony).
- Fixed bug #37812 (aggregate_methods_by_list fails to take certain methods).
(Hannes)

17 Aug 2006, Version 4.4.4
- Fixed memory_limit on 64bit systems. (Stefan E.)
Expand Down
2 changes: 1 addition & 1 deletion ext/standard/aggregation.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ static void aggregate_methods(zend_class_entry *ce, zend_class_entry *from_ce, i
*/
zend_hash_internal_pointer_reset(Z_ARRVAL_P(list_hash));
while (zend_hash_get_current_key_ex(Z_ARRVAL_P(list_hash), &func_name, &func_name_len, &num_key, 0, NULL) == HASH_KEY_IS_STRING) {
if (!strncmp(func_name, from_ce->name, MIN(func_name_len-1, from_ce->name_length)) ||
if (!strncmp(func_name, from_ce->name, MAX(func_name_len-1, from_ce->name_length)) ||
func_name[0] == '_' ||
zend_hash_find(&from_ce->function_table, func_name, func_name_len, (void**)&function) == FAILURE) {
zend_hash_move_forward(Z_ARRVAL_P(list_hash));
Expand Down
55 changes: 55 additions & 0 deletions ext/standard/tests/aggregation/bug37812.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
--TEST--
Bug #37812 (aggregate_methods_by_list fails to take certain methods)
--FILE--
<?php
class Absorber
{
/**
* Assigns object's properties from supplied array
* @param array associative
*/

function absorb($data)
{
$props = get_object_vars($this);

foreach (array_keys($props) as $prop)
{
if (isset($data[$prop]))
{
$this->$prop = $data[$prop];
}
}
}
}

class User
{
function User($id = NULL)
{
// doesn't work
aggregate_methods_by_list($this, 'Absorber', array('absorb'));
echo '<pre>Aggregation:'.print_r(aggregation_info($this),1).'</pre>';
}
}
new User;
?>
--EXPECT--
<pre>Aggregation:Array
(
[absorber] => Array
(
[methods] => Array
(
[0] => absorb
)

[properties] => Array
(
)

)

)
</pre>

0 comments on commit d74d887

Please sign in to comment.