Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 this issue Oct 12, 2023 · 2 comments

Comments

@slim16165
Copy link

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 **

  • PHP Version: 8.0
  • WordPress Version: 6.3.1
  • Rank Math Version: 1.0.203

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(...)
...
  1. 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
Copy link
Author

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
Copy link

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;
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants