Release v3.1.47 (#7180)
Some checks are pending
Mirror to CNB Repo / git-mirror (push) Waiting to run
Mirror to Gitee Repo / git-mirror (push) Waiting to run
Test for Hyperf Components / Test for Database (5.7, 8.1) (push) Waiting to run
Test for Hyperf Components / Test for Database (5.7, 8.2) (push) Waiting to run
Test for Hyperf Components / Test for Database (5.7, 8.3) (push) Waiting to run
Test for Hyperf Components / Test for Database (8.0, 8.1) (push) Waiting to run
Test for Hyperf Components / Test for Database (8.0, 8.2) (push) Waiting to run
Test for Hyperf Components / Test for Database (8.0, 8.3) (push) Waiting to run
Test for Hyperf Components / Test for Database (8.4, 8.1) (push) Waiting to run
Test for Hyperf Components / Test for Database (8.4, 8.2) (push) Waiting to run
Test for Hyperf Components / Test for Database (8.4, 8.3) (push) Waiting to run
Test for Hyperf Components / Test for Filesystem (8.1, ^1.0) (push) Waiting to run
Test for Hyperf Components / Test for Filesystem (8.1, ^2.0) (push) Waiting to run
Test for Hyperf Components / Test for Filesystem (8.1, ^3.0) (push) Waiting to run
Test for Hyperf Components / Test for Filesystem (8.2, ^1.0) (push) Waiting to run
Test for Hyperf Components / Test for Filesystem (8.2, ^2.0) (push) Waiting to run
Test for Hyperf Components / Test for Filesystem (8.2, ^3.0) (push) Waiting to run
Test for Hyperf Components / Test for Filesystem (8.3, ^1.0) (push) Waiting to run
Test for Hyperf Components / Test for Filesystem (8.3, ^2.0) (push) Waiting to run
Test for Hyperf Components / Test for Filesystem (8.3, ^3.0) (push) Waiting to run
Test for Hyperf Components / Test for Building PHAR (, 8.1) (push) Waiting to run
Test for Hyperf Components / Test for Building PHAR (--no-dev, 8.1) (push) Waiting to run
Test for Hyperf Components / Test for Psr Container V1.0 ~ V2.0 (8.1, ^1.0) (push) Waiting to run
Test for Hyperf Components / Test for Psr Container V1.0 ~ V2.0 (8.1, ^2.0) (push) Waiting to run
Test for Hyperf Components / Test for Psr Container V1.0 ~ V2.0 (8.2, ^1.0) (push) Waiting to run
Test for Hyperf Components / Test for Psr Container V1.0 ~ V2.0 (8.2, ^2.0) (push) Waiting to run
Test for Hyperf Components / Test for Psr Container V1.0 ~ V2.0 (8.3, ^1.0) (push) Waiting to run
Test for Hyperf Components / Test for Psr Container V1.0 ~ V2.0 (8.3, ^2.0) (push) Waiting to run
Test for Hyperf Components / Test for Http Message V1.0 ~ V2.0 (8.1, ^1.0) (push) Waiting to run
Test for Hyperf Components / Test for Http Message V1.0 ~ V2.0 (8.1, ^2.0) (push) Waiting to run
Test for Hyperf Components / Test for Http Message V1.0 ~ V2.0 (8.2, ^1.0) (push) Waiting to run
Test for Hyperf Components / Test for Http Message V1.0 ~ V2.0 (8.2, ^2.0) (push) Waiting to run
Test for Hyperf Components / Test for Http Message V1.0 ~ V2.0 (8.3, ^1.0) (push) Waiting to run
Test for Hyperf Components / Test for Http Message V1.0 ~ V2.0 (8.3, ^2.0) (push) Waiting to run
Test for Hyperf Components / Test for Psr Log V1.0 ~ V3.0 (^1.0, 8.3) (push) Waiting to run
Test for Hyperf Components / Test for Psr Log V1.0 ~ V3.0 (^2.0, 8.1) (push) Waiting to run
Test for Hyperf Components / Test for Psr Log V1.0 ~ V3.0 (^2.0, 8.2) (push) Waiting to run
Test for Hyperf Components / Test for Psr Log V1.0 ~ V3.0 (^2.0, 8.3) (push) Waiting to run
Test for Hyperf Components / Test for Psr Log V1.0 ~ V3.0 (^3.0, 8.1) (push) Waiting to run
Test for Hyperf Components / Test for Psr Log V1.0 ~ V3.0 (^3.0, 8.2) (push) Waiting to run
Test for Hyperf Components / Test for Psr Log V1.0 ~ V3.0 (^3.0, 8.3) (push) Waiting to run
Test for Hyperf Components / Test for Psr SimpleCache V1.0 ~ V3.0 (8.1, ^1.0) (push) Waiting to run
Test for Hyperf Components / Test for Psr SimpleCache V1.0 ~ V3.0 (8.1, ^2.0) (push) Waiting to run
Test for Hyperf Components / Test for Psr SimpleCache V1.0 ~ V3.0 (8.1, ^3.0) (push) Waiting to run
Test for Hyperf Components / Test for Psr SimpleCache V1.0 ~ V3.0 (8.2, ^1.0) (push) Waiting to run
Test for Hyperf Components / Test for Psr SimpleCache V1.0 ~ V3.0 (8.2, ^2.0) (push) Waiting to run
Test for Hyperf Components / Test for Psr SimpleCache V1.0 ~ V3.0 (8.2, ^3.0) (push) Waiting to run
Test for Hyperf Components / Test for Psr SimpleCache V1.0 ~ V3.0 (8.3, ^1.0) (push) Waiting to run
Test for Hyperf Components / Test for Psr SimpleCache V1.0 ~ V3.0 (8.3, ^2.0) (push) Waiting to run
Test for Hyperf Components / Test for Psr SimpleCache V1.0 ~ V3.0 (8.3, ^3.0) (push) Waiting to run
Test for Hyperf Components / Test for Redis Module (8.1, redis) (push) Waiting to run
Test for Hyperf Components / Test for Redis Module (8.1, redis-5.3.7) (push) Waiting to run
Test for Hyperf Components / Test for Redis Module (8.2, redis) (push) Waiting to run
Test for Hyperf Components / Test for Redis Module (8.2, redis-5.3.7) (push) Waiting to run
Test for Hyperf Components / Test for Redis Module (8.3, redis) (push) Waiting to run
Test for Hyperf Components / Test for Redis Module (8.3, redis-5.3.7) (push) Waiting to run
Test for Hyperf Components / Test for Symfony (8.1, ^6.0) (push) Waiting to run
Test for Hyperf Components / Test for Symfony (8.2, ^6.0) (push) Waiting to run
Test for Hyperf Components / Test for Symfony (8.2, ^7.0) (push) Waiting to run
Test for Hyperf Components / Test for Symfony (8.3, ^6.0) (push) Waiting to run
Test for Hyperf Components / Test for Symfony (8.3, ^7.0) (push) Waiting to run
PHPUnit for Hyperf / PHP CS Fix on PHP${{ matrix.php }} ${{ matrix.swoole }} (ubuntu-latest, 8.1, swoole) (push) Waiting to run
PHPUnit for Hyperf / Test on PHP${{ matrix.php-version }} Swoole-${{ matrix.sw-version }} (ubuntu-latest, 8.1, master) (push) Blocked by required conditions
PHPUnit for Hyperf / Test on PHP${{ matrix.php-version }} Swoole-${{ matrix.sw-version }} (ubuntu-latest, 8.1, v5.0.3) (push) Blocked by required conditions
PHPUnit for Hyperf / Test on PHP${{ matrix.php-version }} Swoole-${{ matrix.sw-version }} (ubuntu-latest, 8.1, v5.1.4) (push) Blocked by required conditions
PHPUnit for Hyperf / Test on PHP${{ matrix.php-version }} Swoole-${{ matrix.sw-version }} (ubuntu-latest, 8.1, v6.0.0-alpha) (push) Blocked by required conditions
PHPUnit for Hyperf / Test on PHP${{ matrix.php-version }} Swoole-${{ matrix.sw-version }} (ubuntu-latest, 8.2, master) (push) Blocked by required conditions
PHPUnit for Hyperf / Test on PHP${{ matrix.php-version }} Swoole-${{ matrix.sw-version }} (ubuntu-latest, 8.2, v5.0.3) (push) Blocked by required conditions
PHPUnit for Hyperf / Test on PHP${{ matrix.php-version }} Swoole-${{ matrix.sw-version }} (ubuntu-latest, 8.2, v5.1.4) (push) Blocked by required conditions
PHPUnit for Hyperf / Test on PHP${{ matrix.php-version }} Swoole-${{ matrix.sw-version }} (ubuntu-latest, 8.2, v6.0.0-alpha) (push) Blocked by required conditions
PHPUnit for Hyperf / Test on PHP${{ matrix.php-version }} Swoole-${{ matrix.sw-version }} (ubuntu-latest, 8.3, master) (push) Blocked by required conditions
PHPUnit for Hyperf / Test on PHP${{ matrix.php-version }} Swoole-${{ matrix.sw-version }} (ubuntu-latest, 8.3, v5.1.4) (push) Blocked by required conditions
PHPUnit for Hyperf / Test on PHP${{ matrix.php-version }} Swoole-${{ matrix.sw-version }} (ubuntu-latest, 8.3, v6.0.0-alpha) (push) Blocked by required conditions

Co-authored-by: Anderson Ribeiro Lopes <a.alopes@ext.ppay.me>
Co-authored-by: Weslen Teche <weslen_teche@hotmail.com>
Co-authored-by: limingxinleo <limingxinleo@users.noreply.github.com>
This commit is contained in:
李铭昕 2024-11-28 10:28:20 +08:00 committed by GitHub
parent 124f1ceb7e
commit 9c179be234
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 66 additions and 36 deletions

View File

@ -1,4 +1,6 @@
# v3.1.47 - TBD
# v3.1.48 - TBD
# v3.1.47 - 2024-11-28
## Fixed

View File

@ -1,5 +1,11 @@
# Changelogs
# v3.1.47 - 2024-11-28
## Fixed
- [#7176](https://github.com/hyperf/hyperf/pull/7176) Fixed bug that cookies cannot work when using `swow`.
# v3.1.46 - 2024-11-21
## Added

View File

@ -35,7 +35,7 @@ composer require hyperf/constants
An enumeration class can be generated quickly with the `gen:constant` command.
```bash
php bin/hyperf.php gen:constant ErrorCode
php bin/hyperf.php gen:constant ErrorCode --type enum
```
```php
@ -45,25 +45,24 @@ declare(strict_types=1);
namespace App\Constants;
use Hyperf\Constants\AbstractConstants;
use Hyperf\Constants\Annotation\Constants;
use Hyperf\Constants\Annotation\Message;
use Hyperf\Constants\EnumConstantsTrait;
#[Constants]
class ErrorCode extends AbstractConstants
enum ErrorCode: int
{
/**
* @Message("Server Error!")
*/
const SERVER_ERROR = 500;
use EnumConstantsTrait;
/**
* @Message("System parameter error")
*/
const SYSTEM_INVALID = 700;
#[Message("Server Error!")]
case SERVER_ERROR = 500;
#[Message("System parameter error")]
case SYSTEM_INVALID = 700;
}
```
User can use `ErrorCode::getMessage(ErrorCode::SERVER_ERROR)` to get the corresponding error message.
User can use `ErrorCode::SERVER_ERROR->getMessage()` to get the corresponding error message.
### Define exception class
@ -82,12 +81,18 @@ use Throwable;
class BusinessException extends ServerException
{
public function __construct(int $code = 0, string $message = null, Throwable $previous = null)
public function __construct(ErrorCode|int $code = 0, ?string $message = null, ?Throwable $previous = null)
{
if (is_null($message)) {
$message = ErrorCode::getMessage($code);
if ($code instanceof ErrorCode) {
$message = $code->getMessage();
} else {
$message = ErrorCode::getMessage($code);
}
}
$code = $code instanceof ErrorCode ? $code->value : $code;
parent::__construct($message, $code, $previous);
}
}
@ -118,27 +123,25 @@ class IndexController extends AbstractController
### Variable parameter
When using `ErrorCode::getMessage(ErrorCode::SERVER_ERROR)` to get the corresponding error message, we can also pass in variable parameters to combine error messages. For example the following
When using `ErrorCode::SERVER_ERROR->getMessage()` to get the corresponding error message, we can also pass in variable parameters to combine error messages. For example the following
```php
<?php
use Hyperf\Constants\AbstractConstants;
use Hyperf\Constants\Annotation\Constants;
use Hyperf\Constants\Annotation\Message;
use Hyperf\Constants\EnumConstantsTrait;
#[Constants]
class ErrorCode extends AbstractConstants
enum ErrorCode: int
{
/**
* @Message("Params %s is invalid.")
*/
const PARAMS_INVALID = 1000;
use EnumConstantsTrait;
#[Message("Params %s is invalid.")]
case PARAMS_INVALID = 1000;
}
$message = ErrorCode::getMessage(ErrorCode::PARAMS_INVALID, ['user_id']);
// 1.2 Below version The following methods can be used, but will be removed in version 1.2
$message = ErrorCode::getMessage(ErrorCode::PARAMS_INVALID, 'user_id');
$message = ErrorCode::PARAMS_INVALID->getMessage(['user_id']);
```
### Globalization
@ -162,17 +165,18 @@ return [
'params.invalid' => 'Params :param is invalid.',
];
use Hyperf\Constants\AbstractConstants;
use Hyperf\Constants\Annotation\Constants;
use Hyperf\Constants\Annotation\Message;
use Hyperf\Constants\EnumConstantsTrait;
#[Constants]
class ErrorCode extends AbstractConstants
enum ErrorCode: int
{
/**
* @Message("params.invalid")
*/
const PARAMS_INVALID = 1000;
use EnumConstantsTrait;
#[Message("params.invalid")]
case PARAMS_INVALID = 1000;
}
$message = ErrorCode::getMessage(ErrorCode::SERVER_ERROR, ['param' => 'user_id']);
$message = ErrorCode::SERVER_ERROR->getMessage(['param' => 'user_id']);
```

View File

@ -1,4 +1,4 @@
# Excepiton Handler
# Exception Handler
In `Hyperf`, all the business code excute on `Worker Process`. In this case, once any request has an exception that has not been caught, the corresponding `Worker Process` will be interrupted and exited, which is unacceptable for the service. Catch exceptions and output reasonable error content is also more friendly to the client. We can define different `ExceptionHandlers` for each `server`, and once there are exceptions that are not caught in the process, they will be passed to the registered `ExceptionHandler` for processing.

View File

@ -294,7 +294,7 @@ return [
'class' => Handler\StreamHandler::class,
'constructor' => [
'stream' => BASE_PATH . '/runtime/logs/hyperf-debug.log',
'level' => Level::Debug,
'level' => Level::Info,
],
'formatter' => [
'class' => Formatter\JsonFormatter::class,
@ -348,7 +348,7 @@ return [
'class' => Handler\StreamHandler::class,
'constructor' => [
'stream' => BASE_PATH . '/runtime/logs/hyperf-debug.log',
'level' => Level::Debug,
'level' => Level::Info,
],
],
'formatter' => [

View File

@ -1,5 +1,11 @@
# 版本更新记录
# v3.1.47 - 2024-11-28
## Fixed
- [#7176](https://github.com/hyperf/hyperf/pull/7176) 修复使用 `Swow` 时,无法正常设置 `Cookies` 的问题。
# v3.1.46 - 2024-11-21
## 新增

View File

@ -1,5 +1,11 @@
# 版本更新記錄
# v3.1.47 - 2024-11-28
## Fixed
- [#7176](https://github.com/hyperf/hyperf/pull/7176) 修復使用 `Swow` 時,無法正常設置 `Cookies` 的問題。
# v3.1.46 - 2024-11-21
## 新增

View File

@ -1,5 +1,11 @@
# 版本更新記錄
# v3.1.47 - 2024-11-28
## Fixed
- [#7176](https://github.com/hyperf/hyperf/pull/7176) 修復使用 `Swow` 時,無法正常設定 `Cookies` 的問題。
# v3.1.46 - 2024-11-21
## 新增