Legacy Form Error - When trying to send a message with an empty file upload - Whoops \ Exception \ ErrorException (E_WARNING)

Trying to send a legacy form with an empty File Upload field. I get:

Whoops \ Exception \ ErrorException (E_WARNING)
Undefined array key 6

} elseif ($row['inputType'] == 'fileupload') {
    $answerLong = '';
    $answer = (int) ($tmpFileIds[(int) ($row['msqID'])]);   <-- Error line 479
    if ($answer > 0) {
        $answerDisplay = File::getByID($answer)->getVersion()->getDownloadURL();
    } else {
        $answerDisplay = t('No file specified');

I forgot to add
PHP 8.1.12

If you need/want access to the site I’ll post it, it is my testing site.

That looks like it could be a php8 issue. If you try the site under php7.4 that will provide confirmation.

Works perfectly with PHP 7.4, I should have put that. I will start, if I find any more issues.

Please report the issue on Github.

Thanks @JohntheFish - that’s the best way for sure. Here’s a link to where they should submit on Github: Issues · concretecms/concretecms · GitHub

I did submit this as a bug on GitHub.


One quick fix would be just to check if the array key is set and if not, set the answer to zero:

$answer = (int) (isset($tmpFileIds[$row['msqID']]) ? $tmpFileIds[(int) ($row['msqID'])] : 0);

That being said, the Legacy forms seem to have other PHP8-related problems too. If you try to open form results at /dashboard/reports/forms/legacy, you get:

Non-static method Concrete\Block\Form\MiniSurvey::loadQuestions() cannot be called statically

/concrete/controllers/single_page/dashboard/reports/forms/legacy.php 173

$questionsRS = MiniSurvey::loadQuestions($questionSet);