Skip to content

Commit a7bbbaa

Browse files
committed
Merge branch 'develop' into poc/FOUR-22888-Multitenancy
2 parents 2be1294 + cf3462a commit a7bbbaa

20 files changed

Lines changed: 10268 additions & 836 deletions

File tree

‎ProcessMaker/Cache/AbstractCacheFactory.php‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
abstract class AbstractCacheFactory implements CacheFactoryInterface
1111
{
1212
protected static ?CacheInterface $testInstance = null;
13+
protected static bool $storeMetrics = true;
1314

1415
/**
1516
* Set a test instance for the factory
@@ -38,7 +39,11 @@ public static function create(CacheManager $cacheManager, CacheMetricsInterface
3839
$cache = static::createInstance($cacheManager);
3940

4041
// Wrap with metrics decorator
41-
return new CacheMetricsDecorator($cache, $metrics);
42+
if (static::$storeMetrics) {
43+
return new CacheMetricsDecorator($cache, $metrics);
44+
}
45+
46+
return $cache;
4247
}
4348

4449
/**

‎ProcessMaker/Cache/Settings/SettingCacheFactory.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
class SettingCacheFactory extends AbstractCacheFactory
1010
{
11+
protected static bool $storeMetrics = false;
12+
1113
/**
1214
* Create the specific settings cache instance
1315
*

‎ProcessMaker/Console/Kernel.php‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,37 @@ protected function schedule(Schedule $schedule)
4444

4545
$schedule->command('cache:metrics --format=json > storage/logs/processmaker-cache-metrics.json')
4646
->daily();
47+
48+
$clearInterval = config('metrics.clear_interval', 10);
49+
switch ((int) $clearInterval) {
50+
case 1:
51+
$schedule->command('metrics:clear')->everyMinute();
52+
break;
53+
case 2:
54+
$schedule->command('metrics:clear')->everyTwoMinutes();
55+
break;
56+
case 5:
57+
$schedule->command('metrics:clear')->everyFiveMinutes();
58+
break;
59+
case 10:
60+
$schedule->command('metrics:clear')->everyTenMinutes();
61+
break;
62+
case 15:
63+
$schedule->command('metrics:clear')->everyFifteenMinutes();
64+
break;
65+
case 30:
66+
$schedule->command('metrics:clear')->everyThirtyMinutes();
67+
break;
68+
case 60:
69+
$schedule->command('metrics:clear')->hourly();
70+
break;
71+
case 1440:
72+
$schedule->command('metrics:clear')->daily();
73+
break;
74+
default:
75+
$schedule->command('metrics:clear')->cron("*/{$clearInterval} * * * *");
76+
break;
77+
}
4778
}
4879

4980
/**

‎ProcessMaker/Http/Controllers/Api/TaskController.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ public function update(Request $request, ProcessRequestToken $task)
324324
return abort(422, __('Task already closed'));
325325
}
326326
// Skip ConvertEmptyStringsToNull and TrimStrings middlewares
327-
$data = json_decode($request->getContent(), true);
327+
$data = json_optimize_decode($request->getContent(), true);
328328
$data = SanitizeHelper::sanitizeData($data['data'], null, $task->processRequest->do_not_sanitize ?? []);
329329
//Call the manager to trigger the start event
330330
$process = $task->process;

‎ProcessMaker/Managers/OauthMailManager.php‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Google\Client as GoogleClient;
88
use GuzzleHttp\Client;
99
use Illuminate\Mail\MailManager;
10-
use Microsoft\Graph\Graph;
1110
use ProcessMaker\Models\EnvironmentVariable;
1211
use ProcessMaker\Packages\Connectors\Email\EmailConfig;
1312

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
namespace ProcessMaker\Providers;
4+
5+
use Illuminate\Support\ServiceProvider;
6+
use ProcessMaker\Support\JsonOptimizer;
7+
8+
class JsonOptimizerServiceProvider extends ServiceProvider
9+
{
10+
/**
11+
* Register services.
12+
*/
13+
public function register(): void
14+
{
15+
//
16+
}
17+
18+
/**
19+
* Bootstrap services.
20+
*/
21+
public function boot(): void
22+
{
23+
$this->initializeJsonOptimizer();
24+
}
25+
26+
/**
27+
* Initialize JsonOptimizer configuration once at application startup
28+
*/
29+
private function initializeJsonOptimizer(): void
30+
{
31+
// Check if simdjson_plus extension is available
32+
$simdjsonAvailable = extension_loaded('simdjson_plus');
33+
34+
// Set optimization flags based on extension availability and config
35+
JsonOptimizer::$useSimdjsonDecode = $simdjsonAvailable && config('app.json_optimization_decode') === true;
36+
// About the json_encode is more performant than json_optimization_encode
37+
}
38+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
namespace ProcessMaker\Support;
4+
5+
use Illuminate\Support\Facades\Log;
6+
7+
class JsonOptimizer
8+
{
9+
/**
10+
* Global configuration set by ServiceProvider
11+
*/
12+
public static bool $useSimdjsonDecode = false;
13+
14+
public static bool $useSimdjsonEncode = false;
15+
16+
/**
17+
* Decodes a JSON using simdjson if available.
18+
*/
19+
public static function decode(string $json, bool $assoc = false, int $depth = 512, int $options = 0)
20+
{
21+
if (self::$useSimdjsonDecode) {
22+
try {
23+
return simdjson_decode($json, $assoc, $depth);
24+
} catch (\Throwable $e) {
25+
Log::warning("simdjson_decode failed: {$e->getMessage()}");
26+
}
27+
}
28+
29+
return json_decode($json, $assoc, $depth, $options);
30+
}
31+
32+
/**
33+
* Encodes a JSON using simdjson if available.
34+
* But json_encode is more performant than json_optimization_encode.
35+
* to_do: research other options for json_encode optimization.
36+
*/
37+
public static function encode(mixed $value, int $flags = 0, int $depth = 512): string|false
38+
{
39+
if (self::$useSimdjsonEncode) {
40+
try {
41+
return simdjson_encode($value, $flags, $depth);
42+
} catch (\Throwable $e) {
43+
Log::warning("simdjson_encode failed: {$e->getMessage()}");
44+
}
45+
}
46+
47+
return json_encode($value, $flags, $depth);
48+
}
49+
}

‎composer.json‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "processmaker/processmaker",
3-
"version": "4.15.3",
3+
"version": "4.15.4+beta-1",
44
"description": "BPM PHP Software",
55
"keywords": [
66
"php bpm processmaker"
@@ -35,13 +35,13 @@
3535
"lcobucci/jwt": "^4.2",
3636
"league/flysystem-aws-s3-v3": "^3.29",
3737
"mateusjunges/laravel-kafka": "^2.4",
38-
"microsoft/microsoft-graph": "^2.8",
3938
"mittwald/vault-php": "^2.1",
4039
"moontoast/math": "^1.2",
4140
"mustache/mustache": "^2.14",
4241
"openai-php/client": "^0.10.3",
4342
"openai-php/laravel": "^0.10.2",
4443
"php-amqplib/php-amqplib": "^3.7",
44+
"php-http/promise": "~1.2.0",
4545
"pion/laravel-chunk-upload": "^1.5",
4646
"predis/predis": "^2.3",
4747
"processmaker/docker-executor-lua": "^1.0",
@@ -106,7 +106,7 @@
106106
"Gmail"
107107
],
108108
"processmaker": {
109-
"build": "9d9c17c9",
109+
"build": "e181dec8",
110110
"cicd-enabled": true,
111111
"custom": {
112112
"package-ellucian-ethos": "1.19.3",

0 commit comments

Comments
 (0)