1--TEST-- 2Object serialization / unserialization: properties reference containing object 3--FILE-- 4<?php 5 6function check(&$obj) { 7 var_dump($obj); 8 $ser = serialize($obj); 9 var_dump($ser); 10 11 $uobj = unserialize($ser); 12 var_dump($uobj); 13 $uobj->a = "obj->a.changed"; 14 var_dump($uobj); 15 $uobj->b = "obj->b.changed"; 16 var_dump($uobj); 17 $uobj->c = "obj->c.changed"; 18 var_dump($uobj); 19} 20 21echo "\n\n--- a refs container:\n"; 22$ext = 1; 23$obj = new stdClass; 24$obj->a = &$obj; 25$obj->b = 1; 26$obj->c = 1; 27check($obj); 28 29echo "\n\n--- a eqs container:\n"; 30$ext = 1; 31$obj = new stdClass; 32$obj->a = $obj; 33$obj->b = 1; 34$obj->c = 1; 35check($obj); 36 37echo "\n\n--- a,b ref container:\n"; 38$ext = 1; 39$obj = new stdClass; 40$obj->a = &$obj; 41$obj->b = &$obj; 42$obj->c = 1; 43check($obj); 44 45echo "\n\n--- a,b eq container:\n"; 46$ext = 1; 47$obj = new stdClass; 48$obj->a = $obj; 49$obj->b = $obj; 50$obj->c = 1; 51check($obj); 52 53echo "\n\n--- a,b,c ref container:\n"; 54$ext = 1; 55$obj = new stdClass; 56$obj->a = &$obj; 57$obj->b = &$obj; 58$obj->c = &$obj; 59check($obj); 60 61echo "\n\n--- a,b,c eq container:\n"; 62$ext = 1; 63$obj = new stdClass; 64$obj->a = $obj; 65$obj->b = $obj; 66$obj->c = $obj; 67check($obj); 68 69echo "Done"; 70?> 71--EXPECTF-- 72--- a refs container: 73object(stdClass)#%d (3) { 74 ["a"]=> 75 *RECURSION* 76 ["b"]=> 77 int(1) 78 ["c"]=> 79 int(1) 80} 81string(55) "O:8:"stdClass":3:{s:1:"a";R:1;s:1:"b";i:1;s:1:"c";i:1;}" 82object(stdClass)#%d (3) { 83 ["a"]=> 84 *RECURSION* 85 ["b"]=> 86 int(1) 87 ["c"]=> 88 int(1) 89} 90object(stdClass)#%d (3) { 91 ["a"]=> 92 string(14) "obj->a.changed" 93 ["b"]=> 94 int(1) 95 ["c"]=> 96 int(1) 97} 98object(stdClass)#%d (3) { 99 ["a"]=> 100 string(14) "obj->a.changed" 101 ["b"]=> 102 string(14) "obj->b.changed" 103 ["c"]=> 104 int(1) 105} 106object(stdClass)#%d (3) { 107 ["a"]=> 108 string(14) "obj->a.changed" 109 ["b"]=> 110 string(14) "obj->b.changed" 111 ["c"]=> 112 string(14) "obj->c.changed" 113} 114 115 116--- a eqs container: 117object(stdClass)#%d (3) { 118 ["a"]=> 119 *RECURSION* 120 ["b"]=> 121 int(1) 122 ["c"]=> 123 int(1) 124} 125string(55) "O:8:"stdClass":3:{s:1:"a";r:1;s:1:"b";i:1;s:1:"c";i:1;}" 126object(stdClass)#%d (3) { 127 ["a"]=> 128 *RECURSION* 129 ["b"]=> 130 int(1) 131 ["c"]=> 132 int(1) 133} 134object(stdClass)#%d (3) { 135 ["a"]=> 136 string(14) "obj->a.changed" 137 ["b"]=> 138 int(1) 139 ["c"]=> 140 int(1) 141} 142object(stdClass)#%d (3) { 143 ["a"]=> 144 string(14) "obj->a.changed" 145 ["b"]=> 146 string(14) "obj->b.changed" 147 ["c"]=> 148 int(1) 149} 150object(stdClass)#%d (3) { 151 ["a"]=> 152 string(14) "obj->a.changed" 153 ["b"]=> 154 string(14) "obj->b.changed" 155 ["c"]=> 156 string(14) "obj->c.changed" 157} 158 159 160--- a,b ref container: 161object(stdClass)#%d (3) { 162 ["a"]=> 163 *RECURSION* 164 ["b"]=> 165 *RECURSION* 166 ["c"]=> 167 int(1) 168} 169string(55) "O:8:"stdClass":3:{s:1:"a";R:1;s:1:"b";R:1;s:1:"c";i:1;}" 170object(stdClass)#%d (3) { 171 ["a"]=> 172 *RECURSION* 173 ["b"]=> 174 *RECURSION* 175 ["c"]=> 176 int(1) 177} 178object(stdClass)#%d (3) { 179 ["a"]=> 180 &string(14) "obj->a.changed" 181 ["b"]=> 182 &string(14) "obj->a.changed" 183 ["c"]=> 184 int(1) 185} 186object(stdClass)#%d (3) { 187 ["a"]=> 188 &string(14) "obj->b.changed" 189 ["b"]=> 190 &string(14) "obj->b.changed" 191 ["c"]=> 192 int(1) 193} 194object(stdClass)#%d (3) { 195 ["a"]=> 196 &string(14) "obj->b.changed" 197 ["b"]=> 198 &string(14) "obj->b.changed" 199 ["c"]=> 200 string(14) "obj->c.changed" 201} 202 203 204--- a,b eq container: 205object(stdClass)#%d (3) { 206 ["a"]=> 207 *RECURSION* 208 ["b"]=> 209 *RECURSION* 210 ["c"]=> 211 int(1) 212} 213string(55) "O:8:"stdClass":3:{s:1:"a";r:1;s:1:"b";r:1;s:1:"c";i:1;}" 214object(stdClass)#%d (3) { 215 ["a"]=> 216 *RECURSION* 217 ["b"]=> 218 *RECURSION* 219 ["c"]=> 220 int(1) 221} 222object(stdClass)#%d (3) { 223 ["a"]=> 224 string(14) "obj->a.changed" 225 ["b"]=> 226 *RECURSION* 227 ["c"]=> 228 int(1) 229} 230object(stdClass)#%d (3) { 231 ["a"]=> 232 string(14) "obj->a.changed" 233 ["b"]=> 234 string(14) "obj->b.changed" 235 ["c"]=> 236 int(1) 237} 238object(stdClass)#%d (3) { 239 ["a"]=> 240 string(14) "obj->a.changed" 241 ["b"]=> 242 string(14) "obj->b.changed" 243 ["c"]=> 244 string(14) "obj->c.changed" 245} 246 247 248--- a,b,c ref container: 249object(stdClass)#%d (3) { 250 ["a"]=> 251 *RECURSION* 252 ["b"]=> 253 *RECURSION* 254 ["c"]=> 255 *RECURSION* 256} 257string(55) "O:8:"stdClass":3:{s:1:"a";R:1;s:1:"b";R:1;s:1:"c";R:1;}" 258object(stdClass)#%d (3) { 259 ["a"]=> 260 *RECURSION* 261 ["b"]=> 262 *RECURSION* 263 ["c"]=> 264 *RECURSION* 265} 266object(stdClass)#%d (3) { 267 ["a"]=> 268 &string(14) "obj->a.changed" 269 ["b"]=> 270 &string(14) "obj->a.changed" 271 ["c"]=> 272 &string(14) "obj->a.changed" 273} 274object(stdClass)#%d (3) { 275 ["a"]=> 276 &string(14) "obj->b.changed" 277 ["b"]=> 278 &string(14) "obj->b.changed" 279 ["c"]=> 280 &string(14) "obj->b.changed" 281} 282object(stdClass)#%d (3) { 283 ["a"]=> 284 &string(14) "obj->c.changed" 285 ["b"]=> 286 &string(14) "obj->c.changed" 287 ["c"]=> 288 &string(14) "obj->c.changed" 289} 290 291 292--- a,b,c eq container: 293object(stdClass)#%d (3) { 294 ["a"]=> 295 *RECURSION* 296 ["b"]=> 297 *RECURSION* 298 ["c"]=> 299 *RECURSION* 300} 301string(55) "O:8:"stdClass":3:{s:1:"a";r:1;s:1:"b";r:1;s:1:"c";r:1;}" 302object(stdClass)#%d (3) { 303 ["a"]=> 304 *RECURSION* 305 ["b"]=> 306 *RECURSION* 307 ["c"]=> 308 *RECURSION* 309} 310object(stdClass)#%d (3) { 311 ["a"]=> 312 string(14) "obj->a.changed" 313 ["b"]=> 314 *RECURSION* 315 ["c"]=> 316 *RECURSION* 317} 318object(stdClass)#%d (3) { 319 ["a"]=> 320 string(14) "obj->a.changed" 321 ["b"]=> 322 string(14) "obj->b.changed" 323 ["c"]=> 324 *RECURSION* 325} 326object(stdClass)#%d (3) { 327 ["a"]=> 328 string(14) "obj->a.changed" 329 ["b"]=> 330 string(14) "obj->b.changed" 331 ["c"]=> 332 string(14) "obj->c.changed" 333} 334Done 335