Skip to content

Commit 2e0ed4d

Browse files
committed
Merge branch 'develop' into bugfix/FOUR-27812
2 parents 7036677 + 17355e1 commit 2e0ed4d

10 files changed

Lines changed: 111 additions & 90 deletions

File tree

ProcessMaker/Application.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace ProcessMaker;
44

55
use Igaster\LaravelTheme\Facades\Theme;
6+
use Illuminate\Container\Container;
67
use Illuminate\Filesystem\Filesystem;
78
use Illuminate\Foundation\Application as IlluminateApplication;
89
use Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables;
@@ -12,6 +13,7 @@
1213
use Illuminate\Support\Facades\App;
1314
use Illuminate\Support\Facades\Auth;
1415
use Illuminate\Support\Facades\Config;
16+
use ProcessMaker\Console\Kernel;
1517
use ProcessMaker\Multitenancy\Tenant;
1618
use ProcessMaker\Multitenancy\TenantBootstrapper;
1719

@@ -112,4 +114,11 @@ public function bootstrapWith(array $bootstrappers)
112114

113115
return parent::bootstrapWith($bootstrappers);
114116
}
117+
118+
public function reactivateConsoleApp()
119+
{
120+
Container::setInstance($this);
121+
$this->hasBeenBootstrapped = false;
122+
$this->make(Kernel::class)->bootstrap();
123+
}
115124
}

ProcessMaker/Http/Controllers/Api/TaskController.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,17 @@ public function index(Request $request, $getTotal = false, User $user = null)
142142

143143
$this->applyStatusFilter($query, $request);
144144

145-
$this->applyPmql($query, $request, $user);
146-
147-
$this->applyAdvancedFilter($query, $request);
148-
145+
// Apply process manager filter BEFORE PMQL to avoid conflicts with is_self_service filtering
149146
if ($request->input('processesIManage') === 'true') {
150147
$this->applyProcessManager($query, $user);
151148
} else {
152149
$this->applyForCurrentUser($query, $user);
153150
}
154151

152+
$this->applyPmql($query, $request, $user);
153+
154+
$this->applyAdvancedFilter($query, $request);
155+
155156
// Apply filter overdue
156157
$query->overdue($request->input('overdue'));
157158

ProcessMaker/Http/Controllers/ProcessController.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@ public function edit(Process $process)
113113
$isDraft = $lastDraftOrPublishedVersion->draft;
114114
}
115115

116+
// search if user exists
117+
$user = User::where('id', $process->user_id)->exists();
118+
if (!$user) {
119+
// if user not exists, set the first administrator as the process owner
120+
$process->user_id = User::where('is_administrator', true)->where('status', 'ACTIVE')->first()->id;
121+
}
122+
116123
return view('processes.edit', compact([
117124
'process',
118125
'categories',

ProcessMaker/Multitenancy/TenantBootstrapper.php

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,6 @@ class TenantBootstrapper
2626

2727
private $app = null;
2828

29-
public static $landlordKeysToSave = [
30-
'APP_URL',
31-
'APP_KEY',
32-
'LOG_PATH',
33-
'DB_USERNAME',
34-
'DB_PASSWORD',
35-
'DB_HOSTNAME',
36-
'DB_PORT',
37-
'LANDLORD_DB_DATABASE',
38-
'REDIS_PREFIX',
39-
'CACHE_SETTING_PREFIX',
40-
'SCRIPT_MICROSERVICE_CALLBACK',
41-
'CACHE_PREFIX',
42-
];
43-
4429
public function bootstrap(Application $app)
4530
{
4631
try {
@@ -116,6 +101,14 @@ private function setTenantEnvironmentVariables($tenantData)
116101
$this->set('LOG_PATH', $this->app->storagePath('logs/processmaker.log'));
117102
}
118103

104+
// Used for debugging
105+
public static function log($message)
106+
{
107+
$message = '[TenantBootstrapper] ' . $message;
108+
$today = date('Y-m-d');
109+
file_put_contents(base_path('storage/logs/processmaker-' . $today . '.log'), date('Y-m-d H:i:s') . ' ' . $message . PHP_EOL, FILE_APPEND);
110+
}
111+
119112
private function getOriginalValue($key, $default = '')
120113
{
121114
if (self::$landlordValues === []) {

ProcessMaker/Providers/ProcessMakerServiceProvider.php

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -258,51 +258,19 @@ private static function bootstrapTenantApp(JobProcessing|JobRetryRequested $even
258258
return;
259259
}
260260

261-
// Save the landlord's config values so we can reset them later
262-
if (self::$landlordValues === null) {
263-
foreach (TenantBootstrapper::$landlordKeysToSave as $key) {
264-
self::$landlordValues[$key] = $_SERVER[$key] ?? '';
265-
}
266-
}
267-
268261
// Create a new tenant app instance
269262
$_SERVER['TENANT'] = $tenantId;
270-
$_ENV['TENANT'] = $tenantId;
271263

272264
if (!isset(self::$tenantAppContainers[$tenantId])) {
273-
$tenantApp = require app()->bootstrapPath('app.php');
274-
$tenantApp->instance('landlordValues', self::$landlordValues);
275-
$tenantApp->make(\Illuminate\Contracts\Console\Kernel::class)->bootstrap();
276-
self::$tenantAppContainers[$tenantId] = $tenantApp;
265+
self::$tenantAppContainers[$tenantId] = require base_path('bootstrap/app.php');
277266
}
267+
self::$tenantAppContainers[$tenantId]->reactivateConsoleApp();
278268

279269
// Change the job's app service container to the tenant app
280270
$event->job->getRedisQueue()->setContainer(self::$tenantAppContainers[$tenantId]);
281271
}
282272
}
283273

284-
private static function resetTenantApp($event): void
285-
{
286-
if (!method_exists($event->job, 'getRedisQueue')) {
287-
// Not a redis job
288-
return;
289-
}
290-
291-
unset($_SERVER['TENANT']);
292-
unset($_ENV['TENANT']);
293-
294-
if (!self::$landlordValues) {
295-
return;
296-
}
297-
298-
// Restore the original values since the tenant boostrapper modified them
299-
foreach (self::$landlordValues as $key => $value) {
300-
$_SERVER[$key] = $value;
301-
$_ENV[$key] = $value;
302-
putenv("$key=$value");
303-
}
304-
}
305-
306274
/**
307275
* Register app-level events.
308276
*/
@@ -316,10 +284,6 @@ protected static function registerEvents(): void
316284
self::bootstrapTenantApp($event);
317285
});
318286

319-
Facades\Event::listen(JobAttempted::class, function (JobAttempted $event) {
320-
self::resetTenantApp($event);
321-
});
322-
323287
// Listen to the events for our core screen
324288
// types and add our javascript
325289
Facades\Event::listen(ScreenBuilderStarting::class, function ($event) {

ProcessMaker/Traits/TaskControllerIndexMethods.php

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,20 @@ private function applyPmql($query, $request, $user)
289289
} catch (SyntaxError $e) {
290290
abort('Your PMQL contains invalid syntax.', 400);
291291
}
292+
293+
// After PMQL is applied, if processesIManage is active, add self-service tasks
294+
// This is done after PMQL to avoid the is_self_service = 0 filter that PMQL might add
295+
if ($request->input('processesIManage') === 'true' && isset($query->getQuery()->processManagerIds)) {
296+
$ids = $query->getQuery()->processManagerIds;
297+
$selfServiceTaskIds = ProcessRequestToken::select(['id'])
298+
->whereIn('process_id', $ids)
299+
->where('is_self_service', 1)
300+
->whereNull('user_id')
301+
->where('status', 'ACTIVE');
302+
303+
// Add self-service tasks using orWhereIn to override PMQL's is_self_service = 0 filter
304+
$query->orWhereIn('process_request_tokens.id', $selfServiceTaskIds);
305+
}
292306
}
293307
}
294308

@@ -340,11 +354,26 @@ public function applyProcessManager($query, $user)
340354
->orWhereRaw("JSON_CONTAINS(JSON_EXTRACT(properties, '$.manager_id'), CAST(? AS JSON))", [$user->id]);
341355
})
342356
->where('status', 'ACTIVE')
343-
->get()
357+
->pluck('id')
344358
->toArray();
345359

360+
if (empty($ids)) {
361+
// If user is not a manager of any process, return no results
362+
$query->whereRaw('1 = 0');
363+
364+
return;
365+
}
366+
367+
// Show tasks from processes the user manages that are ACTIVE
368+
// OR show self-service tasks from those processes
369+
// Store the process IDs in the query so we can use them later to add self-service tasks
370+
// We'll add self-service tasks after PMQL is applied to avoid the is_self_service = 0 filter
371+
$query->getQuery()->processManagerIds = $ids;
372+
373+
// Apply condition for regular tasks from managed processes
374+
// Self-service tasks will be added after PMQL to avoid conflicts
346375
$query->where(function ($query) use ($ids) {
347-
$query->whereIn('process_request_tokens.process_id', array_column($ids, 'id'))
376+
$query->whereIn('process_request_tokens.process_id', $ids)
348377
->where('process_request_tokens.status', 'ACTIVE');
349378
});
350379
}

composer.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "processmaker/processmaker",
3-
"version": "4.15.10+beta-2",
3+
"version": "4.15.10+beta-3",
44
"description": "BPM PHP Software",
55
"keywords": [
66
"php bpm processmaker"
@@ -23,7 +23,7 @@
2323
"guzzlehttp/guzzle": "^7.9",
2424
"igaster/laravel-theme": "^2.0",
2525
"jenssegers/agent": "^2.6",
26-
"laravel/framework": "^11.0",
26+
"laravel/framework": "^11.44.1",
2727
"laravel/horizon": "^5.30",
2828
"laravel/pail": "^1.2",
2929
"laravel/passport": "^12.3",
@@ -33,6 +33,7 @@
3333
"laravel/ui": "^4.6",
3434
"lavary/laravel-menu": "^1.8",
3535
"lcobucci/jwt": "^4.2",
36+
"league/commonmark": "^2.7",
3637
"league/flysystem-aws-s3-v3": "^3.29",
3738
"mateusjunges/laravel-kafka": "^2.4",
3839
"mittwald/vault-php": "^2.1",
@@ -63,6 +64,7 @@
6364
"spatie/laravel-multitenancy": "^4.0",
6465
"spomky-labs/otphp": "^11.3",
6566
"symfony/expression-language": "^7.2",
67+
"symfony/http-foundation": "^7.3",
6668
"teamtnt/laravel-scout-tntsearch-driver": "^14.0",
6769
"twilio/sdk": "^8.3",
6870
"typo3/class-alias-loader": "^1.2",
@@ -106,7 +108,7 @@
106108
"Gmail"
107109
],
108110
"processmaker": {
109-
"build": "83cb4a38",
111+
"build": "f9daa2ac",
110112
"cicd-enabled": true,
111113
"custom": {
112114
"package-ellucian-ethos": "1.19.7",
@@ -146,11 +148,11 @@
146148
"connector-docusign": "1.11.0",
147149
"connector-idp": "1.14.0",
148150
"connector-pdf-print": "1.23.1",
149-
"connector-send-email": "1.32.9",
151+
"connector-send-email": "1.32.10",
150152
"connector-slack": "1.9.3",
151153
"docker-executor-node-ssr": "1.7.2",
152154
"package-ab-testing": "1.4.0",
153-
"package-actions-by-email": "1.22.8",
155+
"package-actions-by-email": "1.22.9",
154156
"package-advanced-user-manager": "1.13.1",
155157
"package-ai": "1.16.10",
156158
"package-analytics-reporting": "1.11.1",
@@ -160,7 +162,7 @@
160162
"package-conversational-forms": "1.15.0",
161163
"package-data-sources": "1.34.3",
162164
"package-decision-engine": "1.16.1",
163-
"package-dynamic-ui": "1.28.2",
165+
"package-dynamic-ui": "1.28.3",
164166
"package-email-start-event": "1.0.8",
165167
"package-files": "1.23.1",
166168
"package-googleplaces": "1.12.0",

0 commit comments

Comments
 (0)