• Resolved Jake Whiteley

    (@twentyzerotwo)


    As per the title, the following error occurs on at least PHP 7.4 when submitting a step with an empty file input.

    [20-Apr-2021 15:27:54 UTC] PHP Notice:  Undefined index: file-496 in C:\wamp64\www\gc\humanco\wp-content\plugins\cf7-multi-step\inc\frontend\validation.php on line 169
    [20-Apr-2021 15:27:54 UTC] PHP Stack trace:
    [20-Apr-2021 15:27:54 UTC] PHP   1. {main}() C:\wamp64\www\gc\humanco\wp-admin\admin-ajax.php:0
    [20-Apr-2021 15:27:54 UTC] PHP   2. do_action() C:\wamp64\www\gc\humanco\wp-admin\admin-ajax.php:187
    [20-Apr-2021 15:27:54 UTC] PHP   3. WP_Hook->do_action() C:\wamp64\www\gc\humanco\wp-includes\plugin.php:484
    [20-Apr-2021 15:27:54 UTC] PHP   4. WP_Hook->apply_filters() C:\wamp64\www\gc\humanco\wp-includes\class-wp-hook.php:316
    [20-Apr-2021 15:27:54 UTC] PHP   5. NjtCF7MLSValidation->cf7mls_validation_callback() C:\wamp64\www\gc\humanco\wp-includes\class-wp-hook.php:292
    [20-Apr-2021 15:27:54 UTC] PHP   6. NjtCF7MLSValidation->unship_uploaded_files() C:\wamp64\www\gc\humanco\wp-content\plugins\cf7-multi-step\inc\frontend\validation.php:43
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support Bruce

    (@ninjateamwp)

    Hi @twentyzerotwo ,

    Thanks for using multistep plugin, please make sure you are using the latest version of the tool.

    Then, please send us a screenshot or screencast showing this case and the error?

    Also, you can give us your form Link to check?

    Thank you!

    Kind regards,
    -Bruce-

    Thread Starter Jake Whiteley

    (@twentyzerotwo)

    Hi,

    I am using version 2.6.1 of the plugin, and version 7.4.3 of PHP.

    I won’t send you a link because this is a PHP error; sending you a link to the frontend of a website won’t add anything to the discussion as the error only appears in the PHP error logs directly on the server.

    Steps to reproduce:

    1. Create a new multistep form with a file input (do not make the input required) in step one, and a submit button in step 2.
    2. Add to a page
    3. Go to the page and click the next step button without adding a file
    4. check error logs

    This happens because the php $_FILES array is only populated when a file is uploaded.

    Looking at the code you have in that file:

    $file_result = new WPCF7_Validation();
    
    $file_tags = $contact_form->scan_form_tags(
    array(
        'feature' => 'file-uploading',
    )
    );
    
    foreach ( $file_tags as $tag ) {
        $file = $_FILES[ $tag->name ];

    If no file is submitted, then the $_FILES global will be empty.

    All that is needed is an additional check that if $tag->is_required() is false, then there should be an isset($_FILES[ $tag->name ]) conditional in order to continue processing.

    Plugin Support Bruce

    (@ninjateamwp)

    Hi @twentyzerotwo ,

    We checked and found that the log is still there even if the multistep plugin is deactivated.

    But your sugegstion is well taken and we will implement it in our upcoming updates.

    Thank you!

    Kind regards,
    -Burce-

    Thread Starter Jake Whiteley

    (@twentyzerotwo)

    Hi Bruce,

    That is impossible.

    After deactivating the plugin cf7-multi-step\inc\frontend\validation.php will never be run, so that specific error won’t appear.

    I have also tested vanilla contact form 7, and can confirm that no error log entries are created when submitting a CF7 form with an empty and non-required file input.

    The error is specifically from your plugin – line 169 of inc\frontend\validation.php.

    Because you said “still there” that suggests that you aren’t clearing your log between tests, so of course the error is still there – it is a static text file.

    Plugin Support Bruce

    (@ninjateamwp)

    Hi @twentyzerotwo ,

    Yes, you are right, I might not be clearing logs or caches on my tests, however, I assure you it would be fixed in coming update because our developers were notified of this and they would test properly, better me and then fix the issue.

    Many thanks,
    -Bruce-

    Thread Starter Jake Whiteley

    (@twentyzerotwo)

    Hi Bruce,

    Thank you for keeping me updated

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘PHP notice when submitting form with empty file fields’ is closed to new replies.