internationaljack (@internationaljack)

Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • @internationaljack

    Participant

    Sure!

    	/**
    	 * Reads entire file into a string.
    	 *
    	 * @since 2.5.0
    	 *
    	 * @param string $file Name of the file to read.
    	 * @return string|false Read data on success, false if no temporary file could be opened,
    	 *                      or if the file couldn't be retrieved.
    	 */
    	public function get_contents( $file ) {
    		$tempfile   = wp_tempnam( $file );
    		$temphandle = fopen( $tempfile, 'w+' );
    
    		if ( ! $temphandle ) {
    			unlink( $tempfile );
    			return false;
    		}
    
    		if ( ! ftp_fget( $this->link, $temphandle, $file, FTP_BINARY ) ) {
    			fclose( $temphandle );
    			unlink( $tempfile );
    			return false;
    		}
    
    		fseek( $temphandle, 0 ); // Skip back to the start of the file being written to.
    		$contents = '';
    
    		while ( ! feof( $temphandle ) ) {
    			$contents .= fread( $temphandle, 8 * KB_IN_BYTES );
    		}
    
    		fclose( $temphandle );
    		unlink( $tempfile );
    
    		return $contents;
    	}

    Line 146 is if ( ! ftp_fget( $this->link, $temphandle, $file, FTP_BINARY ) ) {

    @internationaljack

    Participant

    Thank you for helping me interpret that!

    This is what was on that line:
    <p class="logo_tagline"><?php bloginfo(description); ?></p>

    I added single quotes to 'description' and now the forums fully load (when FS_METHOD is set to direct). That line was basically the only difference between the original bbpress.php and the child theme’s copy of bbpress.php.

    Unfortunately, that fix only works with FS_METHOD set to direct. I need it set to ftpext so WordPress requests FTP credentials (for things like plugin updates), because otherwise WP doesn’t have write permission.

    When I change FS_METHOD to ftpext, the forum pages start giving me the ol’ “There has been a critical error on this website” message.
    The log gives me this:
    [08-Aug-2025 17:23:55 UTC] PHP Fatal error: Uncaught TypeError: ftp_fget(): Argument #1 ($ftp) must be of type FTP\Connection, null given in /var/www/vhosts/[SITEURL]/httpdocs/wp-admin/includes/class-wp-filesystem-ftpext.php:146

    That’s not a bbPress file, so I think I’ll have to talk with our webhost about this.

    Thanks for your help!

    @internationaljack

    Participant

    When I try to access a forum, I only see the site header (the rest of the page is blank). This is what shows up in my debug.log:

    [07-Aug-2025 22:39:33 UTC] PHP Warning:  chmod(): Operation not permitted in /var/www/vhosts/[SITEURL]/httpdocs/wp-admin/includes/class-wp-filesystem-direct.php on line 173
    [07-Aug-2025 22:39:34 UTC] PHP Warning:  chmod(): Operation not permitted in /var/www/vhosts/[SITEURL]/httpdocs/wp-admin/includes/class-wp-filesystem-direct.php on line 173
    [07-Aug-2025 22:39:39 UTC] PHP Deprecated:  str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/vhosts/[SITEURL]/httpdocs/wp-content/themes/Avada/includes/class-avada-layout-bbpress.php on line 219
    [07-Aug-2025 22:39:39 UTC] PHP Deprecated:  str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/vhosts/[SITEURL]/httpdocs/wp-content/themes/Avada/includes/class-avada-layout-bbpress.php on line 219
    [07-Aug-2025 22:39:39 UTC] PHP Fatal error:  Uncaught Error: Undefined constant "description" in /var/www/vhosts/[SITEURL]/httpdocs/wp-content/themes/Avada-Child-Theme/bbpress.php:22
    Stack trace:
    #0 /var/www/vhosts/[SITEURL]/httpdocs/wp-includes/template-loader.php(106): include()
    #1 /var/www/vhosts/[SITEURL]/httpdocs/wp-blog-header.php(19): require_once('/var/www/vhosts...')
    #2 /var/www/vhosts/[SITEURL]/httpdocs/index.php(17): require('/var/www/vhosts...')
    #3 {main}
      thrown in /var/www/vhosts/[SITEURL]/httpdocs/wp-content/themes/Avada-Child-Theme/bbpress.php on line 22
    [07-Aug-2025 22:39:39 UTC] PHP Warning:  chmod(): Operation not permitted in /var/www/vhosts/[SITEURL]/httpdocs/wp-admin/includes/class-wp-filesystem-direct.php on line 173
    [07-Aug-2025 22:39:47 UTC] PHP Warning:  chmod(): Operation not permitted in /var/www/vhosts/[SITEURL]/httpdocs/wp-admin/includes/class-wp-filesystem-direct.php on line 173

    The above is with this in wp-config.php:
    define('FS_METHOD', 'direct');

    Our sites are normally set to define('FS_METHOD', 'ftpext'); but that produces a much longer error string in the log and a “this site has experienced a critical error” message in the browser.

    Our prod site is on PHP 7.4.33 and doesn’t have any issues in either FS_METHOD mode. Did PHP 8 change something that affected filesystem access?

    Notes:
    – This is a multisite with a bbPress forum on almost all sites.
    – Our theme, Avada, runs fine on our other dev site with PHP 8.4.

Viewing 3 replies - 1 through 3 (of 3 total)