-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[BUG] 中间件对$request 修改后 input/inputs 方法未同步 #3498
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Execute the command and paste the result below.
Command: uname -a && php -v && composer info | grep hyperf && php --ri swoole
Darwin HDJ.local 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:07:06 PST 2021; root:xnu-7195.81.3~1/RELEASE_X86_64 x86_64
PHP 7.4.16 (cli) (built: Mar 4 2021 20:52:51) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.16, Copyright (c), by Zend Technologies
hyperf/async-queue v2.1.0 A async queue component for hyperf.
hyperf/cache v2.1.8 A cache component for hyperf.
hyperf/command v2.1.0 Command for hyperf
hyperf/config v2.1.0 An independent component that provides configuration container.
hyperf/constants v2.1.0 A constants component for hyperf.
hyperf/consul v2.1.0 A Consul Client for Hyperf.
hyperf/contract v2.1.3 The contracts of Hyperf.
hyperf/crontab v2.1.13 A crontab component for Hyperf.
hyperf/database v2.1.10 A flexible database library.
hyperf/db-connection v2.1.13 A hyperf db connection handler for hyperf/database.
hyperf/devtool v2.1.6 A Devtool for Hyperf.
hyperf/di v2.1.14 A DI for Hyperf.
hyperf/dispatcher v2.1.6 A HTTP Server for Hyperf.
hyperf/engine v1.1.1
hyperf/event v2.1.0 an event manager that implements PSR-14.
hyperf/exception-handler v2.1.6 Exception handler for hyperf
hyperf/framework v2.1.1 A coroutine framework that focuses on hyperspeed and flexible, specifically use for build microservices and middlew...
hyperf/guzzle v2.1.1 Swoole coroutine handler for guzzle
hyperf/http-message v2.1.1 microservice framework base on swoole
hyperf/http-server v2.1.12 A HTTP Server for Hyperf.
hyperf/json-rpc v2.1.13 A JSON RPC component for Hyperf RPC Server or Client.
hyperf/load-balancer v2.1.0 A load balancer library for Hyperf.
hyperf/logger v2.1.0 A logger component for hyperf.
hyperf/memory v2.1.0 An independent component that use to operate and manage memory.
hyperf/model-cache v2.1.13 A model cache component for hyperf.
hyperf/model-listener v2.1.0 A model listener for Hyperf.
hyperf/pool v2.1.8 An independent universal connection pool component.
hyperf/process v2.1.7 A process component for hyperf.
hyperf/redis v2.1.3 A redis component for hyperf.
hyperf/retry v2.1.0 A retry component for hyperf.
hyperf/rpc v2.1.1 A rpc basic library for Hyperf.
hyperf/rpc-client v2.1.13 An abstract rpc server component for Hyperf.
hyperf/rpc-server v2.1.12 An abstract rpc server component for Hyperf.
hyperf/server v2.1.10 A base server library for Hyperf.
hyperf/service-governance v2.1.0 A service governance component for Hyperf.
hyperf/signal v2.1.7 A signal library for Hyperf.
hyperf/swagger v2.1.0 A swagger library for Hyperf.
hyperf/task v2.1.1 A task library for Hyperf.
hyperf/testing v2.1.12 Testing for hyperf
hyperf/translation v2.1.0 An independent translation component, forked by illuminate/translation.
hyperf/utils v2.1.14 A tools package that could help developer solved the problem quickly.
hyperf/validation v2.1.10 hyperf validation
hyperf/watcher v2.1.10
hyperf/websocket-server v2.1.14 A websocket server library for Hyperf.
swoole
Swoole => enabled
Author => Swoole Team <[email protected]>
Version => 4.6.3
Built => Mar 2 2021 14:49:52
coroutine => enabled with boost asm context
kqueue => enabled
rwlock => enabled
sockets => enabled
openssl => OpenSSL 1.1.1i 8 Dec 2020
dtls => enabled
http2 => enabled
json => enabled
curl-native => enabled
pcre => enabled
zlib => 1.2.11
brotli => E16777225/D16777225
mysqlnd => enabled
async_redis => enabled
Directive => Local Value => Master Value
swoole.enable_coroutine => On => On
swoole.enable_library => On => On
swoole.enable_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => Off => Off
swoole.unixsock_buffer_size => 262144 => 262144Description:
中间件代码:
namespace App\Middleware;
use Psr\Container\ContainerInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Throwable;
class CheckMaintainForHkMiddleware implements MiddlewareInterface
{
/**
* @var ContainerInterface
*/
protected $container;
public function __construct(ContainerInterface $container)
{
$this->container = $container;
}
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$request = $request->withQueryParams($request->getQueryParams() + ['another_param' => 'another_value']);
return $handler->handle($request);
}
}控制器代码:
namespace App\Controller;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Contract\RequestInterface;
class IndexController
{
/**
* @Inject
* @var RequestInterface
*/
protected $request;
public function index()
{
var_dump($this->request->getQueryParams()['another_param']); // 结果是 another_value
var_dump($this->request->input('another_param')); // 结果是 null
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working