• Hello,

    the validation of a file upload of a file triggers an error. The problem is the number of arguments.

    In the file ‘contact-form-7/modules/file.php:72’ the file filter is added by

    add_filter( 'wpcf7_validate_file', 'wpcf7_file_validation_filter', 10, 3 );
    add_filter( 'wpcf7_validate_file*', 'wpcf7_file_validation_filter', 10, 3 );

    There should be passed 3 arguments.

    But in the file ‘contact-form-7/includes/submission.php:366’ there are only two arguments given:

    $result = apply_filters( "wpcf7_validate_{$type}", $result, $tag );

    This triggers the error

    PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function wpcf7_file_validation_filter(), 2 passed in /www/public/core/wp-includes/class-wp-hook.php on line 292 and exactly 3 expected in /www/public/app/plugins/contact-form-7/modules/file.php:75.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    Form-tags with the file-uploading feature fall here: https://github.com/takayukister/contact-form-7/blob/v5.4.1/includes/submission.php#L545

    $result = apply_filters(
      "wpcf7_validate_{$tag->type}",
      $result, $tag,
      array(
        'uploaded_files' => $new_files,
      )
    );

    Three params are correctly passed.

    Thread Starter Sven Wagener

    (@mahype)

    Thank you for the fast answer!

    I have debugged it, but for me it falls to Line 366 like all other fields and leads to the filter combined filter ‘wpcf7_validate_file’ which automatic assigns the function with the three parameters and leads to the Fatal error. This problem happens in the current version 5.4.1. Before we used 5.3.2 and this worked without problems.

    Plugin Author Takayuki Miyoshi

    (@takayukister)

    Can we see the site having the issue?

    Hi,

    I’m having the exact same issue. I’m unable to debug to the level of the original poster, but my error logs are exactly the same. Posting them here now:

    [Thu Jun 24 12:29:44.937754 2021] [proxy_fcgi:error] [pid 27733:tid 139961156196096] [client 175.142.167.136:34826] AH01071: Got error 'PHP message: PHP Fatal error:  Uncaught ArgumentCountError: Too few arguments to function wpcf7_file_validation_filter(), 2 passed in /var/www/vhosts/fine/httpdocs/wp-includes/class-wp-hook.php on line 292 and exactly 3 expected in /var/www/vhosts/fine/httpdocs/wp-content/plugins/contact-form-7/modules/file.php:75\nStack trace:\n#0 /var/www/vhosts/fine/httpdocs/wp-includes/class-wp-hook.php(292): wpcf7_file_validation_filter(Object(WPCF7_Validation), Object(WPCF7_FormTag))\n#1 /var/www/vhosts/fine/httpdocs/wp-includes/plugin.php(212): WP_Hook->apply_filters(Object(WPCF7_Validation), Array)\n#2 /var/www/vhosts/fine/httpdocs/wp-content/plugins/contact-form-7/includes/submission.php(366): apply_filters('wpcf7_validate_...', Object(WPCF7_Validation), Object(WPCF7_FormTag))\n#3 /var/www/vhosts/fine/httpdocs/wp-content/plugins/contact-form-7/includes/submission.php(60): WPCF7_Submission->validate()\n#4 /var/www/vhosts/fine/httpdocs/wp-content/plugi...', referer: https://www.fine/log-maintenance-issue/
    

    Happy to provide a direct link to the errored out form – in a DM if that’s okay.

    Thanks in advance.

    Hello,

    I think there is a bug in file upload since last version.
    Error I get :
    .384894 [NOTICE] [1917691] [T0] [88.126.132.98:8542-H3:49D17228021321FD-228#APVH_____:443] [STDERR] PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function wpcf7_file_validation_filter(), 2 passed in /wp-includes/class-wp-hook.php on line 292 and exactly 3 expected in /wp-content/plugins/contact-form-7/modules/file.php:75Stack trace:#0 /wp-includes/class-wp-hook.php(292): wpcf7_file_validation_filter(Object(WPCF7_Validation), Object(WPCF7_FormTag))#1 /wp-includes/plugin.php(212): WP_Hook->apply_filters(Object(WPCF7_Validation), Array)#2 /wp-content/plugins/contact-form-7/includes/submission.php(366): apply_filters(‘wpcf7_validate_…’, Object(WPCF7_Validation), Object(WPCF7_FormTag))#3 /wp-content/plugins/contact-form-7/includes/submission.php(60): WPCF7_Submission->validate()#4 /wp in /wp-content/plugins/contact-form-7/modules/file.php on line 75

    It seems that the error come from form-tags-manager.php line 242 :
    if ( $feature ) { if ( ! $this->tag_type_supports( $tag->type, $feature ) and ! $feature_negative ) { continue; } elseif ( $this->tag_type_supports( $tag->type, $feature ) and $feature_negative ) { continue; } }
    => the feature_negative is not good, it should be reverse no ?

    Thanks for your help.

    Correction : the problem come from “Bootstrap for Contact Form 7” module who remove tag “file-uploading”. Deactivate this module make it work again.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Fatal Error on file upload’ is closed to new replies.