LimeSurvey: master a908e85d

Author Committer Branch Timestamp Parent
Bert Hankes GitHub master 2024-01-31 18:59 master e78bedb2
Affected Issues  19217: Error under php 8.x
Changeset

Fixed 19217: PHP8 Error Type NULL (#3666)

  • Fixed: 19217 Update Survey.php

$attdescriptiondata = decodeTokenAttributes($this->attributedescriptions ?? '');
change to
$attdescriptiondata = decodeTokenAttributes($this->attributedescriptions ?? []);
In PHP 7 it is a warning
in PHP 8 it's a 500! parameter key() must be an array!!

  • Fixed 10217: Update common_helper.php

$aSavedExtraTokenFields = Survey::model()->findByPk($surveyid)->tokenAttributes;
change to:
$aSavedExtraTokenFields = Survey::model()->findByPk($surveyid)->tokenAttributes ?? [];
In PHP 7 it is a warning
in PHP 8 it's a 500! $aSavedExtraTokenFields is not allowed to be NULL anymore! in function array_intersect_key()!

  • Update common_helper.php

Corrected code line 2946

  • 19217: Update Survey.php

revert back to from ?? [] to ?? '' on line 667

  • 19217: Update Survey.php

Extra check on first element of array
If it is not an array set array to NULL

  • 19217: Update Survey.php

Final edit after line 667:
Check on array after reset(array)

  • 19217: Update Survey.php

And some missing spaces...
this one should pass!!!

mod - application/helpers/common_helper.php Diff File
mod - application/models/Survey.php Diff File