• Resolved m_disseny

    (@m_disseny)


    Hi, first of all let me thank you for developing this plugin, just came across with it and looks like what I’m looking for.

    However, I found a bug after activation related to table prefixes. I see the plugin contains at least one function which queries directly to “wp_posts” table. This is not correct as table prefix may be (or must be…) changed in config settings for security issues.

    The correct approach would be:

    function stgh_ticket_count_answers($postId) {
            global $wpdb;
    
            $table_name = $wpdb->prefix . 'posts';
    
            $query = 'SELECT COUNT(<code>ID</code>) FROM <code>' . $table_name . '</code>
                          WHERE <code>' . $table_name . '</code>.<code>post_parent</code>= ' .$postId. '
                          AND <code>' . $table_name . '</code>.<code>post_status</code> NOT IN ("trash")
                          AND <code>' . $table_name . '</code>.<code>post_type</code>="'. STG_HELPDESK_COMMENTS_POST_TYPE .'"';

    Further info: http://codex.ww.wp.xz.cn/Class_Reference/wpdb

    Thanks a lot!!!

    https://ww.wp.xz.cn/plugins/catchers-helpdesk/

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘DB table prefix errors’ is closed to new replies.