]> granicus.if.org Git - php/commitdiff
Fixed bug #37812 aggregate_methods_by_list fails to take certain methods
authorHannes Magnusson <bjori@php.net>
Sat, 26 Aug 2006 14:15:07 +0000 (14:15 +0000)
committerHannes Magnusson <bjori@php.net>
Sat, 26 Aug 2006 14:15:07 +0000 (14:15 +0000)
Add test

NEWS
ext/standard/aggregation.c
ext/standard/tests/aggregation/bug37812.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index dfe1027bdfd843d25ce3cea676ac4f9c481f238e..1f495f843a84830fd6b4f62ee90928d09fedfa25 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -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.)
index af7b42363924022960907b428acd78be9bd9c762..99aae10485e434fd89f8b06bc3cba430f8cff16b 100644 (file)
@@ -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));
diff --git a/ext/standard/tests/aggregation/bug37812.phpt b/ext/standard/tests/aggregation/bug37812.phpt
new file mode 100644 (file)
index 0000000..baa151c
--- /dev/null
@@ -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>
+