-
Notifications
You must be signed in to change notification settings - Fork 342
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
ISSUE-209: Encode keys before storing on mongo. #210
Conversation
Looks good. I will get the build fixed for php7. |
It worries me that for me, everything works with mongodb 3.0 (see issue #209 ). I would like to set up a docker env to test this and find out what the real cause of this issue is before we hurry to a fix that might not work. If you need to use your fix, you can do so via https://getcomposer.org/doc/05-repositories.md#loading-a-package-from-a-vcs-repository |
); | ||
foreach ($profile as $k => $v) { | ||
if (is_array($v)) { | ||
$v = $this->encodeProfile($v); |
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.
why is this recursive call? do we have any other problematic keys than the content of array_keys($profile['profile'])
?
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.
Are there any nested structures inside a profile that I have ignored?
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.
If this is the case that we do not need recursive checking, we should instead opt for an easier solution.
What do you think about something like
public function encode($profile) {
// return $profile if the array is empty or not an array
$replacedKeys = str_replace('.', '.', array_keys($profile));
return array_combine($replacedKeys, $profile);
}
?
Here's a demonstration, if you're intersted
<?php
$a = ['fx' => ['a' => 'xxx', 'b' => 2, 'c' => 3], 'quux' => ['f' => 7, 'cx' => 3]];
print_r(array_combine(str_replace('x', 'y', array_keys($a)), $a));
prints
Array
(
[fy] => Array
(
[a] => xxx
[b] => 2
[c] => 3
)
[quuy] => Array
(
[f] => 7
[cx] => 3
)
)
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'd also recommend defining the .
and .
as constants (UNICODE_PERIOD and UNICODE_FULLWIDTH_PERIOD for example?)
Superseded by #352 |
Issue: #209
Notes: