Wednesday, September 28, 2011

Re: patch to helper.phpfor __selectArray()

This is not a core development list. You should fork the code on Github make changes you think are needed with test proving the problem and then submit pull request there. Also checking the core unit tests will tell you if this was the intended purpose of the code.

Attaching a patch to the ticket you are opening is also an option.

http://github.com/cakephp/cakephp

--
Larry E. Masters


On Wed, Sep 28, 2011 at 4:33 PM, lsiden <lsiden@gmail.com> wrote:
I think I may have found a bug in core.  It's in cake/libs/view/
helper.php in the function __selectArray().  Here is my patch:

diff --git a/cake/libs/view/helper.php b/cake/libs/view/helper.php
index b8bc471..6d00740 100644
--- a/cake/libs/view/helper.php
+++ b/cake/libs/view/helper.php
@@ -859,7 +859,7 @@ class Helper extends Overloadable {
               }
               $array = array();
               if (!empty($data)) {
-                       foreach ($data as $var) {
+                       foreach (array_keys($data) as $var) {
                               $array[$var[$key]] = $var[$key];
                       }
               }

$data = array(
 'id' => '123',
 'name' => 'foobar',
 'description' => '',
);
Then the foreach loop assigns "123", "foobar" and "" to $var instead
of "id", "name" and "description".  This cannot possibly be what was
intended.

I am a bit puzzled by how I (or anyone else) did not notice this
sooner.  My "excuse" is that on my site it only became apparent on a
page that I do not visit often and that I previously thought was
working properly.

I am also surprised to see that this is not fixed in the latest
release 1.3.12.  Surely someone else has stubbed his toe on this!

I will cross post this to http://cakephp.lighthouseapp.com with a new
ticket.

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: