-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix GH-17317: ResourceBundle crash on undefined iterator key. #17318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--TEST-- | ||
GH-17319 (ResourceBundle iterator crash on NULL key) | ||
--EXTENSIONS-- | ||
intl | ||
--CREDITS-- | ||
KidFlo | ||
Comment on lines
+5
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should add a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I disagree; I often add CREDITS section. Co-authored-by doesn't allow fine-grained tracking of what a person did, so that's a downgrade in comparison to the CREDITS section. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then we should probably change the description accordingly. :) |
||
--FILE-- | ||
<?php | ||
foreach ((new ResourceBundle('', NULL))->get('calendar')->get('buddhist') as $key => $value) { | ||
echo "KEY: "; var_dump($key); | ||
echo "VALUE: "; var_dump($value); | ||
} | ||
?> | ||
--EXPECT-- | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should use And maybe the test is overspecified; I have no idea how likely it is that the details of this resource bundle will change in ICU versions. |
||
KEY: string(15) "AmPmMarkersAbbr" | ||
VALUE: object(ResourceBundle)#3 (0) { | ||
} | ||
KEY: string(15) "AmPmMarkersAbbr" | ||
VALUE: object(ResourceBundle)#4 (0) { | ||
} | ||
KEY: string(16) "DateTimePatterns" | ||
VALUE: object(ResourceBundle)#3 (0) { | ||
} | ||
KEY: NULL | ||
VALUE: NULL | ||
KEY: NULL | ||
VALUE: NULL | ||
KEY: string(11) "appendItems" | ||
VALUE: object(ResourceBundle)#3 (0) { | ||
} | ||
KEY: string(16) "availableFormats" | ||
VALUE: object(ResourceBundle)#4 (0) { | ||
} | ||
KEY: string(8) "dayNames" | ||
VALUE: object(ResourceBundle)#3 (0) { | ||
} | ||
KEY: string(4) "eras" | ||
VALUE: object(ResourceBundle)#4 (0) { | ||
} | ||
KEY: string(15) "intervalFormats" | ||
VALUE: object(ResourceBundle)#3 (0) { | ||
} | ||
KEY: string(10) "monthNames" | ||
VALUE: object(ResourceBundle)#4 (0) { | ||
} | ||
KEY: string(8) "quarters" | ||
VALUE: object(ResourceBundle)#3 (0) { | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting this here wouldn't have any effect when users traverse over the values only. Changing it in
resourcebundle_iterator_read()
would require more changes (elsewhere there are checks forZ_ISUNDEF(iterator->current)
), and we might break existing semantics. Mayberesourcebundle_iterator_current()
would need to returnnull
, but we don't have azval
there. :/And I wonder about:
That reports
Cannot load resource element 3: U_MISSING_RESOURCE_ERROR
after the::get()
call, butU_ZERO_ERROR
when traversing.Given that value only traversal so far "worked" but returned undef values (and apparently nobody complained), maybe as bugfix we should just set the key to undef (instead of null), and try a proper fix in the master branch only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to this at first but it seemed to me the more spread fashion was to set to NULL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, exposing undef values is certainly uncommon, while having
null
as iterator key is not.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems to cause issue with JIT.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Undef values should never get exposed to userland.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, but how to solve that for the values (they are already undef)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will take a look in this issue in a few hours. In general undef should be transformed into null but this is weird in this case. Possibly the undef values should be skipped, which is conceptually similar to arrays. But anyway, I will first try to understand how and why sometime later today.