Opened 10 years ago
Closed 10 years ago
#32290 closed defect (bug) (invalid)
Problem wpdb->update and update_post_meta
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.2.2 |
Component: | General | Keywords: | close |
Focuses: | Cc: |
Description (last modified by )
I'm developing plugins and wordpress theme for my private project. To the point, i have found problem about "wpdb->update and update_post_meta".
The update result (on database) is incorrect when i use increment variable.
Example: I build viewPageCounter function, so in single.php I update the meta_value (of the post_views_count column) with countered or increment variable.But the result is always +1 (more 1 point from the true result).
But after i remove the rel='prev' and rel='next' on wp_head() using remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head' ); the result is correct.
First trial, i use
$count = get_post_meta('20', $count_key, true); //example the $count is 11 $count++; //to be 12 update_post_meta('20', 'post_views_count', $count); //on database is 13
2nd trial, i use $wpdb->get_results and $wpdb->update, I got the same result.
Finally i trace and got the problem is on wp_head() in rel=next. So after remove it using remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head' );
i got the correct result
$count = get_post_meta('20', $count_key, true); //example the $count is 11 $count++; //to be 12 update_post_meta('20', 'post_views_count', $count); //on database is 12
Hi @mwanteam, welcome to Trac!
It's caused by browser prefetching, see #12603, #14382, #19018, #20192, #21658, #28797.
I don't think we can do anything here.