• Resolved skhl

    (@skhl)


    Hi, I keep getting this PHP warning in my PHP error log related to this plugin, I’m not sure if this is something you fix or do I need to contact my web host? Thank you

    PHP Warning: Undefined array key “SERVER_NAME” in /home/mydomain/public_html/wp-content/plugins/very-simple-contact-form/vscf.php on line 139

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author Guido

    (@guido07111975)

    Hi,

    This is being used for creating the sum transient. Your form works as expected, no issues with sum or form submission?

    Guido

    Plugin Author Guido

    (@guido07111975)

    Hi again,

    Normally $_SERVER['SERVER_NAME'] returns your domain. I’ve read that the $_SERVER superglobal doesn’t work when using WP-CLI. Are you using that perhaps?

    if not, it may then be a conflict with another plugin. Could you please deactivate other plugins and check if new warnings are added to your log?

    Guido

    Thread Starter skhl

    (@skhl)

    Hi Guido, thanks for your reply. There are no issues with the sum or form submission and I’m not using WP-CLI. In that case, may have to try deactivating plugins to see if there’s a conflict.

    Plugin Author Guido

    (@guido07111975)

    Hi,

    If you could do a test with deactivating your other plugins, please do.

    Guido

    Hello, I also have the problem.

    Here is a solution (not the best):

    /***/wp-content/plugins/very-simple-contact-form # diff vscf.php vscf_fix.php 
    140c140,144
    <       $server = preg_replace("/[^a-zA-Z0-9]/", "", $_SERVER['SERVER_NAME']);
    ---
    >       if (isset($_SERVER["SERVER_NAME"])) {
    >               $server = preg_replace("/[^a-zA-Z0-9]/", "", $_SERVER['SERVER_NAME']);
    >       } else {
    >               $server = 'CRONTAB';
    >       }

    The variable ‘$_SERVER[“SERVER_NAME”]’ is not defined when running the WordPress crontab (wp-cron.php).

    The email I received from crontab (every 15min): PHP Warning: Undefined array key “SERVER_NAME” in /***/wp-content/plugins/very-simple-contact-form/vscf.php on line 140

    Plugin Author Guido

    (@guido07111975)

    Hi,

    Thanks, will add the extra check in next version.

    Is the redirect working when you submit form (is the “thank you” message displayed)?
    Because the redirect also uses the $_SERVER global.

    Guido

    belettebuck

    (@belettebuck)

    Hello,

    I don’t really know what to look for, could you say more?

    The form works well (reception for the client and the site manager)

    Plugin Author Guido

    (@guido07111975)

    Hi,

    I’m trying to duplicate “your” behavior so I fully understand the problem. For what are you using the cron job?

    If you press submit and submission is successful the thank you message is displayed. And if you look in the address bar of your browser this should be added to the URL of your contact page: vscf-sh=success
    But I’m pretty certain this works as expected.

    Guido

    belettebuck

    (@belettebuck)

    Cron is used to periodically perform tasks on WordPress, e.g.: update plugins, email campaign, etc.

    Here is an example of a cron task that I have: php /bin/su --shell /bin/sh --command "/usr/bin/php /var/www/[VHOST]/docs/wp-cron.php" [USER_PHP_FPM]

    I confirm, the vscf-sh=success is present.

    I thank you for your energy ??

    Plugin Author Guido

    (@guido07111975)

    Hi,

    I know what they are but have no experience with using them and unfortunately not able to reproduce this on my test installs. But a simple check for SERVER_NAME will fix this. Will update plugin this week.

    Guido

    belettebuck

    (@belettebuck)

    Thank you ?? ??

    Plugin Author Guido

    (@guido07111975)

    Hi @skhl and @belettebuck

    I have just updated plugin and this issue should be fixed now.
    Please do a test form submission and let me know if it still works as expected. It should ??

    Guido

    belettebuck

    (@belettebuck)

    Hello Guido

    Yes it works for me!

    I thank you ??

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘PHP warning “SERVER_NAME”’ is closed to new replies.