Critical error caused by incorrect filesystem API use

#122983
  • Resolved Jon Parker
    Rank Math free

    Hello! Great plugin thank you and I’ve recently moved many sites across from Yoast

    I’m using RankMath on one site in combination with the SSH SFTP Updater plugin to allow sftp updates

    I’ve seen there were similar reports on here in the past relating to RankMath using the WordPress Filesystem API incorrectly:

    https://support.rankmath.com/ticket/ssh-sftp-updater-fatal-error/
    https://support.rankmath.com/ticket/fatal-error-ssh-sftp-updater-plugin-cant-install-plugin-rank-math/

    The author of the SSH SFTP Updater plugin said the following, which I understand to be correct:

    This means that [the RankMath] plugin uses the WordPress Filesystem API incorrectly. It attempts to perform filesystem operations (in this case, looking up whether a file exists) without checking that the filesystem link is up. the WordPress Filesystem API has no way of handling that other than throwing a fatal error (the API only defines “yes” or “no” to the answer “does it exist?”, whereas if the link is not there then this is unknown either way), which is what is happening here. Hence, it can only be fixed in the calling plugin with the error.

    e.g. Lines 87-90 of includes/modules/robots-txt/class-robots-txt.php where exists is being called without checking the result of WordPress::get_filesystem() first

    
    $wp_filesystem = WordPress::get_filesystem();
    $public = absint( get_option( 'blog_public' ) );
    
    if ( $wp_filesystem->exists( ABSPATH . 'robots.txt' ) ) {
    

    This same way of trying to use $wp_filesystem without checking appears in several places throughout the RankMath code

    There is no Github issue so I presume it’s not on the radar to get fixed yet?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello,

    Thank you for your query and we are so sorry about the trouble this must have caused.

    We have noted this down as a bug and we will be releasing an update with a fix very soon.

    We will ping you once the update is available.

    Hello,

    Thank you for your patience.

    Please update Rank Math & all other plugins, themes, and WordPress to the latest version.

    The issue should be fixed.

    If not, please feel free to open a support topic or reply to this message and we will be more than happy to assist.

    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 2 replies - 1 through 2 (of 2 total)

The ticket ‘Critical error caused by incorrect filesystem API use’ is closed to new replies.