Wordpress database error when deleting post programmatically

#458415
  • Resolved Dovid Levine
    Rank Math free

    When programmatically deleting a post with wp_delete_post( $post_id, true ), I get the following error in debug.log


    WordPress database error Unknown column '0' in 'field list' for query UPDATE
    wp_rank_math_internal_meta SET internal_link_count = '0', external_link_count = '0', 0 = '' WHERE object_id = 4 made by include('/shared/httpd/wp/htdocs/web/app/plugins/wp-graphql-rank-math/vendor/codeception/codeception/codecept'), require('/shared/httpd/wp/htdocs/web/app/plugins/wp-graphql-rank-math/vendor/codeception/codeception/app.php'), {closure}, Codeception\Application->run, Symfony\Component\Console\Application->run, Symfony\Component\Console\Application->doRun, Symfony\Component\Console\Application->doRunCommand, Symfony\Component\Console\Command\Command->run, Codeception\Command\Run->execute, Codeception\Codecept->run, Codeception\Codecept->runSuite, Codeception\SuiteManager->run, Codeception\PHPUnit\Runner->doEnhancedRun, PHPUnit\Framework\TestSuite->run, PHPUnit\Framework\TestCase->run, PHPUnit\Framework\TestResult->run, PHPUnit\Framework\TestCase->runBare, ContentNodeSeoQueryTest->tearDown, wp_delete_post, do_action('delete_post'), WP_Hook->do_action, WP_Hook->apply_filters, RankMath\Links\Links->delete_post, RankMath\Links\Storage->update_link_counts, RankMath\Links\Storage->save_meta_data

    I did some sleuthing in includes\modules\links\class-storage.php::save_meta_data(), and for some reason, the $meta_data getting passed into the method is:

    
    Array
    (
        [internal_link_count] => 0
        [external_link_count] => 0
        [0] => 
    )
    

    That 0 key, I believe is supposed to be incoming_link_count, but I’m not sure why its getting lost.

    Any ideas?

    Running PHP 8.0.19 + WordPress 6.0.2 + Rank Math 1.0.98.2

Viewing 1 replies (of 1 total)
  • Hello,

    Thank you for contacting Rank Math support, and sorry for the unexpected delays and any inconvenience that might have been caused due to that.

    We have identified this issue and we are working on a fix already for the next update.

    For now to fix the issue on your site, please replace the code on this line: https://github.com/rankmath/seo-by-rank-math/blob/master/includes/modules/links/class-links.php#L81

    with
    $processor->storage->update_link_counts( $post_id, [], $links );

    I hope that helps.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 1 replies (of 1 total)

The ticket ‘Wordpress database error when deleting post programmatically’ is closed to new replies.