wpDiscuz - WordPress Comment Plugin
Share:
Notifications
Clear all

Comments after the migration


dimitra
Posts: 3
Topic starter
(@dimitra)
New Member
Joined: 1 month ago

After the migration of my website to a new domain, some articles have a false number of comments,  some of them look that have the same amount of comments. But if you visit one of this article, you will not see that number of comments. I have cleared the cache and I have found one script that you can run to fix this but is for PHP 5 and I have PHP 7. I change the script so be able to run in newer version of PHP, but it doesn't work.

Any help?

3 Replies
Asti
Posts: 3860
 Asti
Support
(@asti)
Support member
Joined: 4 years ago

Hi dimitra,

We're really sorry, but we don't have any clue what was going wrong during the migration process. We highly recommend you to make the migration over again. Use for example Duplicator plugin. 

If you don't remake the migration you may also have some other kinds of issues later. 

Reply
dimitra
Posts: 3
Topic starter
(@dimitra)
New Member
Joined: 1 month ago

Hello, I can't do that, It's huge the website. The code that I found that fixing that problem is below but is for php 5 version and I have php 7.

<?php
include("wp-config.php");
if (!mysql_connect(DB_HOST, DB_USER, DB_PASSWORD)) {  die('Could not connect: ' . mysql_error());  }
if (!mysql_select_db(DB_NAME)) {  die('Could not connect: ' . mysql_error());  }
 
$result = mysql_query("SELECT term_taxonomy_id FROM ".$table_prefix."term_taxonomy");
while ($row = mysql_fetch_array($result)) {
  $term_taxonomy_id = $row['term_taxonomy_id'];
  echo "term_taxonomy_id: ".$term_taxonomy_id." count = ";
  $countresult = mysql_query("SELECT count(*) FROM ".$table_prefix."term_relationships WHERE term_taxonomy_id = '$term_taxonomy_id'");
  $countarray = mysql_fetch_array($countresult);
  $count = $countarray[0];
  echo $count."<br />";
 mysql_query("UPDATE ".$table_prefix."term_taxonomy SET count = '$count' WHERE term_taxonomy_id = '$term_taxonomy_id'");
        }
 
$result = mysql_query("SELECT ID FROM ".$table_prefix."posts");
while ($row = mysql_fetch_array($result)) {
  $post_id = $row['ID'];
  echo "post_id: ".$post_id." count = ";
  $countresult = mysql_query("SELECT count(*) FROM ".$table_prefix."comments WHERE comment_post_ID = '$post_id' AND comment_approved = 1");
  $countarray = mysql_fetch_array($countresult);
  $count = $countarray[0];
  echo $count."<br />";
  mysql_query("UPDATE ".$table_prefix."posts SET comment_count = '$count' WHERE ID = '$post_id'");
        }
?>
 
Reply
1 Reply
Asti
 Asti
Support
(@asti)
Joined: 4 years ago

Support member
Posts: 3860

So we may consider this topic as resolved, right?

Reply
Share: