• Resolved bushidopt

    (@bushidopt)


    Just received this email saying that WordPress found an error in one of my plugins, SSH SFTP Updater Support.

    Page where the error was identified (https://www.****.com/wp-admin/admin.php?page=aioseo-tools)

    WordPress version 5.8.1
    Current theme: Newspaper (version 11.3.1)
    Current plugin: SSH SFTP Updater Support (version 0.8.4)
    PHP version 7.4.3

    Error Details
    ================
    An error of type E_ERROR was caused on line 253 of the file /var/www/***.com/wp-content/plugins/ssh-sftp-updater-support/class-wp-filesystem-ssh2.php. Error message: Uncaught Error: Call to a member function stat() on bool in /var/www/***.com/wp-content/plugins/ssh-sftp-updater-support/class-wp-filesystem-ssh2.php:253
    
    Stack trace:
    

    Stack trace:
    #0 /var/www/***.com/wp-content/plugins/all-in-one-seo-pack/app/Common/Tools/BadBotBlocker.php(257): WP_Filesystem_SSH2->exists()
    #1 /var/www/***.com/wp-content/plugins/all-in-one-seo-pack/app/Common/Traits/Helpers/Vue.php(284): AIOSEO\Plugin\Common\Tools\BadBotBlocker->getLogSize()
    #2 /var/www/***.com/wp-content/plugins/all-in-one-seo-pack/app/Common/Admin/Admin.php(864): AIOSEO\Plugin\Common\Utils\Helpers->getVueData()
    #3 /var/www/***.com/wp-includes/class-wp-hook.php(303): AIOSEO\Plugin\Common\Admin\Admin->enqueueAssets()
    #4 /var/www/***.com/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters()
    #5 /var/www/***.com/wp-includes/plugin.php(470): WP_Hook->do_action()
    #6 /var/www/***.com/wp-admin/admin-header.php(102): do_action()
    #7 /var/www/***.com/wp-admin/admin.php(239): require_once(‘/var/www/***..`

    ================

    In the admin area of wordpress shows:
    Warning: ftp_fget() expects parameter 1 to be resource, null given in /var/www/***.com/wp-admin/includes/class-wp-filesystem-ftpext.php on line 146

    ================

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author David Anderson

    (@davidanderson)

    The source of the error is in the plugin wp-content/plugins/all-in-one-seo-pack – it uses the WP filesystem API incorrectly. Specifically, it makes calls without checking whether they succeed. And when they don’t succeed, it just carries on, causing the fatal error. This can only be rectified in that plugin.

    David

    Thread Starter bushidopt

    (@bushidopt)

    Hi David, thanks for the answer ??

    @davidanderson AIOSEO dev here.

    On that line we’re just doing a $wpfs->exists( $filePath ) ) check to see if a file exists so that we can get the size of the file in case it does.

    $wpfs = aioseo()->helpers->wpfs();
    if ( @$wpfs->exists( $filePath ) ) {
    	@$wpfs->put_contents( $filePath, '' );
    }

    Can you explain to me in what way we are incorrectly using the WPFS API here? We’d be happy to fix this on our end in case we’re doing something wrong.

    Plugin Author David Anderson

    (@davidanderson)

    The code on that line checks for whether a file exists, without first checking that there was a working WP_Filesystem connection. In that situation, the question “does this file exist” is unanswerable, so all that the filesystem layer can do is throw an error (it can’t reply “yes” or “no”). And the code does not attempt to catch errors, and hence the error is treated by PHP as fatal.

    So, what you need to do is go to the preceding lines, where the WP Filesystem object is initialised, and check for initialisation failures, instead of proceeding. Or if you do choose to just proceed without checking for errors, then catch errors on subsequent method calls (but that approach requires PHP 7.0+, since earlier versions don’t allow errors to be caught).

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘WordPress found an error in plugin, SSH SFTP Updater Support’ is closed to new replies.