-
I work for a hosting company, and we have a customer who uses the “seo-by-rank-math-pro” plugin.
This customer’s site repeatedly creates more than 6 GB of database temporary tables, which leads to performance problems. We tracked this down to this query being run:
SELECT page, COUNT(DISTINCT(query)) AS keywords FROM wp_rank_math_analytics_gsc WHERE created BETWEEN 1674000000 AND '2023-02-17 23:59:59' GROUP BY page ORDER BY query DESC LIMIT 0, 5;
That SQL query comes from the function “get_position_for_badges()” in the “includes/modules/analytics/class-posts.php” file, and it has a bug. The query generates the database warning “Truncated incorrect datetime value: ‘1674000000’” and ignores the beginning time, making it operate on all the rows in the wp_rank_math_analytics_gsc table, instead of just a subset of them.
Instead of “1674000000”, the query should be using “2023-01-18 00:00:00”, which avoids this problem. The code in the get_position_for_badges() function currently looks like:
$start = strtotime( '-30 days ', Stats::get()->end );
… but should have an extra line to convert it to a string like this:
$start = strtotime( '-30 days ', Stats::get()->end );
$start = date( 'Y-m-d H:i:s', $start );If you could fix this, that would be appreciated.
The ticket ‘Bug in seo-by-rank-math-pro get_position_for_badges function’ is closed to new replies.