Jump to content
TNG Community
lastejas

TNG Mods & php 8

Recommended Posts

lastejas

I have just started testing TNG13.0.1 with php 8.0.0 on my test server and it displays more error messages produced by mods than it does genealogy information!

TNG13.0.1 itself is very much php8 compliant and the couple of issues I've found have been addressed/fixed by Darrin which is much appreciated.

So as an initial heads up to Mod Developers, from all mods I use, the following is a list of the ones that I have found that have php8 problems. I'm sure I'll find more as time goes on.

 Add Parents Children Row -  v10.1.0.0

Count Ancestors/escendants - V13.0.0.4

Expand Search - V13.0.0.0

Family Preview Mod - v10.1.0.2c

FGW Tabs - V11.0.0.9

Person Media Edit - V13.0.0.5f

Placesearch More Info - V13.0.0.5f

Regroup Person-Family Indicators - V13.0.0.19a

Relate Mod - V11.0.0.2a

Relationship Display - v10.0.0.1

Show All Family - V12.0.0.4e

Show Nicknames - V13.0.0.0

Show/Hide Standard Events - V11.0.0.0a

I hope this list is useful.

 

 

 

 

 

 

 

Share this post


Link to post
Share on other sites
Ken Roy

Please, please do not upgrade any TNG sites to using PHP 8. 

As Rick indicates, mods have not been tested in that environment, and I would not be surprised that TNG was also not tested by Darrin on PHP 8.  You all need to give the mod developers a break.  TNG 13 broke several mods and TNG v13 was needed in order to find PHP warnings and notices in mods.  Thanks to Brent Hemphill and Rick Bisbee for their effort in identifying and providing recommendations on fixing PHP notices and warnings 

Personally, I do not have the time to upgrade a test environment to PHP 8.  I am too busy trying to figure out MediaWiki extensions that do not work correctly when upgrading my TNG test wiki to MediaWiki 1.35 which need to be resolved before I can create the steps for Darrin to upgrade the TNG Wiki

Share this post


Link to post
Share on other sites
XerxX
1 hour ago, lastejas said:

Count Ancestors/escendants - V13.0.0.4

In my PHP 7.4.2 environment this mod throws six Notices regarding suspected null indecies. Do you get any Warnings or Errors? I don't.

 

The question I ask (myself) is "How much work shall I do, or do I turn Notices off?"

I can get rid of four of those Notices like this (2 places, I show one):
 

//   if ($xerxxAncArray[0] > 0 && in_array($inPersID, $xerxxAncArray)) { $xerxxCntr--; return $xerxxCntr; }
   if (!empty($xerxxAncArray[0]) && $xerxxAncArray[0] > 0 && in_array($inPersID, $xerxxAncArray)) { $xerxxCntr--; return $xerxxCntr; }

//   $xerxxAncArray[0]++;
   if (!empty($xerxxAncArray[0])) $xerxxAncArray[0]++; else $xerxxAncArray[0] = 1;

And then we have these two(!) Notices (line-numbers incl the above changes):

Quote

[01-Dec-2020 13:14:48 UTC] PHP Notice:  Trying to access array offset on value of type null in /Applications/MAMP/htdocs/TNG13/genlib.php on line 1446
[01-Dec-2020 13:14:48 UTC] PHP Notice:  Trying to access array offset on value of type null in /Applications/MAMP/htdocs/TNG13/genlib.php on line 1446

generated by this single line:

$select = "SELECT husband, wife from $families_table WHERE gedcom = '" . $tree . "' AND familyID = '" .$rad2['familyID'] . "';";

How to get rid of that one? Two?!

None of these indecies have caused any problem ever. The Notices are only that: Notices that something may be wrong, at least in this mod. They are great when you start building a script but sooner or later you have to turn them off: PHP can't tell if an index is set in another script or not.

 

As an elderly (70+ yo) and not very prosperous person, I have a hard time just to keep my mods up-to-TNG. So I whole-heartedly agree with Ken's post above. (And I turn Notices off ;-) )

 

Best regards,

Erik

Share this post


Link to post
Share on other sites
Michel KIRSCH

try if (isset(&xerxxAncArray) &&......

 

or verify, before using it, if your index familyID in the sql statement is not empty or null ( $rad2['familyID'] )

Michel

Share this post


Link to post
Share on other sites
Michel KIRSCH

Have no notice with local Laragon - PHP 7.4.09 - MySQL 5.7.24.

From where is coming this PHP 7.4.2 version? Is it not 7.4.02?

The last PHP version given by https://windows.php.net/download is 7.4.13...

Michel

 

Share this post


Link to post
Share on other sites
Michel KIRSCH

No notice when online with PHP 7.4.13 and MySQL 5.5.5

Maybe is it not your Mod which gives the notice..?

Michel

Share this post


Link to post
Share on other sites
Michel KIRSCH

For a better readability, I propose you the next corrections into the french languages files (French and French-UTF8)

$text['xerxxGPdescs'] = " descendants"; (old was "descendance")
$text['xerxxGPmore'] = "plus de "; (old was "plus que ")
$text['xerxxGPfinishtext'] = " dans cet arbre."; (old was "dans cet arbre de la famille.")

Michel

 

 

Share this post


Link to post
Share on other sites
XerxX

Hi Michel,

The arrays (two) are declared like

$xerxxAncArray = array(0 => 0, 1 => "");

and passed to the functions via the global declaration. So the whole checking thing is not necessary, really.

2 hours ago, Michel KIRSCH said:

try if (isset(&xerxxAncArray) &&......

I use empty() because it's getting variables that are non-existent (without Warning), null, zero (int and float), "0", false and "" (empty string) and even array() (an empty array). And because it can be both true or false in these cases (!empty()) it really doesn't matter.

2 hours ago, Michel KIRSCH said:

f your index familyID in the sql statement is not empty or null ( $rad2['familyID'] )

It's never empty or null as it's read from the childrens table using a children's person ID - children have family IDs. right? So even here, checking is not necessary.

2 hours ago, Michel KIRSCH said:

From where is coming this PHP 7.4.2 version? Is it not 7.4.02?

That's what my MAMP preferences says. And SQL 5.7.26. Wait; I'll check the PHPinfo... Yes: 7.4.2 ...

1 hour ago, Michel KIRSCH said:

Maybe is it not your Mod which gives the notice..?

Well, the line numbers in the Notices are for sure pointing to the modified lines. I got rid of four Notices by changing according to the top example (two places, I show one).

1 hour ago, Michel KIRSCH said:

No notice when online with PHP 7.4.13 and MySQL 5.5.5

Are Notices turned on i subroot.php? I used this:

error_reporting(E_ERROR | E_NOTICE | E_PARSE | E_WARNING );

 

Thank You for the translations! I will use them from the next update.

(I haven't done the above changes in the published version of the mod.)

 

Best regards,

Erik

Edited by XerxX
"both true or false" above

Share this post


Link to post
Share on other sites
Michel KIRSCH
14 hours ago, XerxX said:

$xerxxAncArray = array(0 => 0, 1 => "");

and passed to the functions via the global declaration. So the whole checking thing is not necessary, really.

I think that declare a variable in a function and then uses it with a global statement is not a good a bad idea ! The scope of such a declaration stay IN the function...

The best is to declare it in the function and then pass it to the next function, in the parameters. =>

   $xerxxAncArray = array(0 => 0, 1 => "");
   $summa2 = xerxxCountAllAncestors($pID, 0, $xerxxLimit, $xerxxAncArray);

The global statement works if your variable is defined out of a function (begin of your php file) and then is used in some functions with a global statement...

When you "globalize" your $xerxxAncArray in your xerxxCountAllAncestors function, the array is not viewed by the function.
When the array is examined for the first time, it raise a notice on :

   if ($xerxxAncArray[0] > 0 && in_array($inPersID, $xerxxAncArray)) { $xerxxCntr--; return $xerxxCntr; }

Then the array it is really created on :

   $xerxxAncArray[0]++;
And your declaration in the getXerxxNumberOfAncDesc function has no effect...
Hope I'm understandable and clear...

 

14 hours ago, XerxX said:

Are Notices turned on i subroot.php? I used this: 

I use the prolog Mod with E_ALL and display on the screen.

14 hours ago, XerxX said:

That's what my MAMP preferences says. And SQL 5.7.26. Wait; I'll check the PHPinfo... Yes: 7.4.2 ...

No such a version on the net. The last is 7.4.13 => https://www.php.net/downloads.php

Michel

Share this post


Link to post
Share on other sites
XerxX

Hi Michel,

Thank You for your invaluable suggestions! (And I'm sorry if my reply came out as a bit cocky - when I re-read it it could be read as such, but it was of course not my intention)

I tested and the two arrays were - as you pointed out - empty. So I moved the declarations to the beginning of genlib and the Notices were gone. What surprises me is that the check for duplicate IDs works...

(And I think I remember that I had to keep the arrays outside of the recursive calls (make them global) as they got strange values otherwise... not sure though)

I also now understand that the two "SQL Notices" was regarding the index ["familyID"] itself - AND the value: Hence two Notices. The query obviously gives a valid "result" even if the person is not in the children table..?

   $select2 = "SELECT familyID from $children_table WHERE personID = '" . $inPersID . "' AND gedcom = '" . $tree . "';";
   $result2 = tng_query($select2) or die ("FEL 1: *". $select2 . "*");
   if ($result2) {
      $rad2 =  tng_fetch_array($result2);

      if (isset($rad2['familyID']) && $rad2['familyID'] != "") {

That last line is added and gets rid of the two Notices.

So: There's a new version of the mod coming.

 

Now, regarding PHP 7.4.2 it's absolutely what my PHPinfo says. Here are two screendumps from it:

phptop.gif  phpcore.gif

The first one is at page top, the second is heading "Core". And "PHP7.4.2" is mentioned all over the page.

 

Best regards,

Erik

 

Share this post


Link to post
Share on other sites
Michel KIRSCH
14 minutes ago, XerxX said:

Now, regarding PHP 7.4.2 it's absolutely what my PHPinfo says. Here are two screendumps from it:

Yes this version has existed => https://www.php.net/releases/7_4_2.php
but is no more available... Wierd...

19 minutes ago, XerxX said:

SELECT familyID from $children_table WHERE personID = '" . $inPersID . "' AND gedcom = '" . $tree . "'

The query works well, but returns an empty result2. To avoid using an empty result, you can use
 

if ( mysqli_num_rows($result2) > 0)  $rad2 = tng_fetch_array($result2);

 

27 minutes ago, XerxX said:

(And I'm sorry if my reply came out as a bit cocky - when I re-read it it could be read as such, but it was of course not my intention)

My English is not good enough for me to detect arrogance  :-)

 

Michel

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×