Support » Plugin: Photo Gallery by GT3 - Video Gallery & Gutenberg Block Gallery » Fatal error when deleting image

  • Resolved Alexander

    (@alexholsgrove)


    When we try and delete an image from the media library, we see the following server error:
    Fatal error: Uncaught Error: Class 'WP_Filesystem_Direct' not found in /home/wordpress-sites/######/httpdocs/app/plugins/gt3-photo-video-gallery/core/class-watermark.php:200 Stack trace: #0 /home/wordpress-sites/######/httpdocs/app/plugins/gt3-photo-video-gallery/core/class-watermark.php(153): GT3\PhotoVideoGallery\Watermark::check_folder() #1 /home/wordpress-sites/######/httpdocs/app/plugins/gt3-photo-video-gallery/core/class-watermark.php(36): GT3\PhotoVideoGallery\Watermark::restore(3462) #2 /home/wordpress-sites/######/httpdocs/wp/wp-includes/class-wp-hook.php(289): GT3\PhotoVideoGallery\Watermark::delete_attachment_handler(3462) #3 /home/wordpress-sites/######/httpdocs/wp/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters(NULL, Array) #4 /home/wordpress-sites/######/httpdocs/wp/wp-includes/plugin.php(478): WP_Hook->do_action(Array) #5 /home/wordpress-sites/######/httpdocs/wp/wp-includes/post.php(5815): do_action('delete_attachme...', 3462, Object(WP_Post)) #6 /home/wordpress-sites/######/httpd in /home/wordpress-sites/######/httpdocs/app/plugins/gt3-photo-video-gallery/core/class-watermark.php on line 200

    The WP_Filesystem_Direct class isn’t found (the rest of the site works without any problems).

    I ran a few tests in class-watermark.php and added the extra includes:

    require_once(ABSPATH.'wp-admin/includes/file.php');
    require_once(ABSPATH . '/wp-admin/includes/class-wp-filesystem-base.php');
    require_once(ABSPATH . '/wp-admin/includes/class-wp-filesystem-direct.p$
    require_once(ABSPATH . '/wp-includes/class-wp-error.php');
    WP_Filesystem();

    This seemed to work, although I don’t see the problem on a local developer copy of the website. The admin file.php include works as function_exists('WP_Filesystem'); returns true.

    Can you please advise what the issue may be here?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author gt3themes

    (@gt3themes)

    @alexholsgrove Hi there! The issue happens because of this path /app/plugins/ the standard WP directory is /wp-content/plugins/

    Thread Starter Alexander

    (@alexholsgrove)

    Thanks for the reply @gt3themes. It’s not because of this I’m afraid because the site works fine when I run it on my local development area, using the same split WordPress core and “wp-content” directory. It’s a bedrock/roots inspired setup:

    ABSPATH is defined properly, and points to httpdocs/wp which is where we have the WordPress core (wp-admin, wp-includes etc). httpdocs/app/ is the WP content path.

    As I said, this isn’t an issue unless there are hardcoded paths in your plugin, rather than using the proper WP constants / methods?

    In your code, require_once(ABSPATH.'wp-admin/includes/file.php'); does point to the right location for us httpdocs/wp/wp-admin/includes/file.php. I am happy to provide further debugging output to help work out the problem.

    Thanks,
    Alex

    Plugin Author gt3themes

    (@gt3themes)

    It’s really odd that it works on your local environment but it doesn’t on your live website if you have the same configuration 🙁

    Plugin Author gt3themes

    (@gt3themes)

    Closing the thread

    Thread Starter Alexander

    (@alexholsgrove)

    Rather than closing, could you please offer any assistance in resolving the issue? We are happy to add any debug lines. The code is deployed through git so something else must be failing either at server level or with the plugin.

    Plugin Author gt3themes

    (@gt3themes)

    It would be much easier to communicate via email, can you please send your request to help at gt3themes dot com?
    The thing is that we could not replicate the issue on our end, that’s why it’s hard to debug the issue.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.