Skip to content

Commit 06ccc97

Browse files
committed
Added failing test for full sync cache bug
1 parent 273d1ae commit 06ccc97

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/cached-full-sync.phpt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--TEST--
2+
Test that full sync restores properties of already cached object
3+
--DESCRIPTION--
4+
pthreads_store_full_sync_local_properties() wasn't recursively syncing properties of objects which were already cached by the owning thread.
5+
This means that attempts to connect with dead objects would sometimes be made despite full sync taking place.
6+
This test verifies that the bug is fixed.
7+
--FILE--
8+
<?php
9+
10+
$array = new \ThreadedArray();
11+
12+
$t1 = new class($array) extends \Thread{
13+
public function __construct(
14+
private \ThreadedArray $array
15+
){}
16+
17+
public function run() : void{
18+
$this->array[] = new \ThreadedArray();
19+
}
20+
};
21+
$t1->start() && $t1->join();
22+
23+
var_dump($array);
24+
?>
25+
--EXPECT--
26+
object(ThreadedArray)#1 (1) {
27+
[0]=>
28+
object(ThreadedArray)#3 (0) {
29+
}
30+
}

0 commit comments

Comments
 (0)