diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 8522022bdb..ab59c97ff7 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -11,21 +11,17 @@ Happy contributing! ## What does this PR do? -(Provide a description of what this PR does.) +(Provide a description of what this PR does and why it's needed.) ## Test Plan -(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work.) +(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Screenshots may also be helpful.) ## Related PRs and Issues -(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.) +- (Related PR or issue) -### Have you added your change to the [Changelog](https://github.com/appwrite/appwrite/blob/master/CHANGES.md)? +## Checklist -(The CHANGES.md file tracks all the changes that make it to the `main` branch. Add your change to this file in the following format) -- One line description of your PR [#pr_number](Link to your PR) - -### Have you read the [Contributing Guidelines on issues](https://github.com/appwrite/appwrite/blob/master/CONTRIBUTING.md)? - -(Write your answer here.) +- [ ] Have you read the [Contributing Guidelines on issues](https://github.com/appwrite/appwrite/blob/master/CONTRIBUTING.md)? +- [ ] If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs? diff --git a/CHANGES.md b/CHANGES.md index 361fd8cdbc..7ca561f41e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,11 @@ - Get default region from environment on project create [#4780](https://github.com/appwrite/appwrite/pull/4780) - Store build output file size [#4844](https://github.com/appwrite/appwrite/pull/4844) +# Version 1.2.1 +## Bugs +- Fix a few null safety warnings [#4654](https://github.com/appwrite/appwrite/pull/4654) +- Fix timestamp format in Realtime response [#4515](https://github.com/appwrite/appwrite/pull/4515) + # Version 1.2.0 ## Features - Added GraphQL API [#974](https://github.com/appwrite/appwrite/pull/974) diff --git a/app/controllers/api/avatars.php b/app/controllers/api/avatars.php index fbc77d69f6..75d9ad434b 100644 --- a/app/controllers/api/avatars.php +++ b/app/controllers/api/avatars.php @@ -242,8 +242,8 @@ App::get('/v1/avatars/favicon') case 'jpeg': $size = \explode('x', \strtolower($sizes)); - $sizeWidth = (int) $size[0] ?? 0; - $sizeHeight = (int) $size[1] ?? 0; + $sizeWidth = (int) ($size[0] ?? 0); + $sizeHeight = (int) ($size[1] ?? 0); if (($sizeWidth * $sizeHeight) >= $space) { $space = $sizeWidth * $sizeHeight; diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index 570ea05721..665223c660 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -66,7 +66,7 @@ App::post('/v1/storage/buckets') ->param('enabled', true, new Boolean(true), 'Is bucket enabled?', true) ->param('maximumFileSize', (int) App::getEnv('_APP_STORAGE_LIMIT', 0), new Range(1, (int) App::getEnv('_APP_STORAGE_LIMIT', 0)), 'Maximum file size allowed in bytes. Maximum allowed value is ' . Storage::human(App::getEnv('_APP_STORAGE_LIMIT', 0), 0) . '. For self-hosted setups you can change the max limit by changing the `_APP_STORAGE_LIMIT` environment variable. [Learn more about storage environment variables](docs/environment-variables#storage)', true) ->param('allowedFileExtensions', [], new ArrayList(new Text(64), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Allowed file extensions. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' extensions are allowed, each 64 characters long.', true) - ->param('compression', 'none', new WhiteList([COMPRESSION_TYPE_NONE, COMPRESSION_TYPE_GZIP, COMPRESSION_TYPE_ZSTD]), 'Compression algorithm choosen for compression. Can be one of ' . COMPRESSION_TYPE_NONE . ', [' . COMPRESSION_TYPE_GZIP . '](https://en.wikipedia.org/wiki/Gzip), or [' . COMPRESSION_TYPE_ZSTD . '](https://en.wikipedia.org/wiki/Zstd), For file size above ' . Storage::human(APP_STORAGE_READ_BUFFER, 0) . ' compression is skipped even if it\'s enabled', true) + ->param('compression', COMPRESSION_TYPE_NONE, new WhiteList([COMPRESSION_TYPE_NONE, COMPRESSION_TYPE_GZIP, COMPRESSION_TYPE_ZSTD]), 'Compression algorithm choosen for compression. Can be one of ' . COMPRESSION_TYPE_NONE . ', [' . COMPRESSION_TYPE_GZIP . '](https://en.wikipedia.org/wiki/Gzip), or [' . COMPRESSION_TYPE_ZSTD . '](https://en.wikipedia.org/wiki/Zstd), For file size above ' . Storage::human(APP_STORAGE_READ_BUFFER, 0) . ' compression is skipped even if it\'s enabled', true) ->param('encryption', true, new Boolean(true), 'Is encryption enabled? For file size above ' . Storage::human(APP_STORAGE_READ_BUFFER, 0) . ' encryption is skipped even if it\'s enabled', true) ->param('antivirus', true, new Boolean(true), 'Is virus scanning enabled? For file size above ' . Storage::human(APP_LIMIT_ANTIVIRUS, 0) . ' AntiVirus scanning is skipped even if it\'s enabled', true) ->inject('response') @@ -238,7 +238,7 @@ App::put('/v1/storage/buckets/:bucketId') ->param('enabled', true, new Boolean(true), 'Is bucket enabled?', true) ->param('maximumFileSize', null, new Range(1, (int) App::getEnv('_APP_STORAGE_LIMIT', 0)), 'Maximum file size allowed in bytes. Maximum allowed value is ' . Storage::human((int)App::getEnv('_APP_STORAGE_LIMIT', 0), 0) . '. For self hosted version you can change the limit by changing _APP_STORAGE_LIMIT environment variable. [Learn more about storage environment variables](docs/environment-variables#storage)', true) ->param('allowedFileExtensions', [], new ArrayList(new Text(64), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Allowed file extensions. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' extensions are allowed, each 64 characters long.', true) - ->param('compression', 'none', new WhiteList([COMPRESSION_TYPE_NONE, COMPRESSION_TYPE_GZIP, COMPRESSION_TYPE_ZSTD]), 'Compression algorithm choosen for compression. Can be one of ' . COMPRESSION_TYPE_NONE . ', [' . COMPRESSION_TYPE_GZIP . '](https://en.wikipedia.org/wiki/Gzip), or [' . COMPRESSION_TYPE_ZSTD . '](https://en.wikipedia.org/wiki/Zstd), For file size above ' . Storage::human(APP_STORAGE_READ_BUFFER, 0) . ' compression is skipped even if it\'s enabled', true) + ->param('compression', COMPRESSION_TYPE_NONE, new WhiteList([COMPRESSION_TYPE_NONE, COMPRESSION_TYPE_GZIP, COMPRESSION_TYPE_ZSTD]), 'Compression algorithm choosen for compression. Can be one of ' . COMPRESSION_TYPE_NONE . ', [' . COMPRESSION_TYPE_GZIP . '](https://en.wikipedia.org/wiki/Gzip), or [' . COMPRESSION_TYPE_ZSTD . '](https://en.wikipedia.org/wiki/Zstd), For file size above ' . Storage::human(APP_STORAGE_READ_BUFFER, 0) . ' compression is skipped even if it\'s enabled', true) ->param('encryption', true, new Boolean(true), 'Is encryption enabled? For file size above ' . Storage::human(APP_STORAGE_READ_BUFFER, 0) . ' encryption is skipped even if it\'s enabled', true) ->param('antivirus', true, new Boolean(true), 'Is virus scanning enabled? For file size above ' . Storage::human(APP_LIMIT_ANTIVIRUS, 0) . ' AntiVirus scanning is skipped even if it\'s enabled', true) ->inject('response') @@ -517,14 +517,14 @@ App::post('/v1/storage/buckets/:bucketId/files') $mimeType = $deviceFiles->getFileMimeType($path); // Get mime-type before compression and encryption $data = ''; // Compression - $algorithm = $bucket->getAttribute('compression', 'none'); - if ($fileSize <= APP_STORAGE_READ_BUFFER && $algorithm != 'none') { + $algorithm = $bucket->getAttribute('compression', COMPRESSION_TYPE_NONE); + if ($fileSize <= APP_STORAGE_READ_BUFFER && $algorithm != COMPRESSION_TYPE_NONE) { $data = $deviceFiles->read($path); switch ($algorithm) { - case 'zstd': + case COMPRESSION_TYPE_ZSTD: $compressor = new Zstd(); break; - case 'gzip': + case COMPRESSION_TYPE_GZIP: default: $compressor = new GZIP(); break; @@ -550,6 +550,11 @@ App::post('/v1/storage/buckets/:bucketId/files') $sizeActual = $deviceFiles->getFileSize($path); $fileHash = $deviceFiles->getFileHash($path); + $openSSLVersion = null; + $openSSLCipher = null; + $openSSLTag = null; + $openSSLIV = null; + if ($bucket->getAttribute('encryption', true) && $fileSize <= APP_STORAGE_READ_BUFFER) { $openSSLVersion = '1'; $openSSLCipher = OpenSSL::CIPHER_AES_128_GCM; diff --git a/app/realtime.php b/app/realtime.php index 4b40e2a9dd..b1605f4b87 100644 --- a/app/realtime.php +++ b/app/realtime.php @@ -261,7 +261,7 @@ $server->onWorkerStart(function (int $workerId) use ($server, $register, $stats, 'data' => [ 'events' => ['stats.connections'], 'channels' => ['project'], - 'timestamp' => DateTime::now(), + 'timestamp' => DateTime::formatTz(DateTime::now()), 'payload' => [ $projectId => $payload[$projectId] ] @@ -288,7 +288,7 @@ $server->onWorkerStart(function (int $workerId) use ($server, $register, $stats, 'data' => [ 'events' => ['test.event'], 'channels' => ['tests'], - 'timestamp' => DateTime::now(), + 'timestamp' => DateTime::formatTz(DateTime::now()), 'payload' => $payload ] ]; diff --git a/src/Appwrite/Messaging/Adapter/Realtime.php b/src/Appwrite/Messaging/Adapter/Realtime.php index dddbc59e7f..e37d9ace77 100644 --- a/src/Appwrite/Messaging/Adapter/Realtime.php +++ b/src/Appwrite/Messaging/Adapter/Realtime.php @@ -149,7 +149,7 @@ class Realtime extends Adapter 'data' => [ 'events' => $events, 'channels' => $channels, - 'timestamp' => DateTime::now(), + 'timestamp' => DateTime::formatTz(DateTime::now()), 'payload' => $payload ] ])); diff --git a/src/Appwrite/Network/Validator/CNAME.php b/src/Appwrite/Network/Validator/CNAME.php index 93a302b962..678a57cecd 100644 --- a/src/Appwrite/Network/Validator/CNAME.php +++ b/src/Appwrite/Network/Validator/CNAME.php @@ -46,6 +46,10 @@ class CNAME extends Validator return false; } + if (!$records) { + return false; + } + foreach ($records as $record) { if (isset($record['target']) && $record['target'] === $this->target) { return true; diff --git a/src/Appwrite/Utopia/Response/Model/Func.php b/src/Appwrite/Utopia/Response/Model/Func.php index 540b143876..c4044c0f2e 100644 --- a/src/Appwrite/Utopia/Response/Model/Func.php +++ b/src/Appwrite/Utopia/Response/Model/Func.php @@ -85,7 +85,7 @@ class Func extends Model 'type' => self::TYPE_INTEGER, 'description' => 'Function execution timeout in seconds.', 'default' => 15, - 'example' => 1592981237, + 'example' => 15, ]) ; }