• I noticed that, as soon as the registration form appears on the screen, the WordPress debug log registers two messages, about errors in the php code:

    [03-Jun-2016 18:39:44 UTC] PHP Notice: Undefined index: com_submit in D:\Var\www\html\wp-content\plugins\auto-login-after-registration\auto-login-after-registration.php on line 62
    [03-Jun-2016 18:39:44 UTC] PHP Notice: Undefined variable: error_msg in D:\Var\www\html\wp-content\plugins\auto-login-after-registration\auto-login-after-registration.php on line 109

    It happens because a variable value is tested, before checking if the variable, at that time, is already set. The problem can be corrected as follows:

    ORIGINAL LINE 62:

    if(sanitize_text_field( $_POST['com_submit']) != ''){

    FIXED LINE 62:

    if(array_key_exists('com_submit', $_POST) && sanitize_text_field( $_POST['com_submit']) != ''){

    ORIGINAL LINE 109:

    <?php if($error_msg!='') { ?><div class="error"><?php echo $error_msg; ?></div><?php }  ?>

    FIXED LINE 109:

    <?php if(isset ($error_msg) && $error_msg!='') { ?><div class="error"><?php echo $error_msg; ?></div><?php }  ?>

    https://wordpress.org/plugins/auto-login-after-registration/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter aldemarcalazans

    (@aldemarcalazans)

    I also noticed another message in debug log, after submitting the form:

    PHP Notice: wpdb::escape is deprecated since version 3.6! Use wpdb::prepare() or esc_sql() instead. in D:\Var\www\html\wp-includes\functions.php on line 3573

    It happens because I am using a WordPress version higher than 3.5. It can be corrected as follows:

    ORIGINAL CODE:

    $password = $wpdb->escape( sanitize_text_field( $_REQUEST['com_password']));

    FIXED CODE:

    global $wp_version;
    if ( $wp_version < 2.8 ) {
      $password = $wpdb->escape( sanitize_text_field( $_REQUEST['com_password']));
    } else {
      $password = esc_sql( sanitize_text_field( $_REQUEST['com_password']));
    }

    Thread Starter aldemarcalazans

    (@aldemarcalazans)

    Another notices: If I click in the menu “Auto Login after Register”, in the admin area, the debug log registers two messages:

    [03-Jun-2016 20:39:25 UTC] PHP Notice: Undefined index: add_opt_submit in D:\Var\www\html\wp-content\plugins\auto-login-after-registration\pages\auto_login_on_register_setting.php on line 8
    [03-Jun-2016 20:39:25 UTC] PHP Notice: Undefined variable: message in D:\Var\www\html\wp-content\plugins\auto-login-after-registration\pages\auto_login_on_register_setting.php on line 29

    The corrections are as follows:

    ORIGINAL CODE:

    $add_opt_submit= sanitize_text_field( $_POST['add_opt_submit'] );
    (etc., etc.,etc.)

    FIXED CODE:

    if(array_key_exists('add_opt_submit', $_POST)) {
      $add_opt_submit= sanitize_text_field( $_POST['add_opt_submit'] );
      (etc., etc.,etc.)
    }

    ORIGINAL CODE:

    if ( $message == 'saved' ) {

    FIXED CODE:

    if ( isset($message) && $message == 'saved' ) {

    Plugin Author Cynob IT Consultancy

    (@netattingo-technologies)

    Hi @aldemarcalazans,

    Thanks you so much to notifying the points.
    We are working on new release and we will update plugin with all points.

    Thanks,
    Netattingo Technologies,

    Thread Starter aldemarcalazans

    (@aldemarcalazans)

    Allright!

    I sent you an email with some modifications I did in the plugin code. Feel free to use any of them in your new version.

    Regards,
    Aldemar

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘PHP Notices when debug is turned on’ is closed to new replies.