webman升級(jí)到最新版本,請(qǐng)求發(fā)現(xiàn)每次請(qǐng)求的Request對(duì)象都是同一個(gè)
1.每次返回spl_object_hash都是同一個(gè)
2.每次獲取到的對(duì)象值沒(méi)有重置,假如說(shuō)我第一次請(qǐng)求 username=test,setGet后username=hello_test,
但是下次請(qǐng)求的時(shí)候,我還是傳遞username=test,但是我通過(guò)方法獲取到username直接就是hello_test,好像是個(gè)單例,沒(méi)有重置一樣,記住了上次的值
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ā)問(wèn)題一定記得發(fā)下workerman 和webman具體版本。
哦哦,不好意思
環(huán)境:
workerman版本號(hào):5.1.0
webman版本號(hào):2.1.1
php環(huán)境:8.3.17
嘗試解決:
spl_object_hash 返回同一個(gè)值,不一定代表是同一個(gè)對(duì)象。一個(gè)對(duì)象銷毀后它的spl_object_hash值可能會(huì)被復(fù)用。
你的測(cè)試我沒(méi)看懂,按照你的代碼,下次請(qǐng)求的時(shí)候,還是傳遞username=test,$request->setGet('username', $username);還是被執(zhí)行,得到hello_test沒(méi)問(wèn)題
可能表達(dá)的有問(wèn)題。
假如我第一次請(qǐng)求 傳遞 username=test,獲取到 username是test,返回 hello_test.
假如我第二次請(qǐng)求 傳遞 username=test,,獲取到 username是hello_test,返回 hello_hello_test
假如我第三次請(qǐng)求 傳遞 username=test,獲取到username是hello_hello_test,返回 hello_hello_hello_test
就是每次的請(qǐng)求把上次的值帶過(guò)來(lái)了,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..