Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 8118c7e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Collection/CollectionTrait.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}

/**
Expand Down

0 comments on commit 8118c7e

Please sign in to comment.