• Resolved janus20

    (@janus20)


    Since this morning i have got weird erorrs complaining about database insert error when referer is empty like this:

    Eroare baz? de date WordPress Column ‘ref’ cannot be null pentru interogarea INSERT INTO wp_404_to_301 (date, url, ip, ref, ua) VALUES (‘2015-12-12 18:34:59’, ‘/pagina-de-ajutor/’, ‘78.96.200.252’, NULL, ‘Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.80 Safari/537.36’) efectuat? de require(‘wp-blog-header.php’), require_once(‘wp-includes/template-loader.php’), do_action(‘template_redirect’), call_user_func_array, _404_To_301_Public->i4t3_redirect_404

    ==== eng ====
    Database error WordPress Column ‘ref’ cannot be null for query INSERT INTO wp_404_to_301(date,url,ip,ref,ua`) VALUES (‘2015-12-12 18:34:59’, ‘/pagina-de-ajutor/’, ‘78.96.200.252’, NULL, ‘Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.80 Safari/537.36’) requested by require(‘wp-blog-header.php’), require_once(‘wp-includes/template-loader.php’), do_action(‘template_redirect’), call_user_func_array, _404_To_301_Public->i4t3_redirect_404

    This is happen if it hits direct a link that does not exist anymore ( via google search engine cache or bookmarked old link… etc ).

    404-to-301 version si 2.0.9, my php version is 5.4.4-14+deb7u14 and mySql is 5.5.38

    Thank you very much for your time

    https://www.ads-software.com/plugins/404-to-301/

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Joel James

    (@joelcj91)

    Hello janus20,

    Thanks for notifying this. Will fix this soon.

    same here, just fyi.

    We’re getting this issue too. Had our Liquid Web tech people look and it’s an issue with the plugin for sure.

    Thread Starter janus20

    (@janus20)

    Hi everyone,

    Until Mr. Joel will fix this here is a ‘patch’ to it. I am not and do not pretend to be a php coder and do not know if it is ok as from a php programmer perspective but it works for me just fine.

    Here are the steps:
    1. open wp-content/plugins/404-to-301/public/class-404-to-301-public.php file for editing. Either download file via FTP and edit localy with Notepad++ or look for seqvence of code below if you open it with default text editor from your ftp program.

    2. move to line #143 where is following code
    $data[‘ref’] = $_SERVER[‘HTTP_REFERER’];

    3. modify/edit line of original code from step 2 with following:

    // $data['ref'] = $_SERVER['HTTP_REFERER'];
    if (!empty($_SERVER['HTTP_REFERER'])) {
    	$data['ref'] = $_SERVER['HTTP_REFERER'];
    } else {
    // if referer value is empty flag it with some custom text in
    // order to avoid db insert errors as 'ref' column is declared
    // as not NULL.
    $data['ref'] = 'N/A - empty referer';
    }

    *NOte: // means that content of that line will be treat as comment.

    I hope that helps.

    Wow, thank you so much for taking the time to find a workaround. My errors have stopped now, and there doesn’t appear to be any adverse effects:)

    For anyone not understanding this, just replace that one line of code wiht what Janus20 has discovered. That will take care of those pesky server errors until the plugin gets updated.

    Always appreciate people like you!

    Plugin Author Joel James

    (@joelcj91)

    Hi janus20,

    Thank you for your solution. That should work perfectly! Sorry for being late to release a fix. It will be fixed within this weekend along with few other improvements.

    I appreciate your patience.

    These errors are now getting thrown by the server for this plugin.

    “WordPress database error Column ‘ua’ cannot be null for query INSERT INTO wp_404_to_301 (date, url, ip, ref, ua) VALUES (‘2015-12-17 15:02:33’, ‘/?author=1’, ‘193.201.227.43’, ‘N/A – empty referer’, NULL) made by require(‘wp-blog-header.php’), require_once(‘wp-includes/template-loader.php’), do_action(‘template_redirect’), call_user_func_array, _404_To_301_Public->i4t3_redirect_404
    [17-Dec-2015 22:14:55 UTC] WordPress database error Column ‘ua’ cannot be null for query INSERT INTO wp_404_to_301 (date, url, ip, ref, ua) VALUES (‘2015-12-17 16:14:55’, ‘173.45.72.98’, ‘N/A – empty referer’, NULL) made by require(‘wp-blog-header.php’), require_once(‘wp-includes/template-loader.php’), do_action(‘template_redirect’), call_user_func_array, _404_To_301_Public->i4t3_redirect_404″

    Thread Starter janus20

    (@janus20)

    Hi gooma2,

    Yeah… i have seen it into my side too. You have to do the same for ‘ua’ column as we/you did for ‘ref’ column. Here is the catch:

    1. open wp-content/plugins/404-to-301/public/class-404-to-301-public.php file for editing. Either download file via FTP and edit localy with Notepad++ or look for seqvence of code below if you open it with default text editor from your ftp program.

    2. move to line #150 where is following code
    $data[‘ua’] = $_SERVER[‘HTTP_USER_AGENT’];

    3. modify/edit line of original code from step 2 with following:

    // $data['ua'] = $_SERVER['HTTP_USER_AGENT'];
    if (!empty($_SERVER['HTTP_USER_AGENT'])) {
    	$data['ua'] = $_SERVER['HTTP_USER_AGENT'];
    } else {
    	$data['ua'] = 'N/A - empty user agent! wtf!';
    }

    kind regards

    Thanks again for this!

    It’s been enough trying to get AMP’d up for Google News.:)

    Plugin Author Joel James

    (@joelcj91)

    Hi all,

    Sorry for the delay. Could you please update to latest version now and check? Please let me know the feedback. I have fixed few other issues too.

    Thread Starter janus20

    (@janus20)

    Hi,

    I can confirm that it is working on my side. Thank you very much. ( ua, ref and clear logs too )

    kind regards

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Getting errors if "ref" column is NULL’ is closed to new replies.