Commit 8a812c3
committed
Fix GH-12215: Module entry being overwritten causes type errors in ext/dom (PHP 8.4)
When we try to load an extension multiple times, we still overwrite the
type, module number, and handle. If the module number is used to
indicate module boundaries (e.g. in reflection and in dom, see e.g.
dom_objects_set_class_ex), then all sorts of errors can happen.
In the case of ext/dom, OP's error happens because the following
happens:
- The property handler is set up incorrectly in
dom_objects_set_class_ex() because the wrong module number is
specified. The class highest in the hierarchy is DOMNode, so the
property handler is incorrectly set to that of DOMNode instead of
DOMDocument.
- The documentElement property doesn't exist on DOMNode, it only exists
on DOMDocument, so it tries to read using zend_std_read_property().
As there is no user property called documentElement, that read
operation returns an undef value.
However, the type is still checked, resulting in the strange exception.
Solve this by changing the API such that the data is only overwritten if
it's owned data.
Closes GH-12246.1 parent aab6bbc commit 8a812c3
File tree
6 files changed
+22
-19
lines changed- Zend
- ext/standard
- sapi/phpdbg
6 files changed
+22
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
17 | 22 | | |
18 | 23 | | |
19 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2446 | 2446 | | |
2447 | 2447 | | |
2448 | 2448 | | |
2449 | | - | |
| 2449 | + | |
2450 | 2450 | | |
2451 | 2451 | | |
2452 | 2452 | | |
| |||
2483 | 2483 | | |
2484 | 2484 | | |
2485 | 2485 | | |
2486 | | - | |
| 2486 | + | |
2487 | 2487 | | |
2488 | 2488 | | |
| 2489 | + | |
| 2490 | + | |
2489 | 2491 | | |
2490 | 2492 | | |
2491 | 2493 | | |
| |||
2495 | 2497 | | |
2496 | 2498 | | |
2497 | 2499 | | |
2498 | | - | |
| 2500 | + | |
| 2501 | + | |
| 2502 | + | |
| 2503 | + | |
2499 | 2504 | | |
2500 | 2505 | | |
2501 | 2506 | | |
| |||
2511 | 2516 | | |
2512 | 2517 | | |
2513 | 2518 | | |
2514 | | - | |
2515 | | - | |
2516 | | - | |
| 2519 | + | |
2517 | 2520 | | |
2518 | 2521 | | |
2519 | 2522 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
375 | 375 | | |
376 | 376 | | |
377 | 377 | | |
378 | | - | |
| 378 | + | |
379 | 379 | | |
380 | 380 | | |
381 | 381 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
63 | | - | |
64 | | - | |
| 62 | + | |
65 | 63 | | |
66 | 64 | | |
67 | 65 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | 233 | | |
237 | | - | |
| 234 | + | |
238 | 235 | | |
239 | 236 | | |
240 | 237 | | |
241 | 238 | | |
| 239 | + | |
| 240 | + | |
242 | 241 | | |
243 | 242 | | |
244 | 243 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1314 | 1314 | | |
1315 | 1315 | | |
1316 | 1316 | | |
1317 | | - | |
1318 | | - | |
1319 | | - | |
1320 | | - | |
1321 | | - | |
| 1317 | + | |
1322 | 1318 | | |
1323 | 1319 | | |
1324 | 1320 | | |
1325 | 1321 | | |
1326 | 1322 | | |
| 1323 | + | |
| 1324 | + | |
1327 | 1325 | | |
1328 | 1326 | | |
1329 | 1327 | | |
| |||
0 commit comments