fisharebest / webtrees

Online genealogy
https://webtrees.net
GNU General Public License v3.0
487 stars 301 forks source link

1.7 (PHP7.4) "Trying to access array offset on value of type null" when viewing certain individuals #2874

Closed mestaritonttu closed 4 years ago

mestaritonttu commented 4 years ago

Using version 1.7.6. When I view some individuals, I get an unstyled view and in the website logs I see:

/webtrees/app/Individual.php:1157 Trying to access array offset on value of type null
#0 /app/Individual.php:1157 ErrorException("Trying to access array offset on value of type null")
#1 /app/GedcomRecord.php:633 addName('INDI', '@P.N. /@N.N./', [NULL])
#2 /app/GedcomRecord.php:764 getAllNames()
#3 /app/Module/FamilyNavigatorModule.php:170 getFullName()
#4 /app/Module/FamilyNavigatorModule.php:100 drawFamily([Family F140@1], 'Family with <span class="NAME"…')
#5 /app/Controller/IndividualController.php:387 getSidebarContent()
#6 /individual.php:48 getSideBarContent()

I am running PHP 7.4, looks like it is the cause as its behaviour changed in this regard.

Individual.php:1157 has: $sublevel = 1 + (int) $gedcom[0];

So in this case $gedcom seems to be null and it fails.

Indeed, GedcomRecord.php has a workaround on line 633, which gives null for the $gedcom argument in the addName function:

$this->addName(static::RECORD_TYPE, $this->getFallBackName(), null);

addName is defined as

protected function addName($type, $value, $gedcom)

fisharebest commented 4 years ago

This issue has already been fixed in webtrees 2.0 (which is tested against PHP 7.1 - 7.4)

webtrees 1.7 is only tested against PHP 5.3 - 7.3

I could back-port the fix to the 1.7 branch, but you are likely to find other PHP 7.4 compatibility issues.

mestaritonttu commented 4 years ago

Ok, I understand the reasoning from a resource standpoint.