From a6589c64c33a9a4f16cac52c3f1ada710e1e6448 Mon Sep 17 00:00:00 2001 From: Francois Zaninotto Date: Fri, 27 Apr 2012 23:53:52 +0200 Subject: [PATCH] Fix sortable entity populator modifier --- src/Faker/ORM/Propel/EntityPopulator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Faker/ORM/Propel/EntityPopulator.php b/src/Faker/ORM/Propel/EntityPopulator.php index 65b68092..8fe7f425 100644 --- a/src/Faker/ORM/Propel/EntityPopulator.php +++ b/src/Faker/ORM/Propel/EntityPopulator.php @@ -132,8 +132,8 @@ class EntityPopulator break; case 'sortable': $modifiers['sortable'] = function($obj, $inserted) use ($class, $generator) { - $nbInserted = count($inserted[$class]); - $obj->insertAtRank(mt_rand(1, $nbInserted ? $nbInserted : 1)); + $maxRank = isset($inserted[$class]) ? count($inserted[$class]) : 0; + $obj->insertAtRank(mt_rand(1, $maxRank + 1)); }; break; }