• Resolved Koesper

    (@koesper)


    I’ve been playing with the plugin on my local machine, and it looked really promising. Especially the option to leave additional feedback after the star-rating.

    But when deploying to my production environment, i’m getting “But when deploying to my production environment, i’m getting “Invalid Token” errors when the users submit their additional feedback.

    After some debugging, it appears that the token is an ID that ought to be in the ‘wp_rmp_analytics’ table, but apparently cannot be found?

    Anyone else with similar problems?

    I’ve been able to reproduce this locally, by restoring a backup from the production environment.
    Even when removing all other plugins, and setting the theme to twenty-twentyfour, the problem persists. I’ve also reset the the FeedbackWP configuration and used the ‘Delete Plugin Data’ tool

    • This topic was modified 5 months, 3 weeks ago by Koesper.
Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Collins Agbonghama

    (@collizo4sky)

    Is wp_rmp_analytics table present in your database?

    I am unable to replicate the issue.

    Thread Starter Koesper

    (@koesper)

    Hi, apologies for the delay, but it took some time to get back on this.

    unfortunately, i dont have direct access to the database, so i had to figure out how to check if the table exists… and -as expected- the table does not exist.

    I’ve added this snippet to my theme:

    global $wpdb;
    $result = $wpdb->get_results ( "SELECT * FROM wp_rmp_analytics");

    if($wpdb->last_error){
    var_dump($wpdb->last_error);
    var_dump($wpdb->last_query);
    }
    foreach($result as $row){
    var_dump($row);
    }

    which throws

    string(58) "Table 'wp_xyz.wp_rmp_analytics' doesn't exist"
    string(30) "SELECT * FROM wp_rmp_analytics"

    I’ve deleted the plugin again and updated to the latest (4.1.0) version.

    Thread Starter Koesper

    (@koesper)

    Hmm.. running queries manually triggered me to try to simply add the table manually.
    (by getting the schema from class-rate-my-post-upgrader.php)

    But if i run that, i get this error, which explains why the table doesnt exist
    Failed to generate invisible primary key. Auto-increment column already exists.

    Apparently this can happen on MySQL on Azure, which is what i’m running
    https://learn.microsoft.com/en-us/azure/dms/known-issues-azure-mysql-fs-online


    An other plugin seems to have run into a similar problem, with MSSQL 8 on Azure, where sql_generate_invisible_primary_key apparently is turned on by default.

    Thread Starter Koesper

    (@koesper)

    found a solution!

    change the last line
    UNIQUE KEY id (id)
    into
    PRIMARY KEY (id)

    this way sql_generate_invisible_primary_key isnt triggered, since there is an actual PRIMARY key, instead of a UNIQUE that is used as a primary.

    (because if there is no explicit primary, it will generate an invisible primary)

    I did it by just running this code from my theme functions.php

           global $wpdb;
    $table_name = $wpdb->prefix . 'rmp_analytics';
    $charset_collate = $wpdb->get_charset_collate();

    $sql = "CREATE TABLE $table_name (
    id mediumint(9) NOT NULL AUTO_INCREMENT,
    time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
    ip tinytext NOT NULL,
    country tinytext NOT NULL,
    user smallint(5) NOT NULL,
    post mediumint(9) NOT NULL,
    action smallint(5) NOT NULL,
    duration smallint(5) NOT NULL,
    average decimal(2, 1) NOT NULL,
    votes smallint(5) NOT NULL,
    value smallint(5) NOT NULL,
    token tinytext NOT NULL,
    PRIMARY KEY (id)
    ) $charset_collate;";

    $results = $wpdb->get_results($sql);
    if ($wpdb->last_error) {
    echo "err";
    var_dump($wpdb->last_error);
    var_dump($wpdb->last_query);
    }
    foreach($results as $row){
    var_dump($row);
    }
    • This reply was modified 5 months, 1 week ago by Koesper. Reason: added sample code
    Plugin Author Collins Agbonghama

    (@collizo4sky)

    You right. Thanks for your hard work.

    This will be fixed in the next update.

    Thread Starter Koesper

    (@koesper)

    Crap, close, but no cigar!

    the actual feedback is not saved properly?

    I see the data in wp_postmeta, but it doesnt show in the ‘feedback’ display below the post.

    Plugin Author Collins Agbonghama

    (@collizo4sky)

    That’s weird as the feedbacks are pulled from the post metadata.

    Are you sure the feedback you see share same post ID as the post?

    Thread Starter Koesper

    (@koesper)

    Yeah, i see data like this

    object(stdClass)#2824 (4) {
    ["meta_id"]=>
    string(4) "5247"
    ["post_id"]=>
    string(3) "246"
    ["meta_key"]=>
    string(20) "rmp_feedback_val_new"
    ["meta_value"]=>
    string(156) "a:1:{i:0;a:5:{s:8:"feedback";s:15:"TEST FEEDBACK 1";s:4:"time";s:19:"18-06-2024 11:07:02";s:2:"id";s:13:"66716a564f841";s:4:"user";i:2;s:8:"ratingID";i:8;}}"
    }

    if I run this query

    $postid = get_the_ID();
    $sql = "SELECT * FROM wp_postmeta where post_id = $postid and meta_key like 'rmp_%';";

    Not quite sure how to deconstruct that meta_value, but it looks like that ID string (“66716a564f841”) is not correct?
    (probably because i hacked the UNIQUE / PRIMARY thing in the table?)

    Plugin Author Collins Agbonghama

    (@collizo4sky)

    I have been able to reproduce the issue. It was indeed a bug and I will be releasing an update shortly.

    Plugin Author Collins Agbonghama

    (@collizo4sky)

    Update is now live. That should fix the issue.

    Thanks for reporting this bug to us.

    Thread Starter Koesper

    (@koesper)

    Awesome, seems to work!

    Thanks for your quick and friendly response.

Viewing 11 replies - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.