• PHP Fatal error: Uncaught Error: Undefined class constant ‘VERSION’ in /var/www/html/wp-content/plugins/do-spaces-sync/vendor/aws/aws-sdk-php/src/functions.php:275

Viewing 1 replies (of 1 total)
  • Chris Ostmo

    (@appideasdotcom)

    This is due to other plugins loading GuzzleHttp version 7, whereas, this plugin only supports versions 5 and 6.

    It’s been a long time since we’ve seen an update to do-spaces-sync, so I’m not holding my breath for a fix.

    This two-part fix is likely to break, but it’s working for now:
    Part 1: In do-spaces-sync/vendor/aws/aws-sdk-php/functions.php, find the default_http_handler() function and replace it with this (or something like it):

    	$version = '6.3.3';
    	if( defined( 'ClientInterface::VERSION' ) ) {
    		$version = (string) ClientInterface::VERSION;
    	} else if( defined( 'ClientInterface::MAJOR_VERSION' ) ) {
    		$version = (string) ClientInterface::MAJOR_VERSION;
    	}
    
        if ($version[0] === '5') {
            return new \Aws\Handler\GuzzleV5\GuzzleHandler();
        }
    
        if ($version[0] === '6' || $version[0] === '7') {
            return new \Aws\Handler\GuzzleV6\GuzzleHandler();
        }
    
        throw new \RuntimeException('Unknown Guzzle version: ' . $version);

    Part 2: in do-spaces-sync/vendor/guzzlehttp/guzzle/src/functions.php, find the default_user_agent() function and replace it with:

    	static $defaultAgent = '';
    
    	$version = '6.3.3';
    	if( defined( 'Client::VERSION' ) ) {
    		$version = (string) Client::VERSION;
    	} else if( defined( 'Client::MAJOR_VERSION' ) ) {
    		$version = (string) Client::MAJOR_VERSION;
    	}
    
        if (!$defaultAgent) {
            $defaultAgent = 'GuzzleHttp/' . $version;
            if (extension_loaded('curl') && function_exists('curl_version')) {
                $defaultAgent .= ' curl/' . \curl_version()['version'];
            }
            $defaultAgent .= ' PHP/' . PHP_VERSION;
        }
    
        return $defaultAgent;

    Optional: To prevent your changes from being overwritten accidentally by an update, change the value of Version in do-spaces-sync/loader.php to something like 99.0.1

    Until do-spaces-sync is updated to support GuzzleHttp 7, this problem will persist.

    • This reply was modified 3 years, 1 month ago by Chris Ostmo.
    • This reply was modified 3 years, 1 month ago by Chris Ostmo. Reason: Formatting
Viewing 1 replies (of 1 total)
  • The topic ‘V. 2.2.1 PHP Fatal error: Uncaught Error: Undefined class constant ‘VERSI’ is closed to new replies.