Commit f49b495
Decode the framed sections on demand instead of on restore
restore() no longer hands back the errors, locally ignored errors, collected
data and exported nodes as arrays: the cache file carries them as closures, and
a run that never asks for a section never pays for it. The var_export format
does this by writing `static function (): array { return [...]; }` into the
file, which only defers the array literal - PHP still compiles it and OPCache
still holds it.
A framed file needs no such trick. Each of those sections is one array frame, so
the reader remembers where it starts, walks past its entries without
unserializing them, and hands out a callback that seeks back and decodes on
demand. Walking rather than skipping wholesale keeps the eager validation of the
whole file's framing, so a damaged cache is still discarded by restore() instead
of throwing later inside a callback. fseek() past the end of a file succeeds, so
the position is compared with the file size after every entry - a killed save
leaves exactly that kind of truncation.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent c8650cc commit f49b495
3 files changed
Lines changed: 124 additions & 7 deletions
File tree
- .github/workflows
- e2e/result-cache-truncated
- src/Analyser/ResultCache
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| 130 | + | |
| 131 | + | |
130 | 132 | | |
131 | | - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
132 | 145 | | |
133 | 146 | | |
134 | 147 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
49 | 52 | | |
50 | 53 | | |
51 | 54 | | |
| |||
68 | 71 | | |
69 | 72 | | |
70 | 73 | | |
| 74 | + | |
71 | 75 | | |
72 | 76 | | |
73 | 77 | | |
| |||
98 | 102 | | |
99 | 103 | | |
100 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
101 | 112 | | |
102 | 113 | | |
103 | 114 | | |
| |||
471 | 482 | | |
472 | 483 | | |
473 | 484 | | |
474 | | - | |
475 | | - | |
| 485 | + | |
| 486 | + | |
476 | 487 | | |
477 | 488 | | |
478 | | - | |
479 | | - | |
| 489 | + | |
| 490 | + | |
480 | 491 | | |
481 | 492 | | |
482 | 493 | | |
| |||
1346 | 1357 | | |
1347 | 1358 | | |
1348 | 1359 | | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
1349 | 1364 | | |
1350 | 1365 | | |
1351 | 1366 | | |
1352 | 1367 | | |
1353 | 1368 | | |
1354 | 1369 | | |
| 1370 | + | |
1355 | 1371 | | |
1356 | 1372 | | |
1357 | 1373 | | |
| |||
1370 | 1386 | | |
1371 | 1387 | | |
1372 | 1388 | | |
1373 | | - | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
1374 | 1408 | | |
1375 | 1409 | | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
1376 | 1420 | | |
1377 | 1421 | | |
1378 | | - | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
1379 | 1425 | | |
1380 | 1426 | | |
1381 | 1427 | | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
1382 | 1473 | | |
1383 | 1474 | | |
1384 | 1475 | | |
| |||
0 commit comments