Support #16168
closedproblem with short docs site
0%
Description
When I go to short docs (https://shortdocs.commons.gc.cuny.edu/) I get the following error: There has been a critical error on this website. Looks like it is throwing strict-origin-when-cross-origin error.
Updated by Boone Gorges over 2 years ago
- Assignee changed from Boone Gorges to Raymond Hoh
Ray, can you have a look? Here's the stack trace:
Fatal error: Uncaught Error: Undefined class constant 'MAJOR_VERSION' in /var/www/html/commons/www/wp-content/plugins/two-factor-provider-webauthn/vendor/guzzlehttp/guzzle/src/Utils.php:113 Stack trace: #0 /var/www/html/commons/www/wp-content/plugins/two-factor-provider-webauthn/vendor/guzzlehttp/guzzle/src/functions.php(71): GuzzleHttp\Utils::defaultUserAgent() #1 /var/www/html/commons/www/wp-content/plugins/constant-contact-api/vendor/guzzlehttp/guzzle/src/Client.php(192): GuzzleHttp\default_user_agent() #2 /var/www/html/commons/www/wp-content/plugins/constant-contact-api/vendor/guzzlehttp/guzzle/src/Client.php(73): GuzzleHttp\Client->configureDefaults() #3 /var/www/html/commons/www/wp-content/plugins/constant-contact-api/vendor/constantcontact/constantcontact/src/Ctct/Auth/CtctOAuth2.php(27): GuzzleHttp\Client->__construct() #4 /var/www/html/commons/www/wp-content/plugins/constant-contact-api/classes/class.kwsoauth2.php(40): Ctct\Auth\CtctOAuth2->__construct() #5 /var/www/html/commons/www/wp-content/plugins/constant-co in /var/www/html/commons/www/wp-content/plugins/two-factor-provider-webauthn/vendor/guzzlehttp/guzzle/src/Utils.php on line 113
Updated by Raymond Hoh over 2 years ago
- Category name changed from WordPress (misc) to WordPress Plugins
- Status changed from New to Resolved
- Target version set to 2.0.1
The issue is the WebAuthn plugin is using Composer to include Guzzle 7.4.2: https://github.com/sjinks/wp-two-factor-provider-webauthn/blob/8d32177e7f68b120ab00de0be60dc9fdff3eaa46/composer.lock#L154-L155
And the Constant Contact API plugin is using Composer to include Guzzle 6.2.1: https://github.com/cuny-academic-commons/cac/blob/a073d2a5c9a2aa9c00fe851f9401eb14238ea508/wp-content/plugins/constant-contact-api/composer.lock#L69-L70
The problem is due to namespace collisions. See https://blog.anibalhsanchez.com/en/blogging/lost-and-found/79-about-3rd-party-dependency-conflicts-in-developing-wordpress-plugins.html and https://stackoverflow.com/a/68821865.
Since the Constant Contact API plugin hasn't been updated in awhile, I've chosen to change the namespaces in this plugin: https://github.com/cuny-academic-commons/cac/commit/00e151f5b6ee4f50a9c54a0232aef17443b4f96c. I tried a few tools from the StackOverflow article in an attempt to change the namespace, but Strauss ended up being the least destructive. After using Strauss to namespace the libraries, I changed the autoloader from Composer's to Strauss's one and altered the referenced libraries to use the new namespace.
I tested these changes on CDEV as well as my dev environment and everything seemed to work fine. Fix is also deployed on production.