• Resolved hykw

    (@hykw)


    Due to Changeset 41508(https://core.trac.www.ads-software.com/changeset/41508), which has been taken in WordPress 4.8.2, these codes no longer work.

                $result1 = $wpdb->query( $wpdb->prepare(
                    "INSERT INTO {$table}data
                    (postid, day, last_viewed, pageviews) VALUES (%d, %s, %s, %d)
                    ON DUPLICATE KEY UPDATE pageviews = pageviews + %4\$d, last_viewed = '%3\$s';",
                    $id,
                    $now,
                    $now,
                    $views
                ));
    

    It seems to have been fixed like this.

                $result1 = $wpdb->query( $wpdb->prepare(
                    "INSERT INTO {$table}data
                    (postid, day, last_viewed, pageviews) VALUES (%d, %s, %s, %d)
                    ON DUPLICATE KEY UPDATE pageviews = pageviews + %d, last_viewed = '%s';",
                    $id,
                    $now,
                    $now,
                    $views,
                    $views,
                    $now
                ));
    
    • This topic was modified 7 years, 2 months ago by hykw.
    • This topic was modified 7 years, 2 months ago by hykw.
Viewing 14 replies - 1 through 14 (of 14 total)
  • Thanks! Worked for me.

    Thank you! It’s work

    Also change $result2 variable.

    Does $result2 need to be modified too?

    @hykw, please, answer us

    Prepare statement for $result2 also has same issue as $result1 so i’m pretty sure it needs to be updated.

    
    
    // Update all-time table
    $result1 = $wpdb->query( $wpdb->prepare(
    	"INSERT INTO {$table}data
    	(postid, day, last_viewed, pageviews) VALUES (%d, %s, %s, %d)
    	ON DUPLICATE KEY UPDATE pageviews = pageviews + %d, last_viewed = '%s';",
    	$id,$now,$now,$views,$views,$now ));
    
    // Update range (summary) table
    $result2 = $wpdb->query( $wpdb->prepare(
    	"INSERT INTO {$table}summary
    	(postid, pageviews, view_date, last_viewed) VALUES (%d, %d, %s, %s)
    	ON DUPLICATE KEY UPDATE pageviews = pageviews + %d, last_viewed = '%s';",
    	$id,$views,$curdate,$now,$views,$now ));
    
    

    Thanks to @hykw and @burateen !

    • This reply was modified 7 years, 2 months ago by antonmaju.
    • This reply was modified 7 years, 2 months ago by antonmaju.
    Plugin Author Hector Cabrera

    (@hcabrera)

    Hey guys!

    @hykw thanks for the heads up! I’ll push a update ASAP.

    Plugin Author Hector Cabrera

    (@hcabrera)

    Update pushed to repo. Please upgrade ASAP.

    [20-Sep-2017 14:38:33 UTC] PHP Warning: Invalid argument supplied for foreach() in /public_html/wp-content/plugins/wordpress-popular-posts/includes/class-wordpress-popular-posts-output.php on line 336

    Thanks for the update. The error still does not stop ringing
    ??

    Plugin Author Hector Cabrera

    (@hcabrera)

    Hi @mejapan!

    That sounds like a completely different issue actually.

    Please open a new topic and share as much details as you can to help you debug the problem:

    • WordPress version
    • Site URL
    • Are you using the widget? The [wpp] shortcode? The wpp_get_mostpopular() template tag?
    • Screen capture of your settings, if possible.
    • Include other details you think might help.

    Got this error message when trying to install latest update 4.0.0 on WP 4.8.2:

    Plugin could not be activated because it triggered a fatal error.
    Parse error: syntax error, unexpected ‘[‘ in website/wp-content/plugins/wordpress-popular-posts/admin/class-wordpress-popular-posts-admin.php on line 858

    Plugin Author Hector Cabrera

    (@hcabrera)

    Hi @mountain-hiker-1,

    As I just asked mejapan, please open a new issue since that’s not related to the issue reportes by the OP.

    Plugin Author Hector Cabrera

    (@hcabrera)

    Hey @mountain-hiker-1! Could you please try this?

    Thread Starter hykw

    (@hykw)

    Hi @hcabrera,
    Thank you for your quick fix. I’ve confirmed that the issue has gone in the latest version!

    • This reply was modified 7 years, 2 months ago by hykw.
    • This reply was modified 7 years, 2 months ago by hykw.
Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘broken SQL since WP 4.8.2’ is closed to new replies.