From 2548c1c46765057a3e5d2d94559a6cd70da6b143 Mon Sep 17 00:00:00 2001 From: Dyorg Almeida Date: Wed, 20 Feb 2019 17:06:44 -0300 Subject: [PATCH 1/5] Fix for count() error on Model:find_by_pk in php 7.2 --- .gitignore | 1 + .travis.yml | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ddd550415..8a16021d4 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ vendor/* composer.lock phpunit.xml +.idea \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index ab112fc18..094bbb2ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,15 +7,17 @@ env: PHPAR_MYSQL=mysql://root@127.0.0.1/phpar_test PHPAR_PGSQL=pgsql://postgres@ language: php php: - - 5.3 - 5.4 - 5.5 - 7.0 - 7.1 + - 7.2 - nightly matrix: include: + - php: 5.3 + dist: precise - php: hhvm dist: trusty allow_failures: From fda5090177a08d87941df6a9e18f2ef37b55031b Mon Sep 17 00:00:00 2001 From: Dyorg Almeida Date: Wed, 20 Feb 2019 17:09:07 -0300 Subject: [PATCH 2/5] Fix for count() error on Model:find_by_pk in php 7.2 --- .travis.yml | 4 +--- lib/Model.php | 6 ++++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 094bbb2ea..ab112fc18 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,17 +7,15 @@ env: PHPAR_MYSQL=mysql://root@127.0.0.1/phpar_test PHPAR_PGSQL=pgsql://postgres@ language: php php: + - 5.3 - 5.4 - 5.5 - 7.0 - 7.1 - - 7.2 - nightly matrix: include: - - php: 5.3 - dist: precise - php: hhvm dist: trusty allow_failures: diff --git a/lib/Model.php b/lib/Model.php index 99667b41f..b16b14960 100644 --- a/lib/Model.php +++ b/lib/Model.php @@ -1667,11 +1667,13 @@ public static function find_by_pk($values, $options) } $results = count($list); + if (!is_array($values)) + $values = array($values); + if ($results != ($expected = count($values))) { $class = get_called_class(); - if (is_array($values)) - $values = join(',',$values); + $values = join(',',$values); if ($expected == 1) { From a838d3a289c828b901a2c8ef7a39caa95c899db9 Mon Sep 17 00:00:00 2001 From: Dyorg Almeida Date: Wed, 20 Feb 2019 17:10:25 -0300 Subject: [PATCH 3/5] Change travis test in php 5.3 to precise --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ab112fc18..8dff237d0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,6 @@ env: PHPAR_MYSQL=mysql://root@127.0.0.1/phpar_test PHPAR_PGSQL=pgsql://postgres@ language: php php: - - 5.3 - 5.4 - 5.5 - 7.0 @@ -16,6 +15,8 @@ php: matrix: include: + - php: 5.3 + dist: precise - php: hhvm dist: trusty allow_failures: From cba2dac1422caae7b06f45422dcd96acf97bfe19 Mon Sep 17 00:00:00 2001 From: Dyorg Almeida Date: Wed, 20 Feb 2019 17:11:09 -0300 Subject: [PATCH 4/5] Added travis test to php 7.2 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 8dff237d0..094bbb2ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,7 @@ php: - 5.5 - 7.0 - 7.1 + - 7.2 - nightly matrix: From df1206da4c144b7d352dcb6a2a2b1dc1c19a6b44 Mon Sep 17 00:00:00 2001 From: Dyorg Almeida Date: Wed, 20 Feb 2019 17:32:25 -0300 Subject: [PATCH 5/5] Fix for count() error on PHPUnit tests in php 7.2 --- lib/SQLBuilder.php | 2 +- test/ModelCallbackTest.php | 3 +++ test/helpers/AdapterTest.php | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/SQLBuilder.php b/lib/SQLBuilder.php index ef239ed87..aa85ef66e 100644 --- a/lib/SQLBuilder.php +++ b/lib/SQLBuilder.php @@ -217,7 +217,7 @@ public static function create_conditions_from_underscored_string(Connection $con return null; $parts = preg_split('/(_and_|_or_)/i',$name,-1,PREG_SPLIT_DELIM_CAPTURE); - $num_values = count($values); + $num_values = is_null($values) ? 0 : count($values); $conditions = array(''); for ($i=0,$j=0,$n=count($parts); $i<$n; $i+=2,++$j) diff --git a/test/ModelCallbackTest.php b/test/ModelCallbackTest.php index 949706385..0e2c0adf8 100644 --- a/test/ModelCallbackTest.php +++ b/test/ModelCallbackTest.php @@ -26,6 +26,9 @@ public function register_and_invoke_callbacks($callbacks, $return, $closure) public function assert_fires($callbacks, $closure) { + if (!is_array($callbacks)) + $callbacks = array($callbacks); + $executed = $this->register_and_invoke_callbacks($callbacks,true,$closure); $this->assert_equals(count($callbacks),count($executed)); } diff --git a/test/helpers/AdapterTest.php b/test/helpers/AdapterTest.php index 97685f6bc..50f5d3f51 100644 --- a/test/helpers/AdapterTest.php +++ b/test/helpers/AdapterTest.php @@ -339,12 +339,12 @@ public function test_tables() public function test_query_column_info() { - $this->assert_greater_than(0,count($this->conn->query_column_info("authors"))); + $this->assert_greater_than(0,count((array) $this->conn->query_column_info("authors"))); } public function test_query_table_info() { - $this->assert_greater_than(0,count($this->conn->query_for_tables())); + $this->assert_greater_than(0,count((array) $this->conn->query_for_tables())); } public function test_query_table_info_must_return_one_field()