• ChrisRR

    (@chrisrr)


    Hi,

    The WP Knowledgebase plugin looks good and does exactly what we need. However when we deactivate it and reactivate it (for example when updating WP) we get this error:

    >> WordPress database error: [Duplicate entry ‘kbe_plugin_slug’ for key ‘option_name’]
    >> INSERT INTO wp_options (option_name, option_value) VALUES (‘kbe_plugin_slug’, ‘knowledgebase’)

    The only way to get WP Knowledgebase working again is to delete it from the WP interface and then manually re-install and reactivate. A problem with this is that all KB posts are then deleted on uninstall.

    Looking at the code, the part that is causing this problem is in index.php:

    $kbe_optSlugSql = "Select * From ".$kbe_pre."options Where option_name like '%kbe_plugin_slug%'";
    $kbe_optSlugQry = mysql_query($kbe_optSlugSql);
    $kbe_optSlugNum = mysql_num_rows($kbe_optSlugQry);
    
    if ($kbe_optSlugNum == 0){ ..

    As far as I can see $kbe_optSlugNum is always 0, even if there is a row in the DB meeting the query criteria. Digging further, I think the underlying error generated is that “Access denied for user ”@’localhost’ (using password: NO)”.

    If I change it to:

    $res = $wpdb->query($kbe_optSlugSql);
    if ($res == 0) { ...

    then it seems to work. (The error is then moved to the next query using mysql_query().)

    So I *think* (but am not sure) that mysql_query() does not use the right DB connection credentials, but using the WP $wpdb instance does.

    There is a mixture of these two ways of accessing the DB in the WP Knowledgebase, and as far as I can see using the WPDB class is recommended in WP. Also mysql_query() is now deprecated. So are you thinking of updating the plugin code and removing mysql_…() calls?

    Thanks,

    Chris

    https://wordpress.org/plugins/wp-knowledgebase/

Viewing 1 replies (of 1 total)
  • Plugin Contributor Maeve Lander

    (@enigmaweb)

    Thanks for reporting this Chris, and for helping out by sharing your solution. Very much appreciated. I’ll go through this and implement to the plugin for everyone in next release.

    Thanks again – I really appreciate your contribution.

    Maeve

Viewing 1 replies (of 1 total)

The topic ‘Deactivate/reactivate’ is closed to new replies.