Fix error when Registry with empty separator#66
Fix error when Registry with empty separator#66Llewellynvdm merged 4 commits intojoomla-framework:2.0-devfrom
Conversation
|
@Fedik interesting approach instead of disabling the separator, still not sure if this would be more understand or better recognize able. But a fix at least for the state class. |
|
Looks nice. Would be cool to somehow set the mode to flat a bit more enhanced than setting the property directly. |
It was there #65, but kind of hacky. |
|
I would either also use an argument in the constructor or make a function to flatten it. Like that it looks like an official feature from the registry. |
|
@laoneo are you thinking of something down these lines: With the following tests: @nibra what do think about these additions? |
|
The separator should be set using the constructor and be immutable. |
|
Hmmm like this? So looking at this pull request, where we just want to handle an empty string better... and which basically flattens the registry, This change of making the separator immutable seems to major as it changes the access to the public |
|
The Registry is broken in this regard. |
|
I understand your concerns about the public As programmers, we should strive to follow best practices and principles of software development, but we also need to be pragmatic and flexible in our approach. While encapsulation is important for maintainability, we should also avoid unnecessary complexity and overhead, especially if it doesn't add significant value or benefits. Adding new classes to avoid the @Fedik I will merge this PR (after a few more tests), as it fixes an obvious bug/issue, as for the additional fixes I think we will have to target them with separate PRs as our time permits. |
Agree. Nevertheless, setting the separator through the constructor can and should be added, as well as a deprecation for the public separator property for 4.0 (for 3.0 it would be too short notice). |
|
Hello Fedik, |
|
I know it's an edge case but what's happen if the separator is 0, using a weak comparison is always wrong ;-) |
|
@Fedik, yes thank you indeed. I actually agree with @laoneo, and yet it should be simple enough to do the following. Please just add the following to this PR We can improve on this in other PR's but this will set the stage for our transition. |
|
@HLeithner I am not sure about the deprecation notice, and exactly what should be said. |
|
Deprecation message shouldn't be to hard but should be in it's own pr adding the constructor. I also would allow |
I also thought about 0, and did not found it much important. |
|
It's less about the 0 case it's more about to never use weak comparison. Ymmv |
|
Well the getter and setter functions can solve this. So moving the splitting of the path to its own function and also the setting and getting of the separator will be the best solution. I agree with @nibra that the function should be private. |
|
We can have multiple PR's I also don't care to much for that, but this change of flattening the registry and dealing with empty separator are kinda related to each other. So I see no problem adding those changes here now, and having that conversation here. unless @Fedik does not want to. In simple terms we need to catch the empty separator and flatten the path, we want to start down a path that stops the change of the class separator, unless for setting new data, as this change of separator is temporarily based on data path supplied. For this we want to move all splitting of the path into its own function, and getting and setting of the class separator property. This should then be easy to mitigate any misunderstanding of what is happening, and why. @Fedik are you willing to do that? or would you prefer we just make the changes that effectively deals with the empty separator? this is also good with me. We can move these other improvements to its own PR. |
|
Yes please, other pr's, it is also easier to give feedback, instead of having an all in one pr. |
|
I have add better "empty check". I think it better to do 2 PR, because current one kind of a bug fix and can go in to 2.0.x. |
|
last 2 things, can you add 2 tests one for |
|
Added |
|
@Llewellynvdm I made another PR #68, we can continue discussion there 😉 |
|
LGTM |
Summary of Changes
Registry crashes when separator is empty
Testing Instructions
Test passes
Documentation Changes Required
Kind of bugfix