PHP Fatal Error - Cannot unset string offsets


Staff member
I am trying to patch an issue with WP Plugin Contact Form 7 running on Google App Engine.

The patch code is:

Plugin Name: Fix Contact Form 7
add_filter('wp_mail', 'fix_wp_mail_filter', 11);
function fix_wp_mail_filter($args) {
    $new_wp_mail = array(
        'to'          => $args['to'],
        'subject'     => $args['subject'],
        'message'     => $args['message'],
        'headers'     => $args['headers'],
        'attachments' => $args['attachments'],
    return $new_wp_mail;

Now when I test the contact form I get a 500 error in browser and checking the App Engine request logs, shows this error:

<strong>PHP Fatal error:</strong>

Cannot unset string offsets in /base/data/home/apps/s~aura-www/20170807t210800.403218500896707567/wordpress/wp-content/plugins/cf7_fix_plugin.php on line 8

Is there a problem with the PHP code?