From d2b766f9f45c5353436893ab4761f984a73e77a6 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Mon, 16 Jan 2017 10:15:57 +0100
Subject: [PATCH] Fix PHP 7.1

---
 .travis.yml                          | 2 +-
 ChangeLog                            | 3 ++-
 htdocs/user/card.php                 | 6 +++---
 htdocs/user/class/user.class.php     | 2 +-
 test/phpunit/WebservicesUserTest.php | 8 ++++----
 5 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index a9e47ccb9c6..4f32a1dea43 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -12,7 +12,7 @@ php:
 - '5.5'
 - '5.6'
 - '7.0'
-#- '7.1'
+- '7.1'
 - nightly
 
 addons:
diff --git a/ChangeLog b/ChangeLog
index 33390ca90c0..87e7f4ba18b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -151,7 +151,8 @@ Dolibarr better:
   no more required, were also removed. Use this new one if you were using one of them.
 - The trigger that activate or close a contract line is run on a contract line, not on contract.
 
-Dolibarr 5.0 was frozen before PHP 7.1 was released. It is compatible with PHP 5.3 to 7.0 but not with PHP 7.1 (Dolibarr 6.0 will be).
+Dolibarr 5.0 was frozen before PHP 7.1 was released. Unit tests are successful on PHP 7.1 but we don't have enough
+feedback to confirm all application is compatible. Current officiel supported PHP versions are PHP 5.3 to 7.0.
 
 
 ***** ChangeLog for 4.0.3 to 4.0.2 *****
diff --git a/htdocs/user/card.php b/htdocs/user/card.php
index 8b5ab723bd3..e7614f06f9d 100644
--- a/htdocs/user/card.php
+++ b/htdocs/user/card.php
@@ -1090,9 +1090,9 @@ if (($action == 'create') || ($action == 'adduserldap'))
 	// Categories
 	if (! empty($conf->categorie->enabled)  && ! empty($user->rights->categorie->lire)) 
 	{
-		print '<tr><td>' . fieldLabel( 'Categories', 'usercats' ) . '</td><td colspan="3">';
-		$cate_arbo = $form->select_all_categories( Categorie::TYPE_USER, null, 'parent', null, null, 1 );
-		print $form->multiselectarray( 'usercats', $cate_arbo, GETPOST( 'usercats', 'array' ), null, null, null,
+		print '<tr><td>' . fieldLabel('Categories', 'usercats') . '</td><td colspan="3">';
+		$cate_arbo = $form->select_all_categories('user', null, 'parent', null, null, 1);
+		print $form->multiselectarray('usercats', $cate_arbo, GETPOST('usercats', 'array'), null, null, null,
 			null, '90%' );
 		print "</td></tr>";
 	}
diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php
index 5f44e675ece..ee76525a6ae 100644
--- a/htdocs/user/class/user.class.php
+++ b/htdocs/user/class/user.class.php
@@ -330,7 +330,7 @@ class User extends CommonObject
 		}
 		else
 		{
-			$this->error=$this->db->error();
+			$this->error=$this->db->lasterror();
 			return -1;
 		}
 
diff --git a/test/phpunit/WebservicesUserTest.php b/test/phpunit/WebservicesUserTest.php
index 9be97167104..78d3d311fe0 100644
--- a/test/phpunit/WebservicesUserTest.php
+++ b/test/phpunit/WebservicesUserTest.php
@@ -154,7 +154,7 @@ class WebservicesUserTest extends PHPUnit_Framework_TestCase
 
         // Test URL
         $result='';
-        $parameters = array('authentication'=>$authentication,'ref'=>'admin');
+        $parameters = array('authentication'=>$authentication,'id'=>0,'ref'=>'admin');
         print __METHOD__."Call method ".$WS_METHOD."\n";
         try {
             $result = $soapclient->call($WS_METHOD,$parameters,$ns,'');
@@ -177,11 +177,11 @@ class WebservicesUserTest extends PHPUnit_Framework_TestCase
         }
 
         print __METHOD__." result=".$result."\n";
-        $this->assertEquals('OK',$result['result']['result_code']);
+        $this->assertEquals('OK', $result['result']['result_code'], 'Test on ref admin');
 
         // Test URL
         $result='';
-        $parameters = array('authentication'=>$authentication,'ref'=>'refthatdoesnotexists');
+        $parameters = array('authentication'=>$authentication,'id'=>0,'ref'=>'refthatdoesnotexists');
         print __METHOD__."Call method ".$WS_METHOD."\n";
         try {
             $result = $soapclient->call($WS_METHOD,$parameters,$ns,'');
@@ -200,7 +200,7 @@ class WebservicesUserTest extends PHPUnit_Framework_TestCase
         }
 
         print __METHOD__." result=".$result."\n";
-        $this->assertEquals('NOT_FOUND',$result['result']['result_code']);
+        $this->assertEquals('NOT_FOUND', $result['result']['result_code'], 'Test on ref that does not exists');
 
         return $result;
     }
-- 
GitLab