Refactor error handling in ScheduleBase class to improve project and resource validation.

This commit is contained in:
shimon 2025-12-08 17:49:10 +02:00
parent a241eab792
commit 6156b97ea0
2 changed files with 55 additions and 54 deletions

95
composer.lock generated
View file

@ -2673,16 +2673,16 @@
},
{
"name": "symfony/http-client",
"version": "v7.4.0",
"version": "v7.4.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-client.git",
"reference": "ee5e0e0139ab506f6063a230e631bed677c650a4"
"reference": "26cc224ea7103dda90e9694d9e139a389092d007"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-client/zipball/ee5e0e0139ab506f6063a230e631bed677c650a4",
"reference": "ee5e0e0139ab506f6063a230e631bed677c650a4",
"url": "https://api.github.com/repos/symfony/http-client/zipball/26cc224ea7103dda90e9694d9e139a389092d007",
"reference": "26cc224ea7103dda90e9694d9e139a389092d007",
"shasum": ""
},
"require": {
@ -2750,7 +2750,7 @@
"http"
],
"support": {
"source": "https://github.com/symfony/http-client/tree/v7.4.0"
"source": "https://github.com/symfony/http-client/tree/v7.4.1"
},
"funding": [
{
@ -2770,7 +2770,7 @@
"type": "tidelift"
}
],
"time": "2025-11-20T12:32:50+00:00"
"time": "2025-12-04T21:12:57+00:00"
},
{
"name": "symfony/http-client-contracts",
@ -4264,29 +4264,29 @@
},
{
"name": "utopia-php/framework",
"version": "0.33.33",
"version": "0.33.34",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/http.git",
"reference": "838e3a28276e73187bc34a314f014096dc92191b"
"reference": "76def92594c32504ec80eaacdb60ff8fad73c856"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/http/zipball/838e3a28276e73187bc34a314f014096dc92191b",
"reference": "838e3a28276e73187bc34a314f014096dc92191b",
"url": "https://api.github.com/repos/utopia-php/http/zipball/76def92594c32504ec80eaacdb60ff8fad73c856",
"reference": "76def92594c32504ec80eaacdb60ff8fad73c856",
"shasum": ""
},
"require": {
"php": ">=8.1",
"php": ">=8.3",
"utopia-php/compression": "0.1.*",
"utopia-php/telemetry": "0.1.*",
"utopia-php/validators": "0.1.*"
},
"require-dev": {
"laravel/pint": "^1.2",
"phpbench/phpbench": "^1.2",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^9.5.25"
"laravel/pint": "1.*",
"phpbench/phpbench": "1.*",
"phpstan/phpstan": "1.*",
"phpunit/phpunit": "9.*"
},
"type": "library",
"autoload": {
@ -4306,9 +4306,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/http/issues",
"source": "https://github.com/utopia-php/http/tree/0.33.33"
"source": "https://github.com/utopia-php/http/tree/0.33.34"
},
"time": "2025-11-25T10:21:13+00:00"
"time": "2025-12-08T07:55:31+00:00"
},
{
"name": "utopia-php/image",
@ -4513,16 +4513,16 @@
},
{
"name": "utopia-php/migration",
"version": "1.3.7",
"version": "1.3.9",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/migration.git",
"reference": "409983bc2a9cf53a8a3dc6c23d8b1dee1950b499"
"reference": "c55ec67c74663190cda10fd79297422147be7e85"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/migration/zipball/409983bc2a9cf53a8a3dc6c23d8b1dee1950b499",
"reference": "409983bc2a9cf53a8a3dc6c23d8b1dee1950b499",
"url": "https://api.github.com/repos/utopia-php/migration/zipball/c55ec67c74663190cda10fd79297422147be7e85",
"reference": "c55ec67c74663190cda10fd79297422147be7e85",
"shasum": ""
},
"require": {
@ -4562,9 +4562,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/migration/issues",
"source": "https://github.com/utopia-php/migration/tree/1.3.7"
"source": "https://github.com/utopia-php/migration/tree/1.3.9"
},
"time": "2025-12-05T05:02:31+00:00"
"time": "2025-12-08T08:45:09+00:00"
},
{
"name": "utopia-php/mongo",
@ -4679,16 +4679,16 @@
},
{
"name": "utopia-php/platform",
"version": "0.7.12",
"version": "0.7.13",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/platform.git",
"reference": "04255de21db75e90b170040f4d1b457ba721e7a5"
"reference": "77a863a920122e2c6a6bc6ee5548d366a3f4c6c7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/platform/zipball/04255de21db75e90b170040f4d1b457ba721e7a5",
"reference": "04255de21db75e90b170040f4d1b457ba721e7a5",
"url": "https://api.github.com/repos/utopia-php/platform/zipball/77a863a920122e2c6a6bc6ee5548d366a3f4c6c7",
"reference": "77a863a920122e2c6a6bc6ee5548d366a3f4c6c7",
"shasum": ""
},
"require": {
@ -4701,6 +4701,7 @@
},
"require-dev": {
"laravel/pint": "1.*",
"phpstan/phpstan": "2.*",
"phpunit/phpunit": "9.*"
},
"type": "library",
@ -4723,9 +4724,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/platform/issues",
"source": "https://github.com/utopia-php/platform/tree/0.7.12"
"source": "https://github.com/utopia-php/platform/tree/0.7.13"
},
"time": "2025-09-05T15:53:12+00:00"
"time": "2025-12-08T10:02:40+00:00"
},
{
"name": "utopia-php/pools",
@ -7930,16 +7931,16 @@
},
{
"name": "symfony/console",
"version": "v8.0.0",
"version": "v8.0.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "307d3cf852f5ead3618ac60ecbedbdd512c348b1"
"reference": "fcb73f69d655b48fcb894a262f074218df08bd58"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/307d3cf852f5ead3618ac60ecbedbdd512c348b1",
"reference": "307d3cf852f5ead3618ac60ecbedbdd512c348b1",
"url": "https://api.github.com/repos/symfony/console/zipball/fcb73f69d655b48fcb894a262f074218df08bd58",
"reference": "fcb73f69d655b48fcb894a262f074218df08bd58",
"shasum": ""
},
"require": {
@ -7996,7 +7997,7 @@
"terminal"
],
"support": {
"source": "https://github.com/symfony/console/tree/v8.0.0"
"source": "https://github.com/symfony/console/tree/v8.0.1"
},
"funding": [
{
@ -8016,20 +8017,20 @@
"type": "tidelift"
}
],
"time": "2025-11-21T13:19:49+00:00"
"time": "2025-12-05T15:25:33+00:00"
},
{
"name": "symfony/filesystem",
"version": "v8.0.0",
"version": "v8.0.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/filesystem.git",
"reference": "7fc96ae83372620eaba3826874f46e26295768ca"
"reference": "d937d400b980523dc9ee946bb69972b5e619058d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/7fc96ae83372620eaba3826874f46e26295768ca",
"reference": "7fc96ae83372620eaba3826874f46e26295768ca",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/d937d400b980523dc9ee946bb69972b5e619058d",
"reference": "d937d400b980523dc9ee946bb69972b5e619058d",
"shasum": ""
},
"require": {
@ -8066,7 +8067,7 @@
"description": "Provides basic utilities for the filesystem",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/filesystem/tree/v8.0.0"
"source": "https://github.com/symfony/filesystem/tree/v8.0.1"
},
"funding": [
{
@ -8086,7 +8087,7 @@
"type": "tidelift"
}
],
"time": "2025-11-05T14:36:47+00:00"
"time": "2025-12-01T09:13:36+00:00"
},
{
"name": "symfony/finder",
@ -8624,16 +8625,16 @@
},
{
"name": "symfony/string",
"version": "v8.0.0",
"version": "v8.0.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/string.git",
"reference": "f929eccf09531078c243df72398560e32fa4cf4f"
"reference": "ba65a969ac918ce0cc3edfac6cdde847eba231dc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/string/zipball/f929eccf09531078c243df72398560e32fa4cf4f",
"reference": "f929eccf09531078c243df72398560e32fa4cf4f",
"url": "https://api.github.com/repos/symfony/string/zipball/ba65a969ac918ce0cc3edfac6cdde847eba231dc",
"reference": "ba65a969ac918ce0cc3edfac6cdde847eba231dc",
"shasum": ""
},
"require": {
@ -8690,7 +8691,7 @@
"utf8"
],
"support": {
"source": "https://github.com/symfony/string/tree/v8.0.0"
"source": "https://github.com/symfony/string/tree/v8.0.1"
},
"funding": [
{
@ -8710,7 +8711,7 @@
"type": "tidelift"
}
],
"time": "2025-09-11T14:37:55+00:00"
"time": "2025-12-01T09:13:36+00:00"
},
{
"name": "textalk/websocket",

View file

@ -241,17 +241,17 @@ abstract class ScheduleBase extends Action
}
foreach ($this->schedules as $sequence => $schedule) {
$project = $map[$schedule['projectId']];
$project = $map[$schedule['projectId']] ?? null;
// In case the resource is blocked.
if ($isResourceBlocked($project, $collectionId, $schedule['resourceId'])) {
Console::error("Resource blocked: projectId::{$schedule['projectId']} resourceId::{$schedule['resourceId']}");
if ($project === null || $project->isEmpty()) {
Console::error("Project not found: projectId::{$schedule['projectId']} resourceId::{$schedule['resourceId']}");
unset($this->schedules[$sequence]);
continue;
}
if (empty($project)) {
Console::error("Project not found: projectId::{$schedule['projectId']} resourceId::{$schedule['resourceId']}");
// In case the resource is blocked.
if ($isResourceBlocked($project, $collectionId, $schedule['resourceId'])) {
Console::error("Resource blocked: projectId::{$schedule['projectId']} resourceId::{$schedule['resourceId']}");
unset($this->schedules[$sequence]);
continue;
}
@ -268,7 +268,7 @@ abstract class ScheduleBase extends Action
continue;
}
if (empty($resource)) {
if ($resource->isEmpty()) {
Console::error("Resource not found: projectId::{$schedule['projectId']} resourceId::{$schedule['resourceId']}");
unset($this->schedules[$sequence]);
continue;