From 0256c9f59a591e49de2831c62ade648de2c03186 Mon Sep 17 00:00:00 2001 From: Dmitriy Fishman Date: Tue, 11 May 2021 14:35:58 +0300 Subject: [PATCH 01/14] Use the correct 'End Of Line' symbol for selected platform. --- app/config/variables.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/config/variables.php b/app/config/variables.php index cd7db9ba6..5e8c68373 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -53,7 +53,7 @@ return [ 'introduction' => '', 'default' => 'localhost', 'required' => true, - 'question' => 'Enter a DNS A record hostname to serve as a CNAME for your custom domains.\nYou can use the same value as used for the Appwrite hostname.', + 'question' => 'Enter a DNS A record hostname to serve as a CNAME for your custom domains.' . PHP_EOL . 'You can use the same value as used for the Appwrite hostname.', ], [ 'name' => '_APP_CONSOLE_WHITELIST_EMAILS', From 579a24cf7361975d235f266135d57dd936027c0b Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Mon, 14 Jun 2021 22:18:43 +0300 Subject: [PATCH 02/14] Updated sort method before cleanup --- app/workers/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/workers/functions.php b/app/workers/functions.php index 8bf719e60..248553465 100644 --- a/app/workers/functions.php +++ b/app/workers/functions.php @@ -535,7 +535,7 @@ class FunctionsV1 if(\count($list) > $max) { Console::info('Starting containers cleanup'); - \usort($list, function ($item1, $item2) { + \uasort($list, function ($item1, $item2) { return (int)($item1['appwrite-created'] ?? 0) <=> (int)($item2['appwrite-created'] ?? 0); }); From af493324d0a409bec7b8c46762e2c258051ea41a Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Fri, 18 Jun 2021 13:32:32 +0200 Subject: [PATCH 03/14] docs(acocunt): fix converting anon account --- docs/references/account/create-session-anonymous.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/references/account/create-session-anonymous.md b/docs/references/account/create-session-anonymous.md index 61895604a..f10778b78 100644 --- a/docs/references/account/create-session-anonymous.md +++ b/docs/references/account/create-session-anonymous.md @@ -1 +1 @@ -Use this endpoint to allow a new user to register an anonymous account in your project. This route will also create a new session for the user. To allow the new user to convert an anonymous account to a normal account account, you need to update its [email and password](/docs/client/account#accountUpdateEmail). \ No newline at end of file +Use this endpoint to allow a new user to register an anonymous account in your project. This route will also create a new session for the user. To allow the new user to convert an anonymous account to a normal account, you need to update its [email and password](/docs/client/account#accountUpdateEmail) or create an [OAuth2 session](/docs/client/account#accountCreateOAuth2Session). \ No newline at end of file From a1d4e3537550f24841879f152a43ad15c19af5e4 Mon Sep 17 00:00:00 2001 From: Matej Baco Date: Sat, 19 Jun 2021 23:46:20 +0200 Subject: [PATCH 04/14] Updated INTERVALS of php-resque --- bin/schedule | 2 +- bin/worker-audits | 2 +- bin/worker-certificates | 2 +- bin/worker-deletes | 2 +- bin/worker-functions | 2 +- bin/worker-mails | 2 +- bin/worker-tasks | 2 +- bin/worker-usage | 2 +- bin/worker-webhooks | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bin/schedule b/bin/schedule index 6300d97ed..dbc6d94d9 100644 --- a/bin/schedule +++ b/bin/schedule @@ -7,4 +7,4 @@ else REDIS_BACKEND="redis://${_APP_REDIS_USER}:${_APP_REDIS_PASS}@${_APP_REDIS_HOST}:${_APP_REDIS_PORT}" fi -REDIS_BACKEND=$REDIS_BACKEND RESQUE_PHP='/usr/src/code/vendor/autoload.php' php /usr/src/code/vendor/bin/resque-scheduler +INTERVAL=1 REDIS_BACKEND=$REDIS_BACKEND RESQUE_PHP='/usr/src/code/vendor/autoload.php' php /usr/src/code/vendor/bin/resque-scheduler diff --git a/bin/worker-audits b/bin/worker-audits index 8e99481d2..7dd25c75c 100644 --- a/bin/worker-audits +++ b/bin/worker-audits @@ -7,4 +7,4 @@ else REDIS_BACKEND="redis://${_APP_REDIS_USER}:${_APP_REDIS_PASS}@${_APP_REDIS_HOST}:${_APP_REDIS_PORT}" fi -QUEUE='v1-audits' APP_INCLUDE='/usr/src/code/app/workers/audits.php' php /usr/src/code/vendor/bin/resque -dopcache.preload=opcache.preload=/usr/src/code/app/preload.php \ No newline at end of file +INTERVAL=1 QUEUE='v1-audits' APP_INCLUDE='/usr/src/code/app/workers/audits.php' php /usr/src/code/vendor/bin/resque -dopcache.preload=opcache.preload=/usr/src/code/app/preload.php \ No newline at end of file diff --git a/bin/worker-certificates b/bin/worker-certificates index 9214af513..679885fa4 100755 --- a/bin/worker-certificates +++ b/bin/worker-certificates @@ -7,4 +7,4 @@ else REDIS_BACKEND="redis://${_APP_REDIS_USER}:${_APP_REDIS_PASS}@${_APP_REDIS_HOST}:${_APP_REDIS_PORT}" fi -QUEUE='v1-certificates' APP_INCLUDE='/usr/src/code/app/workers/certificates.php' php /usr/src/code/vendor/bin/resque -dopcache.preload=opcache.preload=/usr/src/code/app/preload.php \ No newline at end of file +INTERVAL=1 QUEUE='v1-certificates' APP_INCLUDE='/usr/src/code/app/workers/certificates.php' php /usr/src/code/vendor/bin/resque -dopcache.preload=opcache.preload=/usr/src/code/app/preload.php \ No newline at end of file diff --git a/bin/worker-deletes b/bin/worker-deletes index 517f75530..02c2311fa 100644 --- a/bin/worker-deletes +++ b/bin/worker-deletes @@ -7,4 +7,4 @@ else REDIS_BACKEND="redis://${_APP_REDIS_USER}:${_APP_REDIS_PASS}@${_APP_REDIS_HOST}:${_APP_REDIS_PORT}" fi -QUEUE='v1-deletes' APP_INCLUDE='/usr/src/code/app/workers/deletes.php' php /usr/src/code/vendor/bin/resque -dopcache.preload=opcache.preload=/usr/src/code/app/preload.php \ No newline at end of file +INTERVAL=1 QUEUE='v1-deletes' APP_INCLUDE='/usr/src/code/app/workers/deletes.php' php /usr/src/code/vendor/bin/resque -dopcache.preload=opcache.preload=/usr/src/code/app/preload.php \ No newline at end of file diff --git a/bin/worker-functions b/bin/worker-functions index 29cd4b85c..5e9728c46 100644 --- a/bin/worker-functions +++ b/bin/worker-functions @@ -7,4 +7,4 @@ else REDIS_BACKEND="redis://${_APP_REDIS_USER}:${_APP_REDIS_PASS}@${_APP_REDIS_HOST}:${_APP_REDIS_PORT}" fi -QUEUE='v1-functions' APP_INCLUDE='/usr/src/code/app/workers/functions.php' php /usr/src/code/vendor/bin/resque -dopcache.preload=opcache.preload=/usr/src/code/app/preload.php \ No newline at end of file +INTERVAL=0.1 QUEUE='v1-functions' APP_INCLUDE='/usr/src/code/app/workers/functions.php' php /usr/src/code/vendor/bin/resque -dopcache.preload=opcache.preload=/usr/src/code/app/preload.php \ No newline at end of file diff --git a/bin/worker-mails b/bin/worker-mails index a66394262..87fa64cf7 100644 --- a/bin/worker-mails +++ b/bin/worker-mails @@ -7,4 +7,4 @@ else REDIS_BACKEND="redis://${_APP_REDIS_USER}:${_APP_REDIS_PASS}@${_APP_REDIS_HOST}:${_APP_REDIS_PORT}" fi -QUEUE='v1-mails' APP_INCLUDE='/usr/src/code/app/workers/mails.php' php /usr/src/code/vendor/bin/resque -dopcache.preload=opcache.preload=/usr/src/code/app/preload.php \ No newline at end of file +INTERVAL=1 QUEUE='v1-mails' APP_INCLUDE='/usr/src/code/app/workers/mails.php' php /usr/src/code/vendor/bin/resque -dopcache.preload=opcache.preload=/usr/src/code/app/preload.php \ No newline at end of file diff --git a/bin/worker-tasks b/bin/worker-tasks index bac1f54a8..0b54d9a06 100644 --- a/bin/worker-tasks +++ b/bin/worker-tasks @@ -7,4 +7,4 @@ else REDIS_BACKEND="redis://${_APP_REDIS_USER}:${_APP_REDIS_PASS}@${_APP_REDIS_HOST}:${_APP_REDIS_PORT}" fi -QUEUE='v1-tasks' APP_INCLUDE='/usr/src/code/app/workers/tasks.php' php /usr/src/code/vendor/bin/resque -dopcache.preload=opcache.preload=/usr/src/code/app/preload.php \ No newline at end of file +INTERVAL=0.1 QUEUE='v1-tasks' APP_INCLUDE='/usr/src/code/app/workers/tasks.php' php /usr/src/code/vendor/bin/resque -dopcache.preload=opcache.preload=/usr/src/code/app/preload.php \ No newline at end of file diff --git a/bin/worker-usage b/bin/worker-usage index 9cb9b5ed8..34e900f65 100644 --- a/bin/worker-usage +++ b/bin/worker-usage @@ -7,4 +7,4 @@ else REDIS_BACKEND="redis://${_APP_REDIS_USER}:${_APP_REDIS_PASS}@${_APP_REDIS_HOST}:${_APP_REDIS_PORT}" fi -QUEUE='v1-usage' APP_INCLUDE='/usr/src/code/app/workers/usage.php' php /usr/src/code/vendor/bin/resque -dopcache.preload=opcache.preload=/usr/src/code/app/preload.php \ No newline at end of file +INTERVAL=0.1 QUEUE='v1-usage' APP_INCLUDE='/usr/src/code/app/workers/usage.php' php /usr/src/code/vendor/bin/resque -dopcache.preload=opcache.preload=/usr/src/code/app/preload.php \ No newline at end of file diff --git a/bin/worker-webhooks b/bin/worker-webhooks index 4ae2fadaa..e34c79658 100644 --- a/bin/worker-webhooks +++ b/bin/worker-webhooks @@ -7,4 +7,4 @@ else REDIS_BACKEND="redis://${_APP_REDIS_USER}:${_APP_REDIS_PASS}@${_APP_REDIS_HOST}:${_APP_REDIS_PORT}" fi -QUEUE='v1-webhooks' APP_INCLUDE='/usr/src/code/app/workers/webhooks.php' php /usr/src/code/vendor/bin/resque -dopcache.preload=opcache.preload=/usr/src/code/app/preload.php \ No newline at end of file +INTERVAL=0.1 QUEUE='v1-webhooks' APP_INCLUDE='/usr/src/code/app/workers/webhooks.php' php /usr/src/code/vendor/bin/resque -dopcache.preload=opcache.preload=/usr/src/code/app/preload.php \ No newline at end of file From b7e9efb3d7fa891504bcf77022fb9f391caeb8eb Mon Sep 17 00:00:00 2001 From: Matej Baco Date: Sun, 20 Jun 2021 00:01:01 +0200 Subject: [PATCH 05/14] Updated interval of an usage worker --- bin/worker-usage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/worker-usage b/bin/worker-usage index 34e900f65..4174acce2 100644 --- a/bin/worker-usage +++ b/bin/worker-usage @@ -7,4 +7,4 @@ else REDIS_BACKEND="redis://${_APP_REDIS_USER}:${_APP_REDIS_PASS}@${_APP_REDIS_HOST}:${_APP_REDIS_PORT}" fi -INTERVAL=0.1 QUEUE='v1-usage' APP_INCLUDE='/usr/src/code/app/workers/usage.php' php /usr/src/code/vendor/bin/resque -dopcache.preload=opcache.preload=/usr/src/code/app/preload.php \ No newline at end of file +INTERVAL=1 QUEUE='v1-usage' APP_INCLUDE='/usr/src/code/app/workers/usage.php' php /usr/src/code/vendor/bin/resque -dopcache.preload=opcache.preload=/usr/src/code/app/preload.php \ No newline at end of file From 607c64734d983acf14336f56564bb87738609fd4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 22 Jun 2021 15:18:52 +0000 Subject: [PATCH 06/14] build(deps): bump phpmailer/phpmailer from 6.4.1 to 6.5.0 Bumps [phpmailer/phpmailer](https://github.com/PHPMailer/PHPMailer) from 6.4.1 to 6.5.0. - [Release notes](https://github.com/PHPMailer/PHPMailer/releases) - [Changelog](https://github.com/PHPMailer/PHPMailer/blob/master/changelog.md) - [Commits](https://github.com/PHPMailer/PHPMailer/compare/v6.4.1...v6.5.0) --- updated-dependencies: - dependency-name: phpmailer/phpmailer dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- composer.lock | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index a22622612..77a118a8d 100644 --- a/composer.json +++ b/composer.json @@ -56,7 +56,7 @@ "matomo/device-detector": "4.2.2", "dragonmantank/cron-expression": "3.1.0", "influxdb/influxdb-php": "1.15.2", - "phpmailer/phpmailer": "6.4.1", + "phpmailer/phpmailer": "6.5.0", "chillerlan/php-qrcode": "4.3.0", "adhocore/jwt": "1.1.2", "slickdeals/statsd": "3.0.2" diff --git a/composer.lock b/composer.lock index 9e7affe29..1d655a0c2 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "399d2426ca92e04b6d6fb84a91c316c3", + "content-hash": "1619af9dd64477ba255e6f47bdf2ac51", "packages": [ { "name": "adhocore/jwt", @@ -834,16 +834,16 @@ }, { "name": "phpmailer/phpmailer", - "version": "v6.4.1", + "version": "v6.5.0", "source": { "type": "git", "url": "https://github.com/PHPMailer/PHPMailer.git", - "reference": "9256f12d8fb0cd0500f93b19e18c356906cbed3d" + "reference": "a5b5c43e50b7fba655f793ad27303cd74c57363c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/9256f12d8fb0cd0500f93b19e18c356906cbed3d", - "reference": "9256f12d8fb0cd0500f93b19e18c356906cbed3d", + "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/a5b5c43e50b7fba655f793ad27303cd74c57363c", + "reference": "a5b5c43e50b7fba655f793ad27303cd74c57363c", "shasum": "" }, "require": { @@ -898,7 +898,7 @@ "description": "PHPMailer is a full-featured email creation and transfer class for PHP", "support": { "issues": "https://github.com/PHPMailer/PHPMailer/issues", - "source": "https://github.com/PHPMailer/PHPMailer/tree/v6.4.1" + "source": "https://github.com/PHPMailer/PHPMailer/tree/v6.5.0" }, "funding": [ { @@ -906,7 +906,7 @@ "type": "github" } ], - "time": "2021-04-29T12:25:04+00:00" + "time": "2021-06-16T14:33:43+00:00" }, { "name": "psr/http-client", From 9e6e345a3fd1a5bbadac18301b0a2f8cbcb50c3e Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Wed, 23 Jun 2021 10:56:35 +0300 Subject: [PATCH 07/14] Updated changelog --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 0dd92eeff..3b3c68869 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -9,6 +9,7 @@ - Add Provider Icon to each Session - Add Anonymous Account Placeholder - Upgraded telegraf docker image version to v1.1.0 +- Upgraded phpmailer version to 6.5.0 (#1317) ## Bugs From 497d391412df070c65578e43a73c743458824d66 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 23 Jun 2021 13:59:35 +0545 Subject: [PATCH 08/14] update image library and gravity param --- app/controllers/api/storage.php | 2 +- composer.json | 2 +- composer.lock | 104 ++++++++++++++++---------------- 3 files changed, 54 insertions(+), 54 deletions(-) diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index c4fe8c849..7cdcc3d0a 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -242,7 +242,7 @@ App::get('/v1/storage/files/:fileId/preview') ->param('fileId', '', new UID(), 'File unique ID') ->param('width', 0, new Range(0, 4000), 'Resize preview image width, Pass an integer between 0 to 4000.', true) ->param('height', 0, new Range(0, 4000), 'Resize preview image height, Pass an integer between 0 to 4000.', true) - ->param('gravity', Image::GRAVITY_CENTER, new WhiteList([Image::GRAVITY_CENTER, Image::GRAVITY_NORTH, Image::GRAVITY_NORTHWEST, Image::GRAVITY_NORTHEAST, Image::GRAVITY_WEST, Image::GRAVITY_EAST, Image::GRAVITY_SOUTHWEST, Image::GRAVITY_SOUTH, Image::GRAVITY_SOUTHEAST]), 'Image crop gravity', true) + ->param('gravity', Image::GRAVITY_CENTER, new WhiteList([Image::GRAVITY_CENTER, Image::GRAVITY_TOP, Image::GRAVITY_TOP_LEFT, Image::GRAVITY_TOP_RIGHT, Image::GRAVITY_LEFT, Image::GRAVITY_RIGHT, Image::GRAVITY_BOTTOM_LEFT, Image::GRAVITY_BOTTOM, Image::GRAVITY_BOTTOM_RIGHT]), 'Image crop gravity', true) ->param('quality', 100, new Range(0, 100), 'Preview image quality. Pass an integer between 0 to 100. Defaults to 100.', true) ->param('borderWidth', 0, new Range(0, 100), 'Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0.', true) ->param('borderColor', '', new HexColor(), 'Preview image border color. Use a valid HEX color, no # is needed for prefix.', true) diff --git a/composer.json b/composer.json index 77a118a8d..c665fb24b 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,7 @@ "utopia-php/domains": "1.1.*", "utopia-php/swoole": "0.2.*", "utopia-php/storage": "0.5.*", - "utopia-php/image": "0.3.*", + "utopia-php/image": "0.4.*", "resque/php-resque": "1.3.6", "matomo/device-detector": "4.2.2", "dragonmantank/cron-expression": "3.1.0", diff --git a/composer.lock b/composer.lock index 1d655a0c2..07e32249b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "1619af9dd64477ba255e6f47bdf2ac51", + "content-hash": "75b472aae18938c8f7f3675395ca7c2f", "packages": [ { "name": "adhocore/jwt", @@ -1742,16 +1742,16 @@ }, { "name": "utopia-php/image", - "version": "0.3.2", + "version": "0.4.0", "source": { "type": "git", "url": "https://github.com/utopia-php/image.git", - "reference": "2044fdd44d87c4253cfe929cca975fd037461b00" + "reference": "63d8d8df59828db8e44a40acfe3ca50af9f0c35f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/image/zipball/2044fdd44d87c4253cfe929cca975fd037461b00", - "reference": "2044fdd44d87c4253cfe929cca975fd037461b00", + "url": "https://api.github.com/repos/utopia-php/image/zipball/63d8d8df59828db8e44a40acfe3ca50af9f0c35f", + "reference": "63d8d8df59828db8e44a40acfe3ca50af9f0c35f", "shasum": "" }, "require": { @@ -1789,9 +1789,9 @@ ], "support": { "issues": "https://github.com/utopia-php/image/issues", - "source": "https://github.com/utopia-php/image/tree/0.3.2" + "source": "https://github.com/utopia-php/image/tree/0.4.0" }, - "time": "2021-06-10T09:16:11+00:00" + "time": "2021-06-23T07:43:36+00:00" }, { "name": "utopia-php/locale", @@ -2003,16 +2003,16 @@ }, { "name": "utopia-php/swoole", - "version": "0.2.3", + "version": "0.2.4", "source": { "type": "git", "url": "https://github.com/utopia-php/swoole.git", - "reference": "45c42aae7e7d3f9f82bf194c2cfa5499b674aefe" + "reference": "37d8c64b536d6bc7da4f0f5a934a0ec44885abf4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/swoole/zipball/45c42aae7e7d3f9f82bf194c2cfa5499b674aefe", - "reference": "45c42aae7e7d3f9f82bf194c2cfa5499b674aefe", + "url": "https://api.github.com/repos/utopia-php/swoole/zipball/37d8c64b536d6bc7da4f0f5a934a0ec44885abf4", + "reference": "37d8c64b536d6bc7da4f0f5a934a0ec44885abf4", "shasum": "" }, "require": { @@ -2053,9 +2053,9 @@ ], "support": { "issues": "https://github.com/utopia-php/swoole/issues", - "source": "https://github.com/utopia-php/swoole/tree/0.2.3" + "source": "https://github.com/utopia-php/swoole/tree/0.2.4" }, - "time": "2021-03-22T22:39:24+00:00" + "time": "2021-06-22T10:49:24+00:00" }, { "name": "utopia-php/system", @@ -2713,20 +2713,20 @@ }, { "name": "felixfbecker/advanced-json-rpc", - "version": "v3.2.0", + "version": "v3.2.1", "source": { "type": "git", "url": "https://github.com/felixfbecker/php-advanced-json-rpc.git", - "reference": "06f0b06043c7438959dbdeed8bb3f699a19be22e" + "reference": "b5f37dbff9a8ad360ca341f3240dc1c168b45447" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/felixfbecker/php-advanced-json-rpc/zipball/06f0b06043c7438959dbdeed8bb3f699a19be22e", - "reference": "06f0b06043c7438959dbdeed8bb3f699a19be22e", + "url": "https://api.github.com/repos/felixfbecker/php-advanced-json-rpc/zipball/b5f37dbff9a8ad360ca341f3240dc1c168b45447", + "reference": "b5f37dbff9a8ad360ca341f3240dc1c168b45447", "shasum": "" }, "require": { - "netresearch/jsonmapper": "^1.0 || ^2.0", + "netresearch/jsonmapper": "^1.0 || ^2.0 || ^3.0 || ^4.0", "php": "^7.1 || ^8.0", "phpdocumentor/reflection-docblock": "^4.3.4 || ^5.0.0" }, @@ -2752,9 +2752,9 @@ "description": "A more advanced JSONRPC implementation", "support": { "issues": "https://github.com/felixfbecker/php-advanced-json-rpc/issues", - "source": "https://github.com/felixfbecker/php-advanced-json-rpc/tree/v3.2.0" + "source": "https://github.com/felixfbecker/php-advanced-json-rpc/tree/v3.2.1" }, - "time": "2021-01-10T17:48:47+00:00" + "time": "2021-06-11T22:34:44+00:00" }, { "name": "felixfbecker/language-server-protocol", @@ -3003,16 +3003,16 @@ }, { "name": "netresearch/jsonmapper", - "version": "v2.1.0", + "version": "v4.0.0", "source": { "type": "git", "url": "https://github.com/cweiske/jsonmapper.git", - "reference": "e0f1e33a71587aca81be5cffbb9746510e1fe04e" + "reference": "8bbc021a8edb2e4a7ea2f8ad4fa9ec9dce2fcb8d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/cweiske/jsonmapper/zipball/e0f1e33a71587aca81be5cffbb9746510e1fe04e", - "reference": "e0f1e33a71587aca81be5cffbb9746510e1fe04e", + "url": "https://api.github.com/repos/cweiske/jsonmapper/zipball/8bbc021a8edb2e4a7ea2f8ad4fa9ec9dce2fcb8d", + "reference": "8bbc021a8edb2e4a7ea2f8ad4fa9ec9dce2fcb8d", "shasum": "" }, "require": { @@ -3020,10 +3020,10 @@ "ext-pcre": "*", "ext-reflection": "*", "ext-spl": "*", - "php": ">=5.6" + "php": ">=7.1" }, "require-dev": { - "phpunit/phpunit": "~4.8.35 || ~5.7 || ~6.4 || ~7.0", + "phpunit/phpunit": "~7.5 || ~8.0 || ~9.0", "squizlabs/php_codesniffer": "~3.5" }, "type": "library", @@ -3048,9 +3048,9 @@ "support": { "email": "cweiske@cweiske.de", "issues": "https://github.com/cweiske/jsonmapper/issues", - "source": "https://github.com/cweiske/jsonmapper/tree/master" + "source": "https://github.com/cweiske/jsonmapper/tree/v4.0.0" }, - "time": "2020-04-16T18:48:43+00:00" + "time": "2020-12-01T19:48:11+00:00" }, { "name": "nikic/php-parser", @@ -4472,16 +4472,16 @@ }, { "name": "sebastian/global-state", - "version": "5.0.2", + "version": "5.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "a90ccbddffa067b51f574dea6eb25d5680839455" + "reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/a90ccbddffa067b51f574dea6eb25d5680839455", - "reference": "a90ccbddffa067b51f574dea6eb25d5680839455", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/23bd5951f7ff26f12d4e3242864df3e08dec4e49", + "reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49", "shasum": "" }, "require": { @@ -4524,7 +4524,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/global-state/issues", - "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.2" + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.3" }, "funding": [ { @@ -4532,7 +4532,7 @@ "type": "github" } ], - "time": "2020-10-26T15:55:19+00:00" + "time": "2021-06-11T13:31:12+00:00" }, { "name": "sebastian/lines-of-code", @@ -4823,16 +4823,16 @@ }, { "name": "sebastian/type", - "version": "2.3.2", + "version": "2.3.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "0d1c587401514d17e8f9258a27e23527cb1b06c1" + "reference": "b8cd8a1c753c90bc1a0f5372170e3e489136f914" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/0d1c587401514d17e8f9258a27e23527cb1b06c1", - "reference": "0d1c587401514d17e8f9258a27e23527cb1b06c1", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/b8cd8a1c753c90bc1a0f5372170e3e489136f914", + "reference": "b8cd8a1c753c90bc1a0f5372170e3e489136f914", "shasum": "" }, "require": { @@ -4867,7 +4867,7 @@ "homepage": "https://github.com/sebastianbergmann/type", "support": { "issues": "https://github.com/sebastianbergmann/type/issues", - "source": "https://github.com/sebastianbergmann/type/tree/2.3.2" + "source": "https://github.com/sebastianbergmann/type/tree/2.3.4" }, "funding": [ { @@ -4875,7 +4875,7 @@ "type": "github" } ], - "time": "2021-06-04T13:02:07+00:00" + "time": "2021-06-15T12:49:02+00:00" }, { "name": "sebastian/version", @@ -4984,16 +4984,16 @@ }, { "name": "symfony/console", - "version": "v5.3.0", + "version": "v5.3.2", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "058553870f7809087fa80fa734704a21b9bcaeb2" + "reference": "649730483885ff2ca99ca0560ef0e5f6b03f2ac1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/058553870f7809087fa80fa734704a21b9bcaeb2", - "reference": "058553870f7809087fa80fa734704a21b9bcaeb2", + "url": "https://api.github.com/repos/symfony/console/zipball/649730483885ff2ca99ca0560ef0e5f6b03f2ac1", + "reference": "649730483885ff2ca99ca0560ef0e5f6b03f2ac1", "shasum": "" }, "require": { @@ -5062,7 +5062,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.3.0" + "source": "https://github.com/symfony/console/tree/v5.3.2" }, "funding": [ { @@ -5078,7 +5078,7 @@ "type": "tidelift" } ], - "time": "2021-05-26T17:43:10+00:00" + "time": "2021-06-12T09:42:48+00:00" }, { "name": "symfony/deprecation-contracts", @@ -5635,16 +5635,16 @@ }, { "name": "symfony/string", - "version": "v5.3.0", + "version": "v5.3.2", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "a9a0f8b6aafc5d2d1c116dcccd1573a95153515b" + "reference": "0732e97e41c0a590f77e231afc16a327375d50b0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/a9a0f8b6aafc5d2d1c116dcccd1573a95153515b", - "reference": "a9a0f8b6aafc5d2d1c116dcccd1573a95153515b", + "url": "https://api.github.com/repos/symfony/string/zipball/0732e97e41c0a590f77e231afc16a327375d50b0", + "reference": "0732e97e41c0a590f77e231afc16a327375d50b0", "shasum": "" }, "require": { @@ -5698,7 +5698,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.3.0" + "source": "https://github.com/symfony/string/tree/v5.3.2" }, "funding": [ { @@ -5714,7 +5714,7 @@ "type": "tidelift" } ], - "time": "2021-05-26T17:43:10+00:00" + "time": "2021-06-06T09:51:56+00:00" }, { "name": "theseer/tokenizer", From 378be8363ab91637a6c0e853c1161d56187f28c3 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 24 Jun 2021 12:15:52 +0545 Subject: [PATCH 09/14] using getGravityTypes method to get list of supported gravity --- app/controllers/api/storage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index 7cdcc3d0a..3adb03104 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -242,7 +242,7 @@ App::get('/v1/storage/files/:fileId/preview') ->param('fileId', '', new UID(), 'File unique ID') ->param('width', 0, new Range(0, 4000), 'Resize preview image width, Pass an integer between 0 to 4000.', true) ->param('height', 0, new Range(0, 4000), 'Resize preview image height, Pass an integer between 0 to 4000.', true) - ->param('gravity', Image::GRAVITY_CENTER, new WhiteList([Image::GRAVITY_CENTER, Image::GRAVITY_TOP, Image::GRAVITY_TOP_LEFT, Image::GRAVITY_TOP_RIGHT, Image::GRAVITY_LEFT, Image::GRAVITY_RIGHT, Image::GRAVITY_BOTTOM_LEFT, Image::GRAVITY_BOTTOM, Image::GRAVITY_BOTTOM_RIGHT]), 'Image crop gravity', true) + ->param('gravity', Image::GRAVITY_CENTER, new WhiteList(Image::getGravityTypes()), 'Image crop gravity. Can be one of ' . implode(",", Image::getGravityTypes()), true) ->param('quality', 100, new Range(0, 100), 'Preview image quality. Pass an integer between 0 to 100. Defaults to 100.', true) ->param('borderWidth', 0, new Range(0, 100), 'Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0.', true) ->param('borderColor', '', new HexColor(), 'Preview image border color. Use a valid HEX color, no # is needed for prefix.', true) From 66a6c404336f6c9b3e9731e6ca51ae9329f9def7 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Fri, 25 Jun 2021 12:36:03 +0545 Subject: [PATCH 10/14] update image library --- composer.json | 2 +- composer.lock | 40 ++++++++++++++++++++-------------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/composer.json b/composer.json index c665fb24b..17b5500ff 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,7 @@ "utopia-php/domains": "1.1.*", "utopia-php/swoole": "0.2.*", "utopia-php/storage": "0.5.*", - "utopia-php/image": "0.4.*", + "utopia-php/image": "0.5.*", "resque/php-resque": "1.3.6", "matomo/device-detector": "4.2.2", "dragonmantank/cron-expression": "3.1.0", diff --git a/composer.lock b/composer.lock index 07e32249b..308f14496 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "75b472aae18938c8f7f3675395ca7c2f", + "content-hash": "a03cb89925d6bda5ad4248699f732a6a", "packages": [ { "name": "adhocore/jwt", @@ -1324,16 +1324,16 @@ }, { "name": "utopia-php/abuse", - "version": "0.4.1", + "version": "0.4.2", "source": { "type": "git", "url": "https://github.com/utopia-php/abuse.git", - "reference": "8b7973aae4b02489bd22ffea45b985608f13b6d9" + "reference": "286b52209818e5033573e6441d65adbc48a6f715" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/abuse/zipball/8b7973aae4b02489bd22ffea45b985608f13b6d9", - "reference": "8b7973aae4b02489bd22ffea45b985608f13b6d9", + "url": "https://api.github.com/repos/utopia-php/abuse/zipball/286b52209818e5033573e6441d65adbc48a6f715", + "reference": "286b52209818e5033573e6441d65adbc48a6f715", "shasum": "" }, "require": { @@ -1370,9 +1370,9 @@ ], "support": { "issues": "https://github.com/utopia-php/abuse/issues", - "source": "https://github.com/utopia-php/abuse/tree/0.4.1" + "source": "https://github.com/utopia-php/abuse/tree/0.4.2" }, - "time": "2021-06-05T14:31:33+00:00" + "time": "2021-06-23T15:04:44+00:00" }, { "name": "utopia-php/analytics", @@ -1431,21 +1431,21 @@ }, { "name": "utopia-php/audit", - "version": "0.5.1", + "version": "0.5.2", "source": { "type": "git", "url": "https://github.com/utopia-php/audit.git", - "reference": "154a850170a58667a15e4b65fbabb6cd0b709dd9" + "reference": "57e4f8f932164bdfd48ec32bf8d7d3f1bf7518e4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/audit/zipball/154a850170a58667a15e4b65fbabb6cd0b709dd9", - "reference": "154a850170a58667a15e4b65fbabb6cd0b709dd9", + "url": "https://api.github.com/repos/utopia-php/audit/zipball/57e4f8f932164bdfd48ec32bf8d7d3f1bf7518e4", + "reference": "57e4f8f932164bdfd48ec32bf8d7d3f1bf7518e4", "shasum": "" }, "require": { "ext-pdo": "*", - "php": ">=7.1" + "php": ">=7.4" }, "require-dev": { "phpunit/phpunit": "^9.3", @@ -1477,9 +1477,9 @@ ], "support": { "issues": "https://github.com/utopia-php/audit/issues", - "source": "https://github.com/utopia-php/audit/tree/0.5.1" + "source": "https://github.com/utopia-php/audit/tree/0.5.2" }, - "time": "2020-12-21T17:28:53+00:00" + "time": "2021-06-23T16:02:40+00:00" }, { "name": "utopia-php/cache", @@ -1742,16 +1742,16 @@ }, { "name": "utopia-php/image", - "version": "0.4.0", + "version": "0.5.0", "source": { "type": "git", "url": "https://github.com/utopia-php/image.git", - "reference": "63d8d8df59828db8e44a40acfe3ca50af9f0c35f" + "reference": "5b4ac25e70a95fa10b39c129b742ac66748d40b8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/image/zipball/63d8d8df59828db8e44a40acfe3ca50af9f0c35f", - "reference": "63d8d8df59828db8e44a40acfe3ca50af9f0c35f", + "url": "https://api.github.com/repos/utopia-php/image/zipball/5b4ac25e70a95fa10b39c129b742ac66748d40b8", + "reference": "5b4ac25e70a95fa10b39c129b742ac66748d40b8", "shasum": "" }, "require": { @@ -1789,9 +1789,9 @@ ], "support": { "issues": "https://github.com/utopia-php/image/issues", - "source": "https://github.com/utopia-php/image/tree/0.4.0" + "source": "https://github.com/utopia-php/image/tree/0.5.0" }, - "time": "2021-06-23T07:43:36+00:00" + "time": "2021-06-25T03:40:03+00:00" }, { "name": "utopia-php/locale", From 44ba052fcb30dbb4f00f225166db44a34539d619 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Mon, 28 Jun 2021 09:19:33 +0200 Subject: [PATCH 11/14] feat(db): improved connection pools --- Dockerfile | 2 +- app/cli.php | 2 +- app/controllers/api/account.php | 7 +- app/controllers/api/health.php | 17 +++-- app/controllers/shared/api.php | 8 +-- app/http.php | 14 ++-- app/init.php | 47 ++++++++----- app/workers/certificates.php | 5 +- app/workers/deletes.php | 12 +++- app/workers/functions.php | 17 ++--- app/workers/tasks.php | 5 +- composer.json | 8 +-- composer.lock | 86 ++++++++++++------------ src/Appwrite/Database/Adapter/MySQL.php | 46 +++++++------ src/Appwrite/Database/Adapter/Redis.php | 15 ++--- src/Appwrite/Database/Pool.php | 20 ------ src/Appwrite/Database/Pool/PDOPool.php | 49 -------------- src/Appwrite/Database/Pool/RedisPool.php | 42 ------------ 18 files changed, 160 insertions(+), 242 deletions(-) delete mode 100644 src/Appwrite/Database/Pool.php delete mode 100644 src/Appwrite/Database/Pool/PDOPool.php delete mode 100644 src/Appwrite/Database/Pool/RedisPool.php diff --git a/Dockerfile b/Dockerfile index 00958f3f1..5e0db5fbc 100755 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,7 @@ RUN composer update --ignore-platform-reqs --optimize-autoloader \ FROM php:8.0-cli-alpine as step1 ENV PHP_REDIS_VERSION=5.3.4 \ - PHP_SWOOLE_VERSION=v4.6.6 \ + PHP_SWOOLE_VERSION=v4.6.7 \ PHP_IMAGICK_VERSION=master \ PHP_YAML_VERSION=2.2.1 \ PHP_MAXMINDDB_VERSION=v1.10.1 diff --git a/app/cli.php b/app/cli.php index ced2fb8da..ee6fe1a80 100644 --- a/app/cli.php +++ b/app/cli.php @@ -1,6 +1,6 @@ label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_LOG_LIST) ->inject('response') - ->inject('register') ->inject('project') ->inject('user') ->inject('locale') ->inject('geodb') - ->action(function ($response, $register, $project, $user, $locale, $geodb) { + ->inject('app') + ->action(function ($response, $project, $user, $locale, $geodb, $app) { /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Document $project */ /** @var Appwrite\Database\Document $user */ /** @var Utopia\Locale\Locale $locale */ /** @var MaxMind\Db\Reader $geodb */ + /** @var Utopia\App $app */ - $adapter = new AuditAdapter($register->get('db')); + $adapter = new AuditAdapter($app->getResource('db')); $adapter->setNamespace('app_'.$project->getId()); $audit = new Audit($adapter); diff --git a/app/controllers/api/health.php b/app/controllers/api/health.php index dbbd59f8c..a161b2bde 100644 --- a/app/controllers/api/health.php +++ b/app/controllers/api/health.php @@ -42,12 +42,11 @@ App::get('/v1/health/db') ->label('sdk.method', 'getDB') ->label('sdk.description', '/docs/references/health/get-db.md') ->inject('response') - ->inject('register') - ->action(function ($response, $register) { + ->inject('app') + ->action(function ($response, $app) { /** @var Appwrite\Utopia\Response $response */ - /** @var Utopia\Registry\Registry $register */ - - $register->get('db'); /* @var $db PDO */ + /** @var Utopia\App $app */ + $app->getResource('db'); $response->json(['status' => 'OK']); }); @@ -61,11 +60,11 @@ App::get('/v1/health/cache') ->label('sdk.method', 'getCache') ->label('sdk.description', '/docs/references/health/get-cache.md') ->inject('response') - ->inject('register') - ->action(function ($response, $register) { + ->inject('app') + ->action(function ($response, $app) { /** @var Appwrite\Utopia\Response $response */ - /** @var Utopia\Registry\Registry $register */ - $register->get('cache'); /* @var $cache Predis\Client */ + /** @var Utopia\App $register */ + $app->getResource('cache'); $response->json(['status' => 'OK']); }); diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 1e4f5dede..c68e7d86b 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -9,7 +9,7 @@ use Utopia\Abuse\Adapters\TimeLimit; use Utopia\Storage\Device\Local; use Utopia\Storage\Storage; -App::init(function ($utopia, $request, $response, $project, $user, $register, $events, $audits, $usage, $deletes) { +App::init(function ($utopia, $request, $response, $project, $user, $register, $events, $audits, $usage, $deletes, $db) { /** @var Utopia\App $utopia */ /** @var Utopia\Swoole\Request $request */ /** @var Appwrite\Utopia\Response $response */ @@ -34,8 +34,8 @@ App::init(function ($utopia, $request, $response, $project, $user, $register, $e /* * Abuse Check */ - $timeLimit = new TimeLimit($route->getLabel('abuse-key', 'url:{url},ip:{ip}'), $route->getLabel('abuse-limit', 0), $route->getLabel('abuse-time', 3600), function () use ($register) { - return $register->get('db'); + $timeLimit = new TimeLimit($route->getLabel('abuse-key', 'url:{url},ip:{ip}'), $route->getLabel('abuse-limit', 0), $route->getLabel('abuse-time', 3600), function () use (&$db) { + return $db; }); $timeLimit->setNamespace('app_'.$project->getId()); $timeLimit @@ -111,7 +111,7 @@ App::init(function ($utopia, $request, $response, $project, $user, $register, $e ->setParam('projectId', $project->getId()) ; -}, ['utopia', 'request', 'response', 'project', 'user', 'register', 'events', 'audits', 'usage', 'deletes'], 'api'); +}, ['utopia', 'request', 'response', 'project', 'user', 'register', 'events', 'audits', 'usage', 'deletes', 'db'], 'api'); App::init(function ($utopia, $request, $response, $project, $user) { diff --git a/app/http.php b/app/http.php index 2fced63f4..6b216da80 100644 --- a/app/http.php +++ b/app/http.php @@ -3,8 +3,6 @@ require_once __DIR__.'/../vendor/autoload.php'; use Appwrite\Database\Validator\Authorization; -use Utopia\Swoole\Files; -use Utopia\Swoole\Request; use Appwrite\Utopia\Response; use Swoole\Process; use Swoole\Http\Server; @@ -12,6 +10,8 @@ use Swoole\Http\Request as SwooleRequest; use Swoole\Http\Response as SwooleResponse; use Utopia\App; use Utopia\CLI\Console; +use Utopia\Swoole\Files; +use Utopia\Swoole\Request; $http = new Server("0.0.0.0", App::getEnv('PORT', 80)); @@ -75,18 +75,22 @@ $http->on('request', function (SwooleRequest $swooleRequest, SwooleResponse $swo return; } + $app = new App('UTC'); + $db = $register->get('dbPool')->get(); $redis = $register->get('redisPool')->get(); - $register->set('db', function () use (&$db) { + App::setResource('db', function () use (&$db) { return $db; }); - $register->set('cache', function () use (&$redis) { + App::setResource('cache', function () use (&$redis) { return $redis; }); - $app = new App('UTC'); + App::setResource('app', function() use (&$app) { + return $app; + }); try { Authorization::cleanRoles(); diff --git a/app/init.php b/app/init.php index 3e83893c7..0dd2ed150 100644 --- a/app/init.php +++ b/app/init.php @@ -24,8 +24,6 @@ use Appwrite\Database\Database; use Appwrite\Database\Adapter\MySQL as MySQLAdapter; use Appwrite\Database\Adapter\Redis as RedisAdapter; use Appwrite\Database\Document; -use Appwrite\Database\Pool\PDOPool; -use Appwrite\Database\Pool\RedisPool; use Appwrite\Database\Validator\Authorization; use Appwrite\Event\Event; use Appwrite\OpenSSL\OpenSSL; @@ -36,6 +34,10 @@ use Utopia\Locale\Locale; use Utopia\Registry\Registry; use MaxMind\Db\Reader; use PHPMailer\PHPMailer\PHPMailer; +use Swoole\Database\PDOConfig; +use Swoole\Database\PDOPool; +use Swoole\Database\RedisConfig; +use Swoole\Database\RedisPool; const APP_NAME = 'Appwrite'; const APP_DOMAIN = 'appwrite.io'; @@ -153,10 +155,21 @@ Database::addFilter('encrypt', */ $register->set('dbPool', function () { // Register DB connection $dbHost = App::getEnv('_APP_DB_HOST', ''); + $dbPort = App::getEnv('_APP_DB_PORT', ''); $dbUser = App::getEnv('_APP_DB_USER', ''); $dbPass = App::getEnv('_APP_DB_PASS', ''); $dbScheme = App::getEnv('_APP_DB_SCHEMA', ''); - $pool = new PDOPool(10, $dbHost, $dbScheme, $dbUser, $dbPass); + + + $pool = new PDOPool((new PDOConfig()) + ->withHost($dbHost) + ->withPort($dbPort) + // ->withUnixSocket('/tmp/mysql.sock') + ->withDbName($dbScheme) + ->withCharset('utf8mb4') + ->withUsername($dbUser) + ->withPassword($dbPass) + ); return $pool; }); @@ -165,16 +178,18 @@ $register->set('redisPool', function () { $redisPort = App::getEnv('_APP_REDIS_PORT', ''); $redisUser = App::getEnv('_APP_REDIS_USER', ''); $redisPass = App::getEnv('_APP_REDIS_PASS', ''); - $redisAuth = []; + $redisAuth = ''; - if ($redisUser) { - $redisAuth[] = $redisUser; - } - if ($redisPass) { - $redisAuth[] = $redisPass; + if ($redisUser && $redisPass) { + $redisAuth = $redisUser.':'.$redisPass; } - $pool = new RedisPool(10, $redisHost, $redisPort, $redisAuth); + $pool = new RedisPool((new RedisConfig) + ->withHost($redisHost) + ->withPort($redisPort) + ->withAuth($redisAuth) + ->withDbIndex(0) + ); return $pool; }); @@ -479,23 +494,23 @@ App::setResource('console', function($consoleDB) { return $consoleDB->getDocument('console'); }, ['consoleDB']); -App::setResource('consoleDB', function($register) { +App::setResource('consoleDB', function($db, $cache) { $consoleDB = new Database(); - $consoleDB->setAdapter(new RedisAdapter(new MySQLAdapter($register), $register)); + $consoleDB->setAdapter(new RedisAdapter(new MySQLAdapter($db, $cache), $cache)); $consoleDB->setNamespace('app_console'); // Should be replaced with param if we want to have parent projects $consoleDB->setMocks(Config::getParam('collections', [])); return $consoleDB; -}, ['register']); +}, ['db', 'cache']); -App::setResource('projectDB', function($register, $project) { +App::setResource('projectDB', function($db, $cache, $project) { $projectDB = new Database(); - $projectDB->setAdapter(new RedisAdapter(new MySQLAdapter($register), $register)); + $projectDB->setAdapter(new RedisAdapter(new MySQLAdapter($db, $cache), $cache)); $projectDB->setNamespace('app_'.$project->getId()); $projectDB->setMocks(Config::getParam('collections', [])); return $projectDB; -}, ['register', 'project']); +}, ['db', 'cache', 'project']); App::setResource('mode', function($request) { /** @var Utopia\Swoole\Request $request */ diff --git a/app/workers/certificates.php b/app/workers/certificates.php index b44b2e44d..bc746775c 100644 --- a/app/workers/certificates.php +++ b/app/workers/certificates.php @@ -28,8 +28,11 @@ class CertificatesV1 extends Worker { global $register; + $db = $register->get('db'); + $cache = $register->get('cache'); + $consoleDB = new Database(); - $consoleDB->setAdapter(new RedisAdapter(new MySQLAdapter($register), $register)); + $consoleDB->setAdapter(new RedisAdapter(new MySQLAdapter($db, $cache), $cache)); $consoleDB->setNamespace('app_console'); // Main DB $consoleDB->setMocks(Config::getParam('collections', [])); diff --git a/app/workers/deletes.php b/app/workers/deletes.php index 006c38c6d..f2931de31 100644 --- a/app/workers/deletes.php +++ b/app/workers/deletes.php @@ -358,9 +358,12 @@ class DeletesV1 extends Worker { global $register; + $db = $register->get('db'); + $cache = $register->get('cache'); + if($this->consoleDB === null) { $this->consoleDB = new Database(); - $this->consoleDB->setAdapter(new RedisAdapter(new MySQLAdapter($register), $register)); + $this->consoleDB->setAdapter(new RedisAdapter(new MySQLAdapter($db, $cache), $cache));; $this->consoleDB->setNamespace('app_console'); // Main DB $this->consoleDB->setMocks(Config::getParam('collections', [])); } @@ -374,9 +377,12 @@ class DeletesV1 extends Worker protected function getProjectDB($projectId): Database { global $register; - + + $db = $register->get('db'); + $cache = $register->get('cache'); + $projectDB = new Database(); - $projectDB->setAdapter(new RedisAdapter(new MySQLAdapter($register), $register)); + $projectDB->setAdapter(new RedisAdapter(new MySQLAdapter($db, $cache), $cache)); $projectDB->setNamespace('app_'.$projectId); // Main DB $projectDB->setMocks(Config::getParam('collections', [])); diff --git a/app/workers/functions.php b/app/workers/functions.php index 82d1abcec..2fd54587d 100644 --- a/app/workers/functions.php +++ b/app/workers/functions.php @@ -137,6 +137,9 @@ class FunctionsV1 extends Worker { global $register; + $db = $register->get('db'); + $cache = $register->get('cache'); + $projectId = $this->args['projectId'] ?? ''; $functionId = $this->args['functionId'] ?? ''; $webhooks = $this->args['webhooks'] ?? []; @@ -150,7 +153,7 @@ class FunctionsV1 extends Worker $jwt = $this->args['jwt'] ?? ''; $database = new Database(); - $database->setAdapter(new RedisAdapter(new MySQLAdapter($register), $register)); + $database->setAdapter(new RedisAdapter(new MySQLAdapter($db, $cache), $cache)); $database->setNamespace('app_'.$projectId); $database->setMocks(Config::getParam('collections', [])); @@ -484,17 +487,7 @@ class FunctionsV1 extends Worker ->setParam('userId', $userId) ->setParam('webhooks', $webhooks) ->setParam('event', 'functions.executions.update') - ->setParam('eventData', [ - '$id' => $execution['$id'], - 'functionId' => $execution['functionId'], - 'dateCreated' => $execution['dateCreated'], - 'trigger' => $execution['trigger'], - 'status' => $execution['status'], - 'exitCode' => $execution['exitCode'], - 'stdout' => $execution['stdout'], - 'stderr' => $execution['stderr'], - 'time' => $execution['time'] - ]); + ->setParam('eventData', $execution->getArrayCopy()); $executionUpdate->trigger(); diff --git a/app/workers/tasks.php b/app/workers/tasks.php index f9a9b6f5d..0b1b33e23 100644 --- a/app/workers/tasks.php +++ b/app/workers/tasks.php @@ -30,8 +30,11 @@ class TasksV1 extends Worker { global $register; + $db = $register->get('db'); + $cache = $register->get('cache'); + $consoleDB = new Database(); - $consoleDB->setAdapter(new RedisAdapter(new MySQLAdapter($register), $register)); + $consoleDB->setAdapter(new RedisAdapter(new MySQLAdapter($db, $cache), $cache)); $consoleDB->setNamespace('app_console'); // Main DB $consoleDB->setMocks(Config::getParam('collections', [])); diff --git a/composer.json b/composer.json index 1f1816d4d..db99dbfe5 100644 --- a/composer.json +++ b/composer.json @@ -53,18 +53,18 @@ "utopia-php/storage": "0.5.*", "utopia-php/image": "0.5.*", "resque/php-resque": "1.3.6", - "matomo/device-detector": "4.2.2", + "matomo/device-detector": "4.2.3", "dragonmantank/cron-expression": "3.1.0", "influxdb/influxdb-php": "1.15.2", "phpmailer/phpmailer": "6.5.0", "chillerlan/php-qrcode": "4.3.0", "adhocore/jwt": "1.1.2", - "slickdeals/statsd": "3.0.2" + "slickdeals/statsd": "3.1.0" }, "require-dev": { "appwrite/sdk-generator": "0.10.11", - "swoole/ide-helper": "4.6.6", - "phpunit/phpunit": "9.5.4", + "swoole/ide-helper": "4.6.7", + "phpunit/phpunit": "9.5.6", "vimeo/psalm": "4.7.2" }, "provide": { diff --git a/composer.lock b/composer.lock index cb3af8cee..df5ab61d4 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ba882fb2e25e5d4304a6574986a6a7e9", + "content-hash": "f9c370c2efc59f40eaf02857a7f4e389", "packages": [ { "name": "adhocore/jwt", @@ -115,16 +115,16 @@ }, { "name": "appwrite/php-runtimes", - "version": "dev-main", + "version": "0.3.0", "source": { "type": "git", "url": "https://github.com/appwrite/php-runtimes.git", - "reference": "cc7090a67d8824c779190b38873f0f8154f906b2" + "reference": "39be003cdff22c8447de151921001eb5d3bf2319" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/php-runtimes/zipball/cc7090a67d8824c779190b38873f0f8154f906b2", - "reference": "cc7090a67d8824c779190b38873f0f8154f906b2", + "url": "https://api.github.com/repos/appwrite/php-runtimes/zipball/39be003cdff22c8447de151921001eb5d3bf2319", + "reference": "39be003cdff22c8447de151921001eb5d3bf2319", "shasum": "" }, "require": { @@ -136,7 +136,6 @@ "utopia-php/cli": "0.11.*", "vimeo/psalm": "4.0.1" }, - "default-branch": true, "type": "library", "autoload": { "psr-4": { @@ -145,7 +144,7 @@ }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "BSD-3" ], "authors": [ { @@ -165,9 +164,9 @@ ], "support": { "issues": "https://github.com/appwrite/php-runtimes/issues", - "source": "https://github.com/appwrite/php-runtimes/tree/main" + "source": "https://github.com/appwrite/php-runtimes/tree/0.3.0" }, - "time": "2021-06-23T07:17:12+00:00" + "time": "2021-06-15T07:52:43+00:00" }, { "name": "chillerlan/php-qrcode", @@ -716,16 +715,16 @@ }, { "name": "matomo/device-detector", - "version": "4.2.2", + "version": "4.2.3", "source": { "type": "git", "url": "https://github.com/matomo-org/device-detector.git", - "reference": "dc270e7645d286d6f01d516a6634aba8b31ad668" + "reference": "d879f07496d6e6ee89cef5bcd925383d9b0c2cc0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/matomo-org/device-detector/zipball/dc270e7645d286d6f01d516a6634aba8b31ad668", - "reference": "dc270e7645d286d6f01d516a6634aba8b31ad668", + "url": "https://api.github.com/repos/matomo-org/device-detector/zipball/d879f07496d6e6ee89cef5bcd925383d9b0c2cc0", + "reference": "d879f07496d6e6ee89cef5bcd925383d9b0c2cc0", "shasum": "" }, "require": { @@ -781,7 +780,7 @@ "source": "https://github.com/matomo-org/matomo", "wiki": "https://dev.matomo.org/" }, - "time": "2021-02-26T07:31:42+00:00" + "time": "2021-05-12T14:14:25+00:00" }, { "name": "mustangostang/spyc", @@ -1193,31 +1192,33 @@ }, { "name": "slickdeals/statsd", - "version": "3.0.2", + "version": "3.1.0", "source": { "type": "git", "url": "https://github.com/Slickdeals/statsd-php.git", - "reference": "393c6565efbfb23c8296ae3099a62fb6366c6ce3" + "reference": "225588a0a079e145359049f6e5e23eedb1b4c17f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Slickdeals/statsd-php/zipball/393c6565efbfb23c8296ae3099a62fb6366c6ce3", - "reference": "393c6565efbfb23c8296ae3099a62fb6366c6ce3", + "url": "https://api.github.com/repos/Slickdeals/statsd-php/zipball/225588a0a079e145359049f6e5e23eedb1b4c17f", + "reference": "225588a0a079e145359049f6e5e23eedb1b4c17f", "shasum": "" }, "require": { - "php": ">= 7.2" + "php": ">= 7.3 || ^8" + }, + "replace": { + "domnikl/statsd": "self.version" }, "require-dev": { - "flyeralarm/php-code-validator": "^2.2", - "phpunit/phpunit": "~8.0", - "vimeo/psalm": "^3.4" + "friendsofphp/php-cs-fixer": "^3.0", + "phpunit/phpunit": "^9", + "vimeo/psalm": "^4.6" }, "type": "library", "autoload": { "psr-4": { - "Domnikl\\Statsd\\": "src/", - "Domnikl\\Test\\Statsd\\": "tests/unit" + "Domnikl\\Statsd\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -1231,7 +1232,7 @@ } ], "description": "a PHP client for statsd", - "homepage": "https://domnikl.github.com/statsd-php", + "homepage": "https://github.com/Slickdeals/statsd-php", "keywords": [ "Metrics", "monitoring", @@ -1240,9 +1241,10 @@ "udp" ], "support": { - "source": "https://github.com/Slickdeals/statsd-php/tree/3.0.2" + "issues": "https://github.com/Slickdeals/statsd-php/issues", + "source": "https://github.com/Slickdeals/statsd-php/tree/3.1.0" }, - "time": "2020-01-03T14:24:58+00:00" + "time": "2021-06-04T20:33:46+00:00" }, { "name": "symfony/polyfill-ctype", @@ -3818,16 +3820,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.5.4", + "version": "9.5.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "c73c6737305e779771147af66c96ca6a7ed8a741" + "reference": "fb9b8333f14e3dce976a60ef6a7e05c7c7ed8bfb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c73c6737305e779771147af66c96ca6a7ed8a741", - "reference": "c73c6737305e779771147af66c96ca6a7ed8a741", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/fb9b8333f14e3dce976a60ef6a7e05c7c7ed8bfb", + "reference": "fb9b8333f14e3dce976a60ef6a7e05c7c7ed8bfb", "shasum": "" }, "require": { @@ -3857,7 +3859,7 @@ "sebastian/global-state": "^5.0.1", "sebastian/object-enumerator": "^4.0.3", "sebastian/resource-operations": "^3.0.3", - "sebastian/type": "^2.3", + "sebastian/type": "^2.3.4", "sebastian/version": "^3.0.2" }, "require-dev": { @@ -3905,7 +3907,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.4" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.6" }, "funding": [ { @@ -3917,7 +3919,7 @@ "type": "github" } ], - "time": "2021-03-23T07:16:29+00:00" + "time": "2021-06-23T05:14:38+00:00" }, { "name": "psr/container", @@ -4933,16 +4935,16 @@ }, { "name": "swoole/ide-helper", - "version": "4.6.6", + "version": "4.6.7", "source": { "type": "git", "url": "https://github.com/swoole/ide-helper.git", - "reference": "d29d71267f8ed4e4993dc057ca53ffdb5d2703b7" + "reference": "0d1409b8274117addfe64d3ea412812a69807411" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/swoole/ide-helper/zipball/d29d71267f8ed4e4993dc057ca53ffdb5d2703b7", - "reference": "d29d71267f8ed4e4993dc057ca53ffdb5d2703b7", + "url": "https://api.github.com/repos/swoole/ide-helper/zipball/0d1409b8274117addfe64d3ea412812a69807411", + "reference": "0d1409b8274117addfe64d3ea412812a69807411", "shasum": "" }, "require-dev": { @@ -4965,7 +4967,7 @@ "description": "IDE help files for Swoole.", "support": { "issues": "https://github.com/swoole/ide-helper/issues", - "source": "https://github.com/swoole/ide-helper/tree/4.6.6" + "source": "https://github.com/swoole/ide-helper/tree/4.6.7" }, "funding": [ { @@ -4981,7 +4983,7 @@ "type": "open_collective" } ], - "time": "2021-04-22T16:38:11+00:00" + "time": "2021-05-14T16:05:16+00:00" }, { "name": "symfony/console", @@ -6004,9 +6006,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": { - "appwrite/php-runtimes": 20 - }, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { diff --git a/src/Appwrite/Database/Adapter/MySQL.php b/src/Appwrite/Database/Adapter/MySQL.php index 37d07c3a2..dcee96113 100644 --- a/src/Appwrite/Database/Adapter/MySQL.php +++ b/src/Appwrite/Database/Adapter/MySQL.php @@ -2,13 +2,12 @@ namespace Appwrite\Database\Adapter; -use Utopia\Registry\Registry; use Appwrite\Database\Adapter; use Appwrite\Database\Exception\Duplicate; use Appwrite\Database\Validator\Authorization; use Exception; use PDO; -use Redis as Client; +use Redis; class MySQL extends Adapter { @@ -23,11 +22,6 @@ class MySQL extends Adapter const OPTIONS_LIMIT_ATTRIBUTES = 1000; - /** - * @var Registry - */ - protected $register; - /** * Last modified. * @@ -42,16 +36,28 @@ class MySQL extends Adapter */ protected $debug = []; + /** + * @var PDO + */ + protected $pdo; + + /** + * @var Redis + */ + protected $redis; + /** * Constructor. * * Set connection and settings * - * @param Registry $register + * @param PDO $pdo + * @param Redis $redis */ - public function __construct(Registry $register) + public function __construct($pdo, Redis $redis) { - $this->register = $register; + $this->pdo = $pdo; + $this->redis = $redis; } /** @@ -87,8 +93,8 @@ class MySQL extends Adapter ORDER BY `order` '); - $st->bindParam(':documentUid', $document['uid'], PDO::PARAM_STR); - $st->bindParam(':documentRevision', $document['revision'], PDO::PARAM_STR); + $st->bindParam(':documentUid', $document['uid'], PDO::PARAM_STR, 32); + $st->bindParam(':documentRevision', $document['revision'], PDO::PARAM_STR, 32); $st->execute(); @@ -116,8 +122,8 @@ class MySQL extends Adapter ORDER BY `order` '); - $st->bindParam(':start', $document['uid'], PDO::PARAM_STR); - $st->bindParam(':revision', $document['revision'], PDO::PARAM_STR); + $st->bindParam(':start', $document['uid'], PDO::PARAM_STR, 32); + $st->bindParam(':revision', $document['revision'], PDO::PARAM_STR, 32); $st->execute(); @@ -933,18 +939,18 @@ class MySQL extends Adapter * * @throws Exception */ - protected function getPDO(): PDO + protected function getPDO() { - return $this->register->get('db'); + return $this->pdo; } /** * @throws Exception * - * @return Client + * @return Redis */ - protected function getRedis(): Client + protected function getRedis(): Redis { - return $this->register->get('cache'); + return $this->redis; } -} +} \ No newline at end of file diff --git a/src/Appwrite/Database/Adapter/Redis.php b/src/Appwrite/Database/Adapter/Redis.php index a1e440112..e4df234e4 100644 --- a/src/Appwrite/Database/Adapter/Redis.php +++ b/src/Appwrite/Database/Adapter/Redis.php @@ -2,7 +2,6 @@ namespace Appwrite\Database\Adapter; -use Utopia\Registry\Registry; use Appwrite\Database\Adapter; use Exception; use Redis as Client; @@ -10,9 +9,9 @@ use Redis as Client; class Redis extends Adapter { /** - * @var Registry + * @var Client */ - protected $register; + protected $redis; /** * @var Adapter @@ -23,11 +22,11 @@ class Redis extends Adapter * Redis constructor. * * @param Adapter $adapter - * @param Registry $register + * @param Client $redis */ - public function __construct(Adapter $adapter, Registry $register) + public function __construct(Adapter $adapter, Client $redis) { - $this->register = $register; + $this->redis = $redis; $this->adapter = $adapter; } @@ -261,7 +260,7 @@ class Redis extends Adapter */ protected function getRedis(): Client { - return $this->register->get('cache'); + return $this->redis; } /** @@ -281,4 +280,4 @@ class Redis extends Adapter return parent::setNamespace($namespace); } -} +} \ No newline at end of file diff --git a/src/Appwrite/Database/Pool.php b/src/Appwrite/Database/Pool.php deleted file mode 100644 index f6ab23266..000000000 --- a/src/Appwrite/Database/Pool.php +++ /dev/null @@ -1,20 +0,0 @@ -available = false; - while (!$this->pool->isEmpty()) { - $this->pool->pop(); - } - } -} diff --git a/src/Appwrite/Database/Pool/PDOPool.php b/src/Appwrite/Database/Pool/PDOPool.php deleted file mode 100644 index 75da61e6e..000000000 --- a/src/Appwrite/Database/Pool/PDOPool.php +++ /dev/null @@ -1,49 +0,0 @@ -pool = new SplQueue; - $this->size = $size; - for ($i = 0; $i < $this->size; $i++) { - $pdo = new PDO( - "mysql:" . - "host={$host};" . - "dbname={$schema};" . - "charset={$charset}", - $user, - $pass, - [ - PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4', - PDO::ATTR_TIMEOUT => 3, // Seconds - PDO::ATTR_PERSISTENT => true, - PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, - PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, - PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true - ] - ); - $this->pool->enqueue($pdo); - } - } - - public function put(PDO $pdo) - { - $this->pool->enqueue($pdo); - } - - public function get(): PDO - { - if ($this->available && count($this->pool) > 0) { - return $this->pool->dequeue(); - } - sleep(0.01); - return $this->get(); - } -} diff --git a/src/Appwrite/Database/Pool/RedisPool.php b/src/Appwrite/Database/Pool/RedisPool.php deleted file mode 100644 index 08e102abb..000000000 --- a/src/Appwrite/Database/Pool/RedisPool.php +++ /dev/null @@ -1,42 +0,0 @@ -pool = new SplQueue; - $this->size = $size; - for ($i = 0; $i < $this->size; $i++) { - $redis = new Redis(); - $redis->pconnect($host, $port); - $redis->setOption(Redis::OPT_READ_TIMEOUT, -1); - - if ($auth) { - $redis->auth($auth); - } - - $this->pool->enqueue($redis); - } - } - - public function put(Redis $redis) - { - $this->pool->enqueue($redis); - } - - public function get(): Redis - { - if ($this->available && !$this->pool->isEmpty()) { - return $this->pool->dequeue(); - } - sleep(0.1); - return $this->get(); - } -} From 91250ea52bcada7673f12703e8eb333ced441724 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Mon, 28 Jun 2021 09:55:56 +0200 Subject: [PATCH 12/14] fix(users): db connection --- app/controllers/api/users.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index 9dd13e34e..a11c65edc 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -232,18 +232,18 @@ App::get('/v1/users/:userId/logs') ->label('sdk.response.model', Response::MODEL_LOG_LIST) ->param('userId', '', new UID(), 'User unique ID.') ->inject('response') - ->inject('register') ->inject('project') ->inject('projectDB') ->inject('locale') ->inject('geodb') - ->action(function ($userId, $response, $register, $project, $projectDB, $locale, $geodb) { + ->inject('app') + ->action(function ($userId, $response, $project, $projectDB, $locale, $geodb, $app) { /** @var Appwrite\Utopia\Response $response */ - /** @var Utopia\Registry\Registry $register */ /** @var Appwrite\Database\Document $project */ /** @var Appwrite\Database\Database $projectDB */ /** @var Utopia\Locale\Locale $locale */ /** @var MaxMind\Db\Reader $geodb */ + /** @var Utopia\App $app */ $user = $projectDB->getDocument($userId); @@ -251,7 +251,7 @@ App::get('/v1/users/:userId/logs') throw new Exception('User not found', 404); } - $adapter = new AuditAdapter($register->get('db')); + $adapter = new AuditAdapter($app->getResource('db')); $adapter->setNamespace('app_'.$project->getId()); $audit = new Audit($adapter); From 49fa26b18c7e3b4cacd4f5ebb59816c8734a4c18 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Mon, 28 Jun 2021 09:56:03 +0200 Subject: [PATCH 13/14] fix model for connections --- app/workers/functions.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/workers/functions.php b/app/workers/functions.php index 2fd54587d..2bf2216bd 100644 --- a/app/workers/functions.php +++ b/app/workers/functions.php @@ -7,6 +7,7 @@ use Appwrite\Database\Adapter\Redis as RedisAdapter; use Appwrite\Database\Validator\Authorization; use Appwrite\Event\Event; use Appwrite\Resque\Worker; +use Appwrite\Utopia\Response\Model\Execution; use Cron\CronExpression; use Swoole\Runtime; use Utopia\App; @@ -480,6 +481,7 @@ class FunctionsV1 extends Worker throw new Exception('Failed saving execution to DB', 500); } + $executionModel = new Execution(); $executionUpdate = new Event('v1-webhooks', 'WebhooksV1'); $executionUpdate @@ -487,7 +489,7 @@ class FunctionsV1 extends Worker ->setParam('userId', $userId) ->setParam('webhooks', $webhooks) ->setParam('event', 'functions.executions.update') - ->setParam('eventData', $execution->getArrayCopy()); + ->setParam('eventData', $execution->getArrayCopy(array_keys($executionModel->getRules()))); $executionUpdate->trigger(); From dd47f195a01f9eba3f7088ce1bcb7019e064d611 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Mon, 28 Jun 2021 12:20:22 +0200 Subject: [PATCH 14/14] deps(composer): updated abuse library to 0.5.0 --- app/controllers/shared/api.php | 4 +--- app/workers/deletes.php | 4 +--- composer.json | 2 +- composer.lock | 14 +++++++------- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index c68e7d86b..4ebe7f32a 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -34,9 +34,7 @@ App::init(function ($utopia, $request, $response, $project, $user, $register, $e /* * Abuse Check */ - $timeLimit = new TimeLimit($route->getLabel('abuse-key', 'url:{url},ip:{ip}'), $route->getLabel('abuse-limit', 0), $route->getLabel('abuse-time', 3600), function () use (&$db) { - return $db; - }); + $timeLimit = new TimeLimit($route->getLabel('abuse-key', 'url:{url},ip:{ip}'), $route->getLabel('abuse-limit', 0), $route->getLabel('abuse-time', 3600), $db); $timeLimit->setNamespace('app_'.$project->getId()); $timeLimit ->setParam('{userId}', $user->getId()) diff --git a/app/workers/deletes.php b/app/workers/deletes.php index f2931de31..a0a5708b6 100644 --- a/app/workers/deletes.php +++ b/app/workers/deletes.php @@ -176,9 +176,7 @@ class DeletesV1 extends Worker throw new Exception('Failed to delete audit logs. No timestamp provided'); } - $timeLimit = new TimeLimit("", 0, 1, function () use ($register) { - return $register->get('db'); - }); + $timeLimit = new TimeLimit("", 0, 1, $register->get('db')); $this->deleteForProjectIds(function($projectId) use ($timeLimit, $timestamp){ $timeLimit->setNamespace('app_'.$projectId); diff --git a/composer.json b/composer.json index db99dbfe5..b6d87d91d 100644 --- a/composer.json +++ b/composer.json @@ -39,7 +39,7 @@ "appwrite/php-runtimes": "0.3.*", "utopia-php/framework": "0.14.*", - "utopia-php/abuse": "0.4.*", + "utopia-php/abuse": "0.5.*", "utopia-php/analytics": "0.2.*", "utopia-php/audit": "0.5.*", "utopia-php/cache": "0.2.*", diff --git a/composer.lock b/composer.lock index df5ab61d4..ec3bd3b80 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f9c370c2efc59f40eaf02857a7f4e389", + "content-hash": "f0045a975cc1e8215cdfef44472b702f", "packages": [ { "name": "adhocore/jwt", @@ -1327,16 +1327,16 @@ }, { "name": "utopia-php/abuse", - "version": "0.4.2", + "version": "0.5.0", "source": { "type": "git", "url": "https://github.com/utopia-php/abuse.git", - "reference": "286b52209818e5033573e6441d65adbc48a6f715" + "reference": "339c1720e5aa5314276128170463594b81f84760" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/abuse/zipball/286b52209818e5033573e6441d65adbc48a6f715", - "reference": "286b52209818e5033573e6441d65adbc48a6f715", + "url": "https://api.github.com/repos/utopia-php/abuse/zipball/339c1720e5aa5314276128170463594b81f84760", + "reference": "339c1720e5aa5314276128170463594b81f84760", "shasum": "" }, "require": { @@ -1373,9 +1373,9 @@ ], "support": { "issues": "https://github.com/utopia-php/abuse/issues", - "source": "https://github.com/utopia-php/abuse/tree/0.4.2" + "source": "https://github.com/utopia-php/abuse/tree/0.5.0" }, - "time": "2021-06-23T15:04:44+00:00" + "time": "2021-06-28T10:11:01+00:00" }, { "name": "utopia-php/analytics",