-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[BUG, v.3.1.2] Inconsistent behaviour of Phalcon\Config::merge() across minor versions of PHP7 #12779
Comments
Phalcon 3.2.x with PHP7.1.3 behaves exactly as Phalcon 3.1.2 & PHP7.0.17 (i.e. is broken). |
I'll try to sort out. Thank you for pointing out |
This "feature" broke our dev environment. We also found that the function works incorrectly when config keys are numerical, adding a letter to a key makes it work as intended.
|
@piotrgolasz what makes you think it's a "feature"? hope you're being sarcastic :) |
Do you know why this is happening? How could change in PHP minor version affect this, or is it something in Phalcon? |
@temuri416, @piotrgolasz Could you please try to compile Phalcon from master (v3.1.2) by using |
@temuri416 more likely in zephir. |
@sergeyklay any updates with this issue? |
@piotrgolasz @temuri416 Could you please test by using latest Zephir from master branch and Phalcon 3.2.x ? |
Looks like it's broken with PHP 7.1.5, with latest Phalcon 3.2.x: Running the snipped above I am getting this:
Phalcon info:
|
Could you please use latest Zephir ? |
Sure... where can I see the instructions on how to compile Phalcon with externally compiled Zephir? |
|
Same result:
|
Provide please ini config example |
You mean php.ini config? |
$config = new Phalcon\Config([
'a' => [
[
1
]
],
]);
$config->merge(new Phalcon\Config([
'a' => [
[
2
]
],
])); Your result is correct. You have TWO nested arrays. If you want to have returned a key with 1 and 2 value then you need to change your code to: $config = new Phalcon\Config([
'a' => [
1
]
]);
$config->merge(new Phalcon\Config([
'a' => [
2
]
])); Not sure why you have on php 7.0.14 diffrent result, maybe you were using outdated phalcon? |
Are you saying that it was working incorrectly before and now it is correct? |
Well actually im not sure, well i need to test it. |
I don't care anymore which way is right - what was before or what's now. I don't need that type of merging anymore in my config (implemented it differently). However, what's bugging me is that it's THE SAME combo of Phalcon & Zephir that behaves differently across minor PHP versions. |
You sure that you had the same combo? |
@temuri416 Could you please provide a small unit test to test it on Travis with PHP 5.6 - 7.1 ? |
100%. Checked that several times, could not believe my eyes. You can also ask @piotrgolasz. The fact is, behaviour of |
ok, but I never worked with that. Link for more info? |
Just add new test here https://github.com/phalcon/cphalcon/blob/3.2.x/tests/unit/Config/Adapter/IniTest.php |
ok, I'll try to do it this weekend. |
I just think that result on php 7.0.17 is correct, not sure why you had returned 7.0.14, from logical point of view what i wrote above should be true. |
Well i will need to test it, though from conditions i see there it should merge, for some reason it doesn't. |
Well it looks like that we need to cast key to string most likely. |
Okay so on first _merge run it properly go into "a" key of both configs. Then we have |
Just code must be updated to something like:
|
Yea i can confirm this is an fix, already tested @sergeyklay @temuri416 @piotrgolasz Actually it's like this even in plain php, so im not sure how your code fixed it. |
Check this out: @sergeyklay @temuri416 @piotrgolasz WTF PHP |
So it seems before v7.0.17 numeric keys were cast as strings |
Yea and in 7.1.0-7.1.2 they went back to castings as ints and then go back to casting as string xD wtf |
Well i guess just 7.1.3 was released same time as 7.0.17, right? |
F**k. |
Yea exactly, it's about release date, though it's pretty funny. |
Still - there is just a bug in phalcon, and it was working because php was returning wrong value :D :D So bug in php was fixing bug in phalcon, funny. |
What is more stupid: $key = 1;
$object->$key; // works
$object->1; // syntax error |
@Jurigag, just PHP syntax $object->{'1'} |
Actually |
Fixed in the |
Phalcon\Config::merge()
of the same version of Phalcon (v3.1.2
) behaves differently on PHP versions7.0.14
and7.0.17
.PHP v7.0.14
Expected and Actual Behavior
$config
is:Everything is correct.
PHP v7.0.17
The same code results in the following
$config
value:I expect
$config
to have the same value that's produced underv7.0.14
.Details
7.0.14
vs7.0.17
0.9.7
Nginx
The text was updated successfully, but these errors were encountered: