Skip to content

Commit a1fdd82

Browse files
committed
Fix count php 7.2 jpfuentes2#602
1 parent 4b07198 commit a1fdd82

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

lib/Model.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1673,8 +1673,8 @@ public static function find_by_pk($values, $options)
16731673
if ($results != ($expected = count($values)))
16741674
{
16751675
$class = get_called_class();
1676-
if (is_array($values))
1677-
$values = join(',',$values);
1676+
1677+
$values = join(',',$values);
16781678

16791679
if ($expected == 1)
16801680
{

lib/SQLBuilder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public static function create_conditions_from_underscored_string(Connection $con
217217
return null;
218218

219219
$parts = preg_split('/(_and_|_or_)/i',$name,-1,PREG_SPLIT_DELIM_CAPTURE);
220-
$num_values = count($values);
220+
$num_values = is_null($values) ? 0 : count($values);
221221
$conditions = array('');
222222

223223
for ($i=0,$j=0,$n=count($parts); $i<$n; $i+=2,++$j)

test/ModelCallbackTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ public function register_and_invoke_callbacks($callbacks, $return, $closure)
2626

2727
public function assert_fires($callbacks, $closure)
2828
{
29+
if (!is_array($callbacks))
30+
$callbacks = array($callbacks);
2931
$executed = $this->register_and_invoke_callbacks($callbacks,true,$closure);
3032
$this->assert_equals(count($callbacks),count($executed));
3133
}

test/helpers/AdapterTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -339,12 +339,12 @@ public function test_tables()
339339

340340
public function test_query_column_info()
341341
{
342-
$this->assert_greater_than(0,count($this->conn->query_column_info("authors")));
342+
$this->assert_greater_than(0,count((array) $this->conn->query_column_info("authors")));
343343
}
344344

345345
public function test_query_table_info()
346346
{
347-
$this->assert_greater_than(0,count($this->conn->query_for_tables()));
347+
$$this->assert_greater_than(0,count((array) $this->conn->query_for_tables()));
348348
}
349349

350350
public function test_query_table_info_must_return_one_field()

0 commit comments

Comments
 (0)