webman升級到最新版本,請求發(fā)現(xiàn)每次請求的Request對象都是同一個
1.每次返回spl_object_hash都是同一個
2.每次獲取到的對象值沒有重置,假如說我第一次請求 username=test,setGet后username=hello_test,
但是下次請求的時候,我還是傳遞username=test,但是我通過方法獲取到username直接就是hello_test,好像是個單例,沒有重置一樣,記住了上次的值
public function test(Request $request)
{
$username = $request->get('username');
$prefix = 'hello_';
$username = $prefix . $username;
$request->setGet('username', $username);
$error = null;
$retData = [
'username' => $request->get('username'),
'spl_object_hash' => spl_object_hash($request),
];
return $this->jsonReturn($this->_channel, $error, $retData);
}
烏班圖系統(tǒng)
webman最新版本
發(fā)問題一定記得發(fā)下workerman 和webman具體版本。
哦哦,不好意思
環(huán)境:
workerman版本號:5.1.0
webman版本號:2.1.1
php環(huán)境:8.3.17
嘗試解決:
spl_object_hash 返回同一個值,不一定代表是同一個對象。一個對象銷毀后它的spl_object_hash值可能會被復用。
你的測試我沒看懂,按照你的代碼,下次請求的時候,還是傳遞username=test,$request->setGet('username', $username);還是被執(zhí)行,得到hello_test沒問題
可能表達的有問題。
假如我第一次請求 傳遞 username=test,獲取到 username是test,返回 hello_test.
假如我第二次請求 傳遞 username=test,,獲取到 username是hello_test,返回 hello_hello_test
假如我第三次請求 傳遞 username=test,獲取到username是hello_hello_test,返回 hello_hello_hello_test
就是每次的請求把上次的值帶過來了,append上了,
workerman/coroutine 1.1.3 Workerman coroutine
workerman/webman-framework 2.1.1 High performance HTTP Service Frame...
workerman/workerman 5.1.0 An asynchronous event driven PHP fr..