From f27f2a7777d33a2b1ddc37f68e80be01709d5074 Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Wed, 27 Jun 2018 11:57:14 +1200 Subject: [PATCH] Update MaintenanceProxyExtension for use in CWP 1.9 --- _config/maintenance.yml | 2 +- .../extensions}/MaintenanceProxyExtension.php | 19 ++++--------------- 2 files changed, 5 insertions(+), 16 deletions(-) rename {src/Extensions => code/extensions}/MaintenanceProxyExtension.php (70%) diff --git a/_config/maintenance.yml b/_config/maintenance.yml index 1ad457cd..d4d04cf5 100644 --- a/_config/maintenance.yml +++ b/_config/maintenance.yml @@ -2,7 +2,7 @@ Name: maintenanceproxyextensions Before: updatecheckerextensions Only: - moduleexists: bringyourownideas/silverstripe-maintenance + moduleexists: silverstripe-maintenance --- BringYourOwnIdeas\Maintenance\Util\ComposerLoader: extensions: diff --git a/src/Extensions/MaintenanceProxyExtension.php b/code/extensions/MaintenanceProxyExtension.php similarity index 70% rename from src/Extensions/MaintenanceProxyExtension.php rename to code/extensions/MaintenanceProxyExtension.php index 3540b2e4..9fe10bc7 100644 --- a/src/Extensions/MaintenanceProxyExtension.php +++ b/code/extensions/MaintenanceProxyExtension.php @@ -2,13 +2,7 @@ namespace CWP\CWP\Extension; -use BringYourOwnIdeas\Maintenance\Reports\SiteSummary; -use SilverStripe\Core\Environment; -use SilverStripe\Core\Extension; - -if (!class_exists(SiteSummary::class)) { - return; -} +use Extension; /** * Used to configure proxy settings for bringyourownideas/silverstripe-maintenance and its related modules @@ -25,11 +19,6 @@ class MaintenanceProxyExtension extends Extension */ public function onAfterBuild() { - // Mock COMPOSER_HOME if it's not defined already. Composer requires one of the two to be set. - if (!Environment::getEnv('HOME') && !Environment::getEnv('COMPOSER_HOME')) { - putenv('COMPOSER_HOME=/tmp'); - } - // Provide access for Composer's StreamContextFactory, since it creates its own stream context if ($proxy = $this->getCwpProxy()) { $_SERVER['CGI_HTTP_PROXY'] = $proxy; @@ -56,14 +45,14 @@ public function updateClientOptions(&$options) */ protected function getCwpProxy() { - if (!Environment::getEnv('SS_OUTBOUND_PROXY') || !Environment::getEnv('SS_OUTBOUND_PROXY_PORT')) { + if (!defined('SS_OUTBOUND_PROXY') || !defined('SS_OUTBOUND_PROXY_PORT')) { return ''; } return sprintf( 'tcp://%s:%d', - Environment::getEnv('SS_OUTBOUND_PROXY'), - Environment::getEnv('SS_OUTBOUND_PROXY_PORT') + SS_OUTBOUND_PROXY, + SS_OUTBOUND_PROXY_PORT ); } }