rankmath / seo-by-rank-math

Rank Math is a revolutionary WordPress SEO Plugin that combines the features of many SEO tools and lets you multiply your traffic in the easiest way possible :bulb: :chart_with_upwards_trend: →
https://rankmath.com
106 stars 52 forks source link

PHP Fatal error: Uncaught TypeError: array_reverse(): Argument #1 ($array) must be of type array, string given in /www/gossipchi_431/public/wp-content/plugins/seo-by-rank-math/includes/modules/instant-indexing/class-instant-indexing.php:410 #252

Open slim16165 opened 12 months ago

slim16165 commented 12 months ago

Describe the bug I'm encountering two critical errors when attempting to save a post in WordPress using the Rank Math plugin. These errors prevent the post from being saved and cause a crash.

To Reproduce

  1. Log into the WordPress admin panel.
  2. Open an existing post or create a new one.
  3. Edit the post and try to save it.
  4. A fatal error occurs, preventing the post from being saved.

Expected behavior After making edits to the post, I expect the post to save successfully without any errors.

Additional details on server

Additional context Here are the detailed errors:

  1. Error related to array_reverse():

    [error] FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught TypeError: array_reverse(): Argument #1 ($array) must be of type array, string given in .../wp-content/plugins/seo-by-rank-math/includes/modules/instant-indexing/class-instant-indexing.php:410
    Stack trace:
    #0 .../wp-content/plugins/seo-by-rank-math/includes/modules/instant-indexing/class-instant-indexing.php(410): array_reverse('a:100:{i:0;a:5:...')
    #1 .../wp-content/plugins/seo-by-rank-math/includes/modules/instant-indexing/class-instant-indexing.php(325): RankMath\Instant_Indexing\Instant_Indexing->api_submit('https://...', false)
    #2 .../wp-includes/class-wp-hook.php(310): RankMath\Instant_Indexing\Instant_Indexing->save_post(...)
    ...
  2. Error related to "rankingKeywords":

    [error] FastCGI sent in stderr: "PHP message: PHP Warning:  Undefined array key "rankingKeywords" in .../wp-content/plugins/seo-by-rank-math-pro/includes/modules/analytics/class-posts.php on line 92" while reading response header from upstream...

IMPORTANT: I managed to resolve the bug, and here's the patch in git format for version 1.0.203. However, I'm primarily not a PHP developer, so I would greatly appreciate if you could review my solution. solve issue.zip

This is a small part of the dump of the log history: string(16356) "a:100:{i:0;a:5:{s:3:"url";s:32:"https://gossipchi.it/ariete/202/";s:6:"status";i:200;s:17:"manual_submission";b:0;s:7:"message";s:2:"OK";s:4:"time";i:1695884902;}i:1;a:5:{s:3:"url";s:45:"https://gossipchi.it/colapesce-dimartino/210/";s:6:"status";i:200;s:17:"manual_submission";b:0;s:7:"message";s:2:"OK";s:4:"time";i:1695884945;}i:2;a:5:{s:3:"url";s:35:"https://gossipchi.it/colla-zio/213/";s:6:"status";i:200;s:17:"manual_submission";b:0;s:7:"message";s:2:"OK";s:4:"time";i:1695884961;}i:3;a:5:{s:3:"url";s:42:"https://gossipchi.it/gianluca-grignani/48/";s:6:"status";i:200;s:17:"manual_submission";b:0;s:7:"message";s:2:"OK";s:4:"time";i:1695885005;}i:4;a:5:{s:3:"url";s:42:"https://gossipchi.it/elodie-di-patrizi/42/";s:6:"status";i:200;s:17:"manual_submission";b:0;s:7:"message";s:2:"OK";s:4:"time";i:1695885029;}i:5;a:5:{s:3:"url";s:28:"https://gossipchi.it/lda/96/";s:6:"status";i:200;s:17:"manual_submission";b:0;s:7:"message";s:2:"OK";s:4:"time";i:1695885051;}i:6;a:5:{s:3:"url";s:37:"https://gossipchi.it/sanremo-2023/39/";s:6:"status";i:200;s:17:"manual_submission";b:0;s:7:"message";s:2:"OK";s:4:"time";i:1695885080;}i:7;a:5:{s:3:"url";s:45:"https://gossipchi.it/i-cugini-di-campagna/57/";s:6:"status";i:200;s:17:"manual_submission";b:0;s:7:"message";s:2:"OK";s:4:"time";i:1695885121;}i:8;a:5:{s:3:"url";s:43:"https://gossipchi.it/silvana-giacobini/303/";s:6:"status";i:200;s:17:"manual_submission";b:0;s:7:"message";s:2:"OK";s:4:"time";i:1695885145;}i:9;a:5:{s:3:"url";s:41:"https://gossipchi.it/dorothea-wierer/300/";s:6:"status";i:200;s:17:"manual_submission";b:0;s:7:"message";s:2:"OK";s:4:"time";i:1695885168;}i:10;a:5:{s:3:"url";s:38:"https://gossipchi.it/anna-favella/297/";s:6:"status";i:200;s:17:"manual_submission";b:0;s:7:"message";s:2:"OK";s:4:"time";i:1695885191;}i:11;a:5:{s:3:"url";s:41:"https://gossipchi.it/ana-quiles-boix/291/";s:6:"status";i:200;s:17:"manual_submission";b:0;s:7:"message";s:2:"OK";s:4:"time";i:1695885734;}i:12;a:5:{s:3:"url";s:39:"https://gossipchi.it/jason-

slim16165 commented 12 months ago

IMPORTANT: I managed to resolve the bug, and here's the patch in git format for version 1.0.203. However, I'm primarily not a PHP developer, so I would greatly appreciate if you could review my solution. solve issue.zip

bahiskritik commented 5 months ago

Here solve:

Find : 405 or 406 line and change with this


$auto_submission_log = get_option( 'giapi_auto_submissions', [] );
if ( ! $is_manual && is_array( $auto_submission_log ) ) {
    // We keep the auto-submitted URLs in a log to prevent duplicates.
    $logs = array_values( array_reverse( $auto_submission_log ) );
    if ( ! empty( $logs[0] ) && $logs[0]['url'] === $url_input[0] && time() - $logs[0]['time'] < self::THROTTLE_LIMIT ) {
        return false;
    }
}