From 21a0b9508eb8354d8c549f6c39229d52ff00a745 Mon Sep 17 00:00:00 2001 From: davidcallizaya Date: Mon, 7 Aug 2017 13:02:26 -0400 Subject: [PATCH] HOR-3626 Moved laravel boot after ProcessMaker loads its evironment constants. (PATH_DATA for shared folder) --- bootstrap/app.php | 11 ++++------- config/app.php | 2 +- config/cache.php | 9 +++++++-- config/filesystems.php | 2 +- config/view.php | 3 ++- framework/src/Maveriks/WebApplication.php | 5 +++++ tests/CreatesApplication.php | 8 +++++--- tests/TestCase.php | 5 +++-- workflow/engine/classes/class.wsTools.php | 8 ++++---- workflow/engine/classes/model/Translation.php | 2 +- workflow/engine/controllers/installer.php | 4 ++-- workflow/public_html/app.php | 7 +++---- workflow/public_html/sysGeneric.php | 14 ++++++++++++++ 13 files changed, 52 insertions(+), 28 deletions(-) diff --git a/bootstrap/app.php b/bootstrap/app.php index 7833d2fa6..0bb6d3f62 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -12,12 +12,9 @@ */ $app = new Illuminate\Foundation\Application( - realpath(__DIR__.'/../') + realpath(__DIR__ . '/../') ); -// Change storage path -$app->useStoragePath(realpath(__DIR__.'/../shared/')); - /* |-------------------------------------------------------------------------- | Bind Important Interfaces @@ -44,11 +41,11 @@ $app->singleton( Illuminate\Foundation\Exceptions\Handler::class ); -$app->configureMonologUsing(function($monolog) use ($app) { +$app->configureMonologUsing(function ($monolog) use ($app) { $monolog->pushHandler( (new Monolog\Handler\RotatingFileHandler( // Set the log path - $app->storagePath().'/logs/processmaker.log', + $app->storagePath() . '/logs/processmaker.log', // Set the number of daily files you want to keep $app->make('config')->get('app.log_max_files', 5) ))->setFormatter(new Monolog\Formatter\LineFormatter(null, null, true, true)) @@ -66,4 +63,4 @@ $app->configureMonologUsing(function($monolog) use ($app) { | */ -return $app; \ No newline at end of file +return $app; diff --git a/config/app.php b/config/app.php index 4c4ffe79c..744aa911a 100644 --- a/config/app.php +++ b/config/app.php @@ -16,4 +16,4 @@ return [ 'aliases' => [ ], -]; \ No newline at end of file +]; diff --git a/config/cache.php b/config/cache.php index 500fa675c..5529d9a1f 100644 --- a/config/cache.php +++ b/config/cache.php @@ -56,8 +56,13 @@ return [ env('MEMCACHED_USERNAME'), env('MEMCACHED_PASSWORD'), ], + /** + * Memcached options, example: + * Memcached::OPT_CONNECT_TIMEOUT => 2000, + * + * @link http://php.net/manual/en/memcached.constants.php + */ 'options' => [ - // Memcached::OPT_CONNECT_TIMEOUT => 2000, ], 'servers' => [ [ @@ -88,4 +93,4 @@ return [ 'prefix' => 'processmaker', -]; \ No newline at end of file +]; diff --git a/config/filesystems.php b/config/filesystems.php index d215e5abd..4544f60c4 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -65,4 +65,4 @@ return [ ], -]; \ No newline at end of file +]; diff --git a/config/view.php b/config/view.php index 5f09ea326..6064ca556 100644 --- a/config/view.php +++ b/config/view.php @@ -1,4 +1,5 @@ realpath(storage_path('framework/views')), -]; \ No newline at end of file +]; diff --git a/framework/src/Maveriks/WebApplication.php b/framework/src/Maveriks/WebApplication.php index 8625042a5..6af32cd75 100644 --- a/framework/src/Maveriks/WebApplication.php +++ b/framework/src/Maveriks/WebApplication.php @@ -5,6 +5,7 @@ use Maveriks\Util; use ProcessMaker\Services; use ProcessMaker\Services\Api; use Luracast\Restler\RestException; +use Illuminate\Foundation\Http\Kernel; /** * Web application bootstrap @@ -476,6 +477,10 @@ class WebApplication define("PATH_TEMPORAL", PATH_C . "dynEditor/"); define("PATH_DB", PATH_DATA . "sites" . PATH_SEP); + // Change storage path + app()->useStoragePath(realpath(PATH_DATA)); + app()->make(Kernel::class)->bootstrap(); + \Bootstrap::setLanguage(); \Bootstrap::LoadTranslationObject((defined("SYS_LANG"))? SYS_LANG : "en"); diff --git a/tests/CreatesApplication.php b/tests/CreatesApplication.php index 5ca8d2599..1f6324863 100644 --- a/tests/CreatesApplication.php +++ b/tests/CreatesApplication.php @@ -1,6 +1,8 @@ make(Kernel::class)->bootstrap(); return $app; } -} \ No newline at end of file +} diff --git a/tests/TestCase.php b/tests/TestCase.php index 2b55471c5..0e61740a2 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -1,8 +1,9 @@ Update framework paths...\n"); - $this->updatingFrameworkPaths($workSpace); + $this->updateFrameworkPaths($workSpace); $stop = microtime(true); CLI::logging("<*> Update framework paths took " . ($stop - $start) . " seconds.\n"); } @@ -3909,17 +3909,17 @@ class workspaceTools * Updating framework directory structure * */ - private function updatingFrameworkPaths($workSpace = SYS_SYS) + private function updateFrameworkPaths($workSpace = SYS_SYS) { $paths = [ PATH_DATA.'framework' => 0770, - PATH_DATA.'framework'.DIRECTORY_SEPARATOR.'cache' => 0770, + PATH_DATA.'framework' . DIRECTORY_SEPARATOR.'cache' => 0770, ]; foreach ($paths as $path => $permission) { if (!file_exists($path)) { G::mk_dir($path, $permission); } - CLI::logging(" $path [".(file_exists($path) ? 'OK' : 'MISSING')."]\n"); + CLI::logging(" $path [" . (file_exists($path) ? 'OK' : 'MISSING') . "]\n"); } } } diff --git a/workflow/engine/classes/model/Translation.php b/workflow/engine/classes/model/Translation.php index c1e643baf..b4cc04ba0 100644 --- a/workflow/engine/classes/model/Translation.php +++ b/workflow/engine/classes/model/Translation.php @@ -285,7 +285,7 @@ class Translation extends BaseTranslation /* Load strings from plugin translation.php. * @parameter $languageId (es|en|...). */ - public function generateFileTranslationPlugin ($plugin, $languageId = '') + public static function generateFileTranslationPlugin ($plugin, $languageId = '') { if (!file_exists(PATH_PLUGINS . $plugin . PATH_SEP . 'translations' . PATH_SEP . 'translations.php')) { return; diff --git a/workflow/engine/controllers/installer.php b/workflow/engine/controllers/installer.php index d47d26c56..e5fc7deac 100644 --- a/workflow/engine/controllers/installer.php +++ b/workflow/engine/controllers/installer.php @@ -1749,8 +1749,8 @@ class Installer extends Controller private function verifySharedFrameworkPaths($sharedPath) { $paths = [ - $sharedPath.'framework' => 0770, - $sharedPath.'framework'.DIRECTORY_SEPARATOR.'cache' => 0770, + $sharedPath . 'framework' => 0770, + $sharedPath . 'framework' . DIRECTORY_SEPARATOR . 'cache' => 0770, ]; foreach ($paths as $path => $permission) { if (!file_exists($path)) { diff --git a/workflow/public_html/app.php b/workflow/public_html/app.php index df1133fc0..cb97f2ea2 100644 --- a/workflow/public_html/app.php +++ b/workflow/public_html/app.php @@ -2,10 +2,9 @@ use Illuminate\Foundation\Http\Kernel; // Because laravel has a __ helper function, it's important we include the class.g file to ensure our __ is used. -require_once __DIR__.'/../../gulliver/system/class.g.php'; -require_once __DIR__.'/../../bootstrap/autoload.php'; -require_once __DIR__.'/../../bootstrap/app.php'; -$app->make(Kernel::class)->bootstrap(); +require_once __DIR__ . '/../../gulliver/system/class.g.php'; +require_once __DIR__ . '/../../bootstrap/autoload.php'; +require_once __DIR__ . '/../../bootstrap/app.php'; register_shutdown_function( diff --git a/workflow/public_html/sysGeneric.php b/workflow/public_html/sysGeneric.php index d2da8912b..0b07f9f67 100644 --- a/workflow/public_html/sysGeneric.php +++ b/workflow/public_html/sysGeneric.php @@ -22,6 +22,8 @@ * Coral Gables, FL, 33134, USA, or email info@colosa.com. */ +use Illuminate\Foundation\Http\Kernel; + /** * bootstrap - ProcessMaker Bootstrap * this file is used initialize main variables, redirect and dispatch all requests @@ -546,6 +548,18 @@ if (! defined( 'PATH_DATA' ) || ! file_exists( PATH_DATA )) { die(); } +app()->useStoragePath(realpath(PATH_DATA)); +app()->make(Kernel::class)->bootstrap(); +//Overwrite with the Processmaker env.ini configuration used in production environments +//@todo: move env.ini configuration to .env +ini_set( 'display_errors', $config['display_errors']); +ini_set( 'error_reporting', $config['error_reporting']); +ini_set( 'short_open_tag', 'On' ); +ini_set( 'default_charset', "UTF-8" ); +ini_set( 'memory_limit', $config['memory_limit'] ); +ini_set( 'soap.wsdl_cache_enabled', $config['wsdl_cache'] ); +ini_set('date.timezone', $config['time_zone']); //Set Time Zone + // Load Language Translation Bootstrap::LoadTranslationObject( defined( 'SYS_LANG' ) ? SYS_LANG : "en" );