Fix GH-17317: ResourceBundle crash on undefined iterator key#17323
Fix GH-17317: ResourceBundle crash on undefined iterator key#17323ndossche wants to merge 1 commit intophp:PHP-8.3from
Conversation
The next() and rewind() calls should be the ones fetching the data. We skip holes in the resource bundle in the same way that holes in arrays are skipped.
|
Thank you! I haven't checked very thoroughly, but this looks like a sensible solution. There is, however, an issue regarding the var_dump((new ResourceBundle('', NULL))->get('calendar')->get('buddhist')->count());reports 12, but traversal only shows 10 items. We can't change Probably not a big deal, so I'm fine merging this PR as is into PHP-8.3. |
Indeed, this one is unfortunate but we should preserve BC.
Sounds like a typical PHP solution, and inconsistent with how arrays work imo.
You can only do this if the iterator is invalid, so it's not a valid alternative solution (if you're talking about returning a NULL pointer).
This is consistent with how arrays work: <?php
$array = [0 => "a", 2 => "b"];
$array[1]; // warning & returns NULL
foreach ($array as $k=>$v) { var_dump($k, $v); } // skips 1 |
The next() and rewind() calls should be the ones fetching the data. We skip holes in the resource bundle in the same way that holes in arrays are skipped.