Skip to content
Permalink
Browse files

Reverting changes done to Collection::compile() as it breaks other code

The main reaosn compile exsted was to detach the iterator pointers from one
collection to the other. The solution using another iterator still keeps those
pointers, causing old bugs to re-appear
  • Loading branch information...
lorenzo committed Sep 22, 2014
1 parent 77438ef commit 8118c7ef929ff5348cbce138221f6ece1ecd7e83
Showing with 6 additions and 3 deletions.
  1. +6 −3 src/Collection/CollectionTrait.php
@@ -17,7 +17,6 @@
use AppendIterator;
use ArrayObject;
use Cake\Collection\Collection;
use Cake\Collection\Iterator\BufferedIterator;
use Cake\Collection\Iterator\ExtractIterator;
use Cake\Collection\Iterator\FilterIterator;
use Cake\Collection\Iterator\InsertIterator;
@@ -880,10 +879,14 @@ public function jsonSerialize() {
* You can think of this method as a way to create save points for complex
* calculations in a collection.
*
* @param bool $preserveKeys whether to use the keys returned by this
* collection as the array keys. Keep in mind that it is valid for iterators
* to return the same key for different elements, setting this value to false
* can help getting all items if keys are not important in the result.
* @return \Cake\Collection\Collection
*/
public function compile() {
return new BufferedIterator($this);
public function compile($preserveKeys = true) {
return new Collection($this->toArray($preserveKeys));
}
/**

0 comments on commit 8118c7e

Please sign in to comment.
You can’t perform that action at this time.