wp_content_dir creating error
-
WordPress: 6.4.2
PHP: 8.2 FPM (via Docker)
Visualizer plugin: 3.10.4I’m in the middle of migrating my WordPress site to Docker, and I’ll be using nginx for this. (Existing site is using Apache2.) And I was getting a rather interesting error:
NOTICE: PHP message: PHP Fatal error: Uncaught TypeError: ftp_nlist(): Argument #1 ($ftp) must be of type FTP\Connection, null given in /usr/share/nginx/wordpress/wp-admin/includes/class-wp-filesystem-ftpext.php:438
Here’s the stacktrace:
Stack trace: #0 /usr/share/nginx/wordpress/wp-admin/includes/class-wp-filesystem-ftpext.php(438): ftp_nlist() #1 /usr/share/nginx/wordpress/wp-admin/includes/class-wp-filesystem-base.php(231): WP_Filesystem_FTPext->exists() #2 /usr/share/nginx/wordpress/wp-admin/includes/class-wp-filesystem-base.php(79): WP_Filesystem_Base->find_folder() #3 /usr/share/nginx/wordpress/wp-content/plugins/visualizer/classes/Visualizer/Module.php(532): WP_Filesystem_Base->wp_content_dir() #4 /usr/share/nginx/wordpress/wp-content/plugins/visualizer/classes/Visualizer/Module/Frontend.php(274): Visualizer_Module->get_user_customization_js() #5 /usr/share/nginx/wordpress/wp-includes/class-wp-hook.php(324): Visualizer_Module_Frontend->enqueueScripts() #6 /usr/share/nginx/wordpress/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() #7 /usr/share/nginx/wordpress/wp-includes/plugin.php(517): WP_Hook->do_action() #8 /usr/share/nginx/wordpress/wp-includes/script-loader.php(2262): do_action() #9 /usr/share/nginx/wordpress/wp-includes/class-wp-hook.php(324): wp_enqueue_scripts() #10 /usr/share/nginx/wordpress/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() #11 /usr/share/nginx/wordpress/wp-includes/plugin.php(517): WP_Hook->do_action() #12 /usr/share/nginx/wordpress/wp-includes/general-template.php(3052): do_action() #13 /usr/share/nginx/wordpress/wp-content/themes/graphy/header.php(15): wp_head() #14 /usr/share/nginx/wordpress/wp-includes/template.php(790): require_once('/usr/share/nginx/wordpress/wp-content/themes/graphy/header.php') #15 /usr/share/nginx/wordpress/wp-includes/template.php(725): load_template() #16 /usr/share/nginx/wordpress/wp-includes/general-template.php(48): locate_template() #17 /usr/share/nginx/wordpress/wp-content/themes/graphy/home.php(10): get_header() #18 /usr/share/nginx/wordpress/wp-includes/template-loader.php(106): include('/usr/share/nginx/wordpress/wp-content/themes/graphy/home.php') #19 /usr/share/nginx/wordpress/wp-blog-header.php(19): require_once('/usr/share/nginx/wordpress/wp-includes/template-loader.php') #20 /usr/share/nginx/wordpress/index.php(17): require('/usr/share/nginx/wordpress/wp-blog-header.php') #21 {main} thrown in /usr/share/nginx/wordpress/wp-admin/includes/class-wp-filesystem-ftpext.php on line 438
In going through the plugin’s code with the stack trace above, I believe the issue is your call to this method:
WP_Filesystem_Base::wp_content_dir()
. This method is called on lines 532 and 533 ofclasses/Visualizer/Module.php
. Changing these lines to useWP_CONTENT_DIR
alleviated the error.And in searching the code to the other plugins I have installed, it appears yours is the only one (of my set, at least) using the
wp_content_dir()
method to get the content directory path. You should change that to use theWP_CONTENT_DIR
variable directly instead since there appears to be an issue with the wp_content_dir method on some setups. I am not seeing any adverse side-effects with the plugin with that change.
- The topic ‘wp_content_dir creating error’ is closed to new replies.