#6232: Set::extract() returns empty result when array is non-zero indexed ----------------------------+----------------------------------------------- Reporter: speedmax | Type: Bug Status: new | Priority: High Milestone: 1.2.x.x | Component: Core Libs Version: 1.2 Final | Severity: Normal Keywords: set extract | Php_version: n/a Cake_version: 8120 | ----------------------------+----------------------------------------------- Set::extract failed to extract list of members using their key,
'''here is the patch.''' {{{ ### Eclipse Workspace Patch 1.0 #P cakephp Index: cake/tests/cases/libs/set.test.php =================================================================== --- cake/tests/cases/libs/set.test.php (revision 8128) +++ cake/tests/cases/libs/set.test.php (working copy) @@ -969,7 +969,50 @@ $expected = array(array('name' => 'zipfile.zip','type' => 'application/zip','tmp_name' => '/tmp/php178.tmp','error' => 0,'size' => '564647')); $r = Set::extract('/file/.[type=application/zip]', $f); $this->assertEqual($r, $expected); - + + $f = array( + 1 => array( + 'file' => array( + 'name' => 'zipfile.zip', + ) + ), + 2 => array( + 'file' => array( + 'name' => 'zipfile2.zip', + ) + ), + 3 => array( + 'file' => array( + 'name' => 'picture.jpg', + ) + ) + ); + + $expected = array('zipfile.zip', 'zipfile2.zip', 'picture.jpg'); + $this->assertEqual(Set::extract('/file/name', $f), $expected); + + $f = array( + array( + 'file' => array( + 'name' => 'zipfile.zip', + ) + ), + array( + 'file' => array( + 'name' => 'zipfile2.zip', + ) + ), + array( + 'file' => array( + 'name' => 'picture.jpg', + ) + ) + ); + + unset($f[0]); + $expected = array('zipfile2.zip', 'picture.jpg'); + $this->assertEqual(Set::extract('/file/name', $f), $expected); + } /** * testMatches method }}} -- Ticket URL: <https://trac.cakephp.org/ticket/6232> CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/> Cake is a rapid development framework for PHP which uses commonly known design patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC. Our primary goal is to provide a structured framework that enables PHP users at all levels to rapidly develop robust web applications, without any loss to flexibility. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "tickets cakephp" group. To post to this group, send email to tickets-cakephp@googlegroups.com To unsubscribe from this group, send email to tickets-cakephp+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/tickets-cakephp?hl=en -~----------~----~----~----~------~----~------~--~---