From c8e3c7ae682db5c8c14cabaeec332e2d28bb215a Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 23 Mar 2020 07:45:16 +1100 Subject: [PATCH] Fix regression where .env file was being deleted erroneously (#3515) * Fixes for tests * Fixes for self updates --- app/Console/Commands/ArtisanUpgrade.php | 18 ++++++++---------- app/Models/CompanyGateway.php | 2 +- app/PaymentDrivers/StripePaymentDriver.php | 2 +- app/Utils/Ninja.php | 2 +- app/Utils/SystemHealth.php | 4 ++-- 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/app/Console/Commands/ArtisanUpgrade.php b/app/Console/Commands/ArtisanUpgrade.php index 405fe4675c..7b3f4f9a47 100644 --- a/app/Console/Commands/ArtisanUpgrade.php +++ b/app/Console/Commands/ArtisanUpgrade.php @@ -41,16 +41,6 @@ class ArtisanUpgrade extends Command public function handle() { set_time_limit(0); - // Composer\Factory::getHomeDir() method - // needs COMPOSER_HOME environment variable set - putenv('COMPOSER_HOME=' . __DIR__ . '/vendor/bin/composer'); - - // call `composer install` command programmatically - $input = new ArrayInput(array('command' => 'install')); - $application = new Application(); - //$application->setAutoExit(false); // prevent `$application->run` method from exitting the script - $application->run($input); - try { Artisan::call('migrate'); @@ -69,5 +59,13 @@ class ArtisanUpgrade extends Command } catch (Exception $e) { \Log::error("I wasn't able to restart the queue"); } + + + putenv('COMPOSER_HOME=' . __DIR__ . '/vendor/bin/composer'); + $input = new ArrayInput(array('command' => 'install')); + $application = new Application(); + //$application->setAutoExit(false); // prevent `$application->run` method from exitting the script + $application->run($input); + } } diff --git a/app/Models/CompanyGateway.php b/app/Models/CompanyGateway.php index 26ece66450..5f656f95ec 100644 --- a/app/Models/CompanyGateway.php +++ b/app/Models/CompanyGateway.php @@ -196,7 +196,7 @@ class CompanyGateway extends BaseModel */ public function getPublishableKey() :string { - return $this->getConfigField('publishable_key'); + return $this->getConfigField('publishableKey'); } /** diff --git a/app/PaymentDrivers/StripePaymentDriver.php b/app/PaymentDrivers/StripePaymentDriver.php index 80ecda1d31..f6dea8a96e 100644 --- a/app/PaymentDrivers/StripePaymentDriver.php +++ b/app/PaymentDrivers/StripePaymentDriver.php @@ -59,7 +59,7 @@ class StripePaymentDriver extends BasePaymentDriver */ public function init() :void { - Stripe::setApiKey($this->company_gateway->getConfigField('23_apiKey')); + Stripe::setApiKey($this->company_gateway->getConfigField('apiKey')); } /** diff --git a/app/Utils/Ninja.php b/app/Utils/Ninja.php index 2418f21886..37996af83b 100644 --- a/app/Utils/Ninja.php +++ b/app/Utils/Ninja.php @@ -64,7 +64,7 @@ class Ninja $data = trim(CurlUtils::post('https://license.invoiceninja.com/api/check', $data)); $data = json_decode($data); - if ($data->message == sha1(config('ninja.license'))) { + if ($data && property_exists($data, 'message') && $data->message == sha1(config('ninja.license'))) { return false; } else { return true; diff --git a/app/Utils/SystemHealth.php b/app/Utils/SystemHealth.php index 91fa0c83d8..349d0661d5 100644 --- a/app/Utils/SystemHealth.php +++ b/app/Utils/SystemHealth.php @@ -55,7 +55,6 @@ class SystemHealth 'dbs' => self::dbCheck(), 'mail' => self::testMailServer(), 'env_writable' => self::checkEnvWritable(), - 'env_exists' ]; } @@ -122,6 +121,7 @@ class SystemHealth private static function checkEnvWritable() { - return @fopen(base_path().'/.env', 'w'); + return is_writable(base_path().'/.env'); + //return @fopen(base_path().'/.env', 'w'); } }