Merge remote-tracking branch 'origin/feature/HOR-3559' into feature/HOR-3629

This commit is contained in:
Ronald Quenta
2017-08-10 22:01:13 -04:00
19 changed files with 2959 additions and 496 deletions

76
bootstrap/app.php Normal file
View File

@@ -0,0 +1,76 @@
<?php
use Illuminate\Contracts\Console\Kernel as Kernel2;
use Illuminate\Contracts\Debug\ExceptionHandler;
use Illuminate\Contracts\Http\Kernel as Kernel4;
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Console\Kernel;
use Illuminate\Foundation\Exceptions\Handler;
use Illuminate\Foundation\Http\Kernel as Kernel3;
use Monolog\Formatter\LineFormatter;
use Monolog\Handler\RotatingFileHandler;
/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| The first thing we will do is create a new Laravel application instance
| which serves as the "glue" for all the components of Laravel, and is
| the IoC container for the system binding all of the various parts.
|
*/
$app = new Application(
realpath(__DIR__ . '/../')
);
/*
|--------------------------------------------------------------------------
| Bind Important Interfaces
|--------------------------------------------------------------------------
|
| Next, we need to bind some important interfaces into the container so
| we will be able to resolve them when needed. The kernels serve the
| incoming requests to this application from both the web and CLI.
|
*/
$app->singleton(
Kernel4::class,
Kernel3::class
);
$app->singleton(
Kernel2::class,
Kernel::class
);
$app->singleton(
ExceptionHandler::class,
Handler::class
);
$app->configureMonologUsing(function ($monolog) use ($app) {
$monolog->pushHandler(
(new RotatingFileHandler(
// Set the log path
$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 LineFormatter(null, null, true, true))
);
});
/*
|--------------------------------------------------------------------------
| Return The Application
|--------------------------------------------------------------------------
|
| This script returns the application instance. The instance is given to
| the calling script so we can separate the building of the instances
| from the actual running of the application and sending responses.
|
*/
return $app;

2
bootstrap/cache/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
*
!.gitignore

View File

@@ -27,6 +27,7 @@
"minimum-stability": "dev", "minimum-stability": "dev",
"prefer-stable": true, "prefer-stable": true,
"require": { "require": {
"laravel/framework": "5.4.*",
"luracast/restler": "^3.0", "luracast/restler": "^3.0",
"bshaffer/oauth2-server-php": "v1.0", "bshaffer/oauth2-server-php": "v1.0",
"colosa/pmUI": "develop-dev", "colosa/pmUI": "develop-dev",
@@ -46,7 +47,7 @@
}, },
"require-dev": { "require-dev": {
"guzzle/guzzle": "~3.1.1", "guzzle/guzzle": "~3.1.1",
"behat/behat": "2.4.*@stable" "phpunit/phpunit": "~5.7"
}, },
"autoload": { "autoload": {
"psr-0": { "psr-0": {
@@ -78,5 +79,10 @@
"thirdparty/HTMLPurifier/HTMLPurifier.auto.php", "thirdparty/HTMLPurifier/HTMLPurifier.auto.php",
"workflow/engine/classes/class.pmFunctions.php" "workflow/engine/classes/class.pmFunctions.php"
] ]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
} }
} }

2958
composer.lock generated

File diff suppressed because it is too large Load Diff

23
config/app.php Normal file
View File

@@ -0,0 +1,23 @@
<?php
use Illuminate\Cache\CacheServiceProvider;
use Illuminate\Filesystem\FilesystemServiceProvider;
use Illuminate\View\ViewServiceProvider;
return [
'name' => env('APP_NAME', 'ProcessMaker'),
'env' => env('APP_ENV', 'production'),
'debug' => env('APP_DEBUG', false),
'log' => env('APP_LOG', 'single'),
'log_level' => env('APP_LOG_LEVEL', 'debug'),
'providers' => [
FilesystemServiceProvider::class,
CacheServiceProvider::class,
ViewServiceProvider::class,
],
'aliases' => [
],
];

96
config/cache.php Normal file
View File

@@ -0,0 +1,96 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Cache Store
|--------------------------------------------------------------------------
|
| This option controls the default cache connection that gets used while
| using this caching library. This connection is used when another is
| not explicitly specified when executing a given caching function.
|
| Supported: "apc", "array", "database", "file", "memcached", "redis"
|
*/
'default' => env('CACHE_DRIVER', 'file'),
/*
|--------------------------------------------------------------------------
| Cache Stores
|--------------------------------------------------------------------------
|
| Here you may define all of the cache "stores" for your application as
| well as their drivers. You may even define multiple stores for the
| same cache driver to group types of items stored in your caches.
|
*/
'stores' => [
'apc' => [
'driver' => 'apc',
],
'array' => [
'driver' => 'array',
],
'database' => [
'driver' => 'database',
'table' => 'cache',
'connection' => null,
],
'file' => [
'driver' => 'file',
'path' => storage_path('framework/cache/data'),
],
'memcached' => [
'driver' => 'memcached',
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
'sasl' => [
env('MEMCACHED_USERNAME'),
env('MEMCACHED_PASSWORD'),
],
/**
* Memcached options, example:
* Memcached::OPT_CONNECT_TIMEOUT => 2000,
*
* @link http://php.net/manual/en/memcached.constants.php
*/
'options' => [
],
'servers' => [
[
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
'port' => env('MEMCACHED_PORT', 11211),
'weight' => 100,
],
],
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
],
],
/*
|--------------------------------------------------------------------------
| Cache Key Prefix
|--------------------------------------------------------------------------
|
| When utilizing a RAM based store such as APC or Memcached, there might
| be other applications utilizing the same cache. So, we'll specify a
| value to get prefixed to all our keys so we can avoid collisions.
|
*/
'prefix' => 'processmaker',
];

68
config/filesystems.php Normal file
View File

@@ -0,0 +1,68 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Filesystem Disk
|--------------------------------------------------------------------------
|
| Here you may specify the default filesystem disk that should be used
| by the framework. The "local" disk, as well as a variety of cloud
| based disks are available to your application. Just store away!
|
*/
'default' => env('FILESYSTEM_DRIVER', 'local'),
/*
|--------------------------------------------------------------------------
| Default Cloud Filesystem Disk
|--------------------------------------------------------------------------
|
| Many applications store files both locally and in the cloud. For this
| reason, you may specify a default "cloud" driver here. This driver
| will be bound as the Cloud disk implementation in the container.
|
*/
'cloud' => env('FILESYSTEM_CLOUD', 's3'),
/*
|--------------------------------------------------------------------------
| Filesystem Disks
|--------------------------------------------------------------------------
|
| Here you may configure as many filesystem "disks" as you wish, and you
| may even configure multiple disks of the same driver. Defaults have
| been setup for each driver as an example of the required options.
|
| Supported Drivers: "local", "ftp", "s3", "rackspace"
|
*/
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL') . '/storage',
'visibility' => 'public',
],
's3' => [
'driver' => 's3',
'key' => env('AWS_KEY'),
'secret' => env('AWS_SECRET'),
'region' => env('AWS_REGION'),
'bucket' => env('AWS_BUCKET'),
],
],
];

28
config/view.php Normal file
View File

@@ -0,0 +1,28 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| View Storage Paths
|--------------------------------------------------------------------------
|
| Most templating systems load templates from disk. Here you may specify
| an array of paths that should be checked for your views. Of course
| the usual Laravel view path has already been registered for you.
|
*/
'paths' => [
resource_path('views'),
],
/*
|--------------------------------------------------------------------------
| Compiled View Path
|--------------------------------------------------------------------------
|
| This option determines where all the compiled Blade templates will be
| stored for your application. Typically, this is within the storage
| directory. However, as usual, you are free to change this value.
|
*/
'compiled' => realpath(storage_path('framework/views')),
];

View File

@@ -6,6 +6,7 @@ use ProcessMaker\Plugins\PluginRegistry;
use ProcessMaker\Services; use ProcessMaker\Services;
use ProcessMaker\Services\Api; use ProcessMaker\Services\Api;
use Luracast\Restler\RestException; use Luracast\Restler\RestException;
use Illuminate\Foundation\Http\Kernel;
/** /**
* Web application bootstrap * Web application bootstrap
@@ -478,6 +479,10 @@ class WebApplication
define("PATH_TEMPORAL", PATH_C . "dynEditor/"); define("PATH_TEMPORAL", PATH_C . "dynEditor/");
define("PATH_DB", PATH_DATA . "sites" . PATH_SEP); define("PATH_DB", PATH_DATA . "sites" . PATH_SEP);
// Change storage path
app()->useStoragePath(realpath(PATH_DATA));
app()->make(Kernel::class)->bootstrap();
\Bootstrap::setLanguage(); \Bootstrap::setLanguage();
\Bootstrap::LoadTranslationObject((defined("SYS_LANG"))? SYS_LANG : "en"); \Bootstrap::LoadTranslationObject((defined("SYS_LANG"))? SYS_LANG : "en");

View File

@@ -1,55 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false" <phpunit backupGlobals="false"
backupStaticAttributes="false" backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true" colors="true"
convertErrorsToExceptions="true" convertErrorsToExceptions="true"
convertNoticesToExceptions="true" convertNoticesToExceptions="true"
convertWarningsToExceptions="true" convertWarningsToExceptions="true"
processIsolation="false" processIsolation="false"
stopOnFailure="true" stopOnFailure="false">
syntaxCheck="true" <testsuites>
bootstrap="tests/bootstrap.php" <testsuite name="Feature">
> <directory suffix="Test.php">./tests/Feature</directory>
<testsuites> </testsuite>
<testsuite name="automated">
<directory>./tests/automated/</directory>
</testsuite>
<!--
<testsuite name="unit">
<directory>./tests/unit/</directory>
</testsuite>
-->
<testsuite name="api">
<directory>./workflow/engine/src/</directory>
</testsuite>
</testsuites>
<!-- <filter> <testsuite name="Unit">
<whitelist> <directory suffix="Test.php">./tests/Unit</directory>
<directory>./</directory> </testsuite>
<exclude> </testsuites>
<directory>./gulliver</directory> <filter>
<directory>./workflow</directory> <whitelist processUncoveredFilesFromWhitelist="true">
<directory>./rbac</directory> <directory suffix=".php">./app</directory>
</exclude> </whitelist>
</whitelist> </filter>
</filter> --> <php>
<env name="APP_ENV" value="testing"/>
<php> <env name="CACHE_DRIVER" value="array"/>
<var name="SYS_SYS" value="os" /> </php>
<var name="SYS_LANG" value="en" />
<var name="SYS_SKIN" value="classic" />
<var name="zDB_ADAPTER" value="mysql" />
<var name="zDB_HOST" value="localhost" />
<var name="zDB_NAME" value="wf_os" />
<var name="zDB_USER" value="root" />
<var name="zDB_PASS" value="password" />
<var name="PATH_DB" value="/shared/workflow_data/sites/" />
<var name="PATH_DATA" value="/shared/workflow_data/sites/" />
</php>
<logging>
<log type="junit" target="build/logs/junit.xml" logIncompleteSkipped="false"/>
</logging>
</phpunit> </phpunit>

View File

@@ -1,7 +1,14 @@
#!/usr/bin/env php #!/usr/bin/env php
<?php <?php
use Illuminate\Foundation\Console\Kernel;
$scriptDir = dirname(__FILE__).'/'; // 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();
$scriptDir = dirname(__FILE__).'/';
define("PROCESSMAKER_PATH", $scriptDir); define("PROCESSMAKER_PATH", $scriptDir);
define("WORKFLOW_PATH", $scriptDir . 'workflow/'); define("WORKFLOW_PATH", $scriptDir . 'workflow/');

View File

@@ -0,0 +1,19 @@
<?php
namespace tests;
use Illuminate\Contracts\Console\Kernel;
trait CreatesApplication
{
/**
* Creates the application.
*
* @return \Illuminate\Foundation\Application
*/
public function createApplication()
{
$app = require __DIR__ . '/../bootstrap/app.php';
$app->make(Kernel::class)->bootstrap();
return $app;
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace Tests\Feature;
use Illuminate\Support\Facades\Cache;
use Tests\TestCase;
class CacheTest extends TestCase
{
/**
* A basic cache example.
*
* @return void
*/
public function testCache()
{
Cache::put('foo', 'bar', 5);
$this->assertEquals('bar', (Cache::get('foo')));
}
}

9
tests/TestCase.php Normal file
View File

@@ -0,0 +1,9 @@
<?php
namespace tests;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
use CreatesApplication;
}

View File

@@ -201,6 +201,12 @@ class workspaceTools
$stop = microtime(true); $stop = microtime(true);
CLI::logging("<*> Updating rows in Web Entry table for classic processes took " . ($stop - $start) . " seconds.\n"); CLI::logging("<*> Updating rows in Web Entry table for classic processes took " . ($stop - $start) . " seconds.\n");
$start = microtime(true);
CLI::logging("> Update framework paths...\n");
$this->updateFrameworkPaths($workSpace);
$stop = microtime(true);
CLI::logging("<*> Update framework paths took " . ($stop - $start) . " seconds.\n");
$start = microtime(true); $start = microtime(true);
CLI::logging("> Migrating and populating plugin singleton data...\n"); CLI::logging("> Migrating and populating plugin singleton data...\n");
$this->migrateSingleton($workSpace); $this->migrateSingleton($workSpace);
@@ -3927,4 +3933,22 @@ class workspaceTools
CLI::logging(CLI::error("Error:" . "Error updating generated class files for PM Tables, proceed to regenerate manually: " . $e)); CLI::logging(CLI::error("Error:" . "Error updating generated class files for PM Tables, proceed to regenerate manually: " . $e));
} }
} }
/**
* Updating framework directory structure
*
*/
private function updateFrameworkPaths($workSpace = SYS_SYS)
{
$paths = [
PATH_DATA.'framework' => 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");
}
}
} }

View File

@@ -285,7 +285,7 @@ class Translation extends BaseTranslation
/* Load strings from plugin translation.php. /* Load strings from plugin translation.php.
* @parameter $languageId (es|en|...). * @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')) { if (!file_exists(PATH_PLUGINS . $plugin . PATH_SEP . 'translations' . PATH_SEP . 'translations.php')) {
return; return;

View File

@@ -321,10 +321,12 @@ class Installer extends Controller
if ($info->pathShared->result) { if ($info->pathShared->result) {
$info->pathShared->message = G::LoadTranslation('ID_WRITEABLE'); $info->pathShared->message = G::LoadTranslation('ID_WRITEABLE');
} else { } else {
//Verify and create the shared path
G::verifyPath( $_REQUEST['pathShared'], true ); G::verifyPath( $_REQUEST['pathShared'], true );
$info->pathShared->result = G::is_writable_r( $_REQUEST['pathShared'], $noWritableFiles ); $info->pathShared->result = G::is_writable_r( $_REQUEST['pathShared'], $noWritableFiles );
if ($info->pathShared->result) { if ($info->pathShared->result) {
$info->pathShared->message = G::LoadTranslation('ID_WRITEABLE'); $info->pathShared->message = G::LoadTranslation('ID_WRITEABLE');
$info->success = $this->verifySharedFrameworkPaths($_REQUEST['pathShared']);
} else { } else {
$info->success = false; $info->success = false;
} }
@@ -1739,4 +1741,25 @@ class Installer extends Controller
} }
} }
} }
/**
* Verify/create framework shared directory structure
*
*/
private function verifySharedFrameworkPaths($sharedPath)
{
$paths = [
$sharedPath . 'framework' => 0770,
$sharedPath . 'framework' . DIRECTORY_SEPARATOR . 'cache' => 0770,
];
foreach ($paths as $path => $permission) {
if (!file_exists($path)) {
G::mk_dir($path, $permission);
}
if (!file_exists($path)) {
return false;
}
}
return true;
}
} }

View File

@@ -1,5 +1,12 @@
<?php <?php
require_once(__DIR__ . '/../../bootstrap/autoload.php'); 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';
register_shutdown_function( register_shutdown_function(
create_function( create_function(
"", "",

View File

@@ -22,6 +22,7 @@
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/ */
use Illuminate\Foundation\Http\Kernel;
use ProcessMaker\Plugins\PluginRegistry; use ProcessMaker\Plugins\PluginRegistry;
/** /**
@@ -548,6 +549,18 @@ if (! defined( 'PATH_DATA' ) || ! file_exists( PATH_DATA )) {
die(); 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 // Load Language Translation
Bootstrap::LoadTranslationObject( defined( 'SYS_LANG' ) ? SYS_LANG : "en" ); Bootstrap::LoadTranslationObject( defined( 'SYS_LANG' ) ? SYS_LANG : "en" );