View ProjeQtOr On SourceForge.net
ProjeQtOr - Project Management Tool
Support us on Capterra
OIN - Open Invention Network
ProjeQtOr free project management software - Meaning of "// FOR PHP 7.1 COMPATIBILITY " in model/persistence/SqlElement.php - ProjeQtOr
 
 

Meaning of "// FOR PHP 7.1 COMPATIBILITY " in model/persistence/SqlElement.php

More
27 Jun 2018 18:05 #1 by Glaurung4567
Hi,
I'm coding new functionnalities on Projeqtor as part of my traineeship. I created a new class with an attribute with a decimal type. I wish to keep the attribute to NULL when getting the objects from the db with getSqlElementsFromCriteria(...), but the function set my attribute from NULL to 0 on the line 2362.

I do not understand the condition nor the comment, could you explain it to me ? Here is the condition:



Thank you
Attachments:

Please Log in or Create an account to join the conversation.

More
29 Jun 2018 09:15 - 29 Jun 2018 09:16 #2 by babynus
It wont be possible now to keep numeric value to zero.

It is due to major change on PHP 7.1.
Before PHP 7.1 : $a=1; $b=null; $c=$a+$b; // leads to $c=1
After PHP 7.1 : $a=1; $b=null; $c=$a+$b; // leads to error

So we had to manage numeric values to never be null, and replace them with 0 when read from db or from input.
(we could not get through the whole code to parse every sting used in arythmetic operation)
But I agree that it may be disapointing as Null value (no data entered) is not exactly the same as zero value (a zéro is amnually entered)

Babynus
Administrator of ProjeQtOr web site
Last edit: 29 Jun 2018 09:16 by babynus.
The following user(s) said Thank You: Glaurung4567

Please Log in or Create an account to join the conversation.

More
29 Jun 2018 09:38 #3 by Glaurung4567
Well, i tested this case on a php sandbox and it didn't seem to present any problem.
Here the link: sandbox.onlinephpfunctions.com/code/a592...c2206f6dec8b902a8a40

Sadly i don't have a server with PHP 7.1 (i work with wamp) so i can't test it on Projeqtor.

Please Log in or Create an account to join the conversation.

More
29 Jun 2018 10:01 #4 by babynus

Sadly i don't have a server with PHP 7.1 (i work with wamp) so i can't test it on Projeqtor.

You can easily have several versions of PHP on Wamp : wampserver.aviatechno.net/
(I have 5 on my dev one)
Try with ProjeQtOr V6.3.7 : you'll have the issues

Babynus
Administrator of ProjeQtOr web site

Please Log in or Create an account to join the conversation.

More
29 Jun 2018 17:29 #5 by Glaurung4567
Well, i dug deeper into the problem and reproduced the error on PHP 7.1 (I commented the lines to set the attribute to 0 when it's null in SqlElement.php).

But the cause isn't exactly the one you mentionned. It's the addition of a string of a float and an empty string which cause the warning (sandbox.onlinephpfunctions.com/code/47ca...ff53533bc050b57059bc). Here the test I made on Projeqtor :


A possible solution might be to replace the first test of the condition ("if ($this->{$col_name}===null...") by " if ($this->{$col_name}===''"...".
Attachments:

Please Log in or Create an account to join the conversation.

More
03 Jul 2018 16:09 #6 by babynus
We'll have a try on V7.2 (under development)
But I'm afraid issues will occur.
if ($this->{$col_name}==='' 
and ( ( $dbType=='numeric') or ( $dbType=='decimal') )
cannot be true (db cannot store empty string in a numeric column)

Babynus
Administrator of ProjeQtOr web site

Please Log in or Create an account to join the conversation.

Moderators: babynusprotion
Time to create page: 0.062 seconds

Cookies settings

×

Functional Cookies

Ce site utilise des cookies pour assurer son bon fonctionnement et ne peuvent pas être désactivés de nos systèmes. Nous ne les utilisons pas à des fins publicitaires. Si ces cookies sont bloqués, certaines parties du site ne pourront pas fonctionner.

Session

Please login to see yours activities!

Other cookies

Ce site web utilise un certain nombre de cookies pour gérer, par exemple, les sessions utilisateurs.