-
Notifications
You must be signed in to change notification settings - Fork 732
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
lazy toArray #916
lazy toArray #916
Conversation
interface Nameable | ||
{ | ||
public function getName(); | ||
} |
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 think that for consistency, interface should include setName
as well.
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.
Done
Awesome! I suspect something is broken, but all tests seems to be green, hence lgtm. I left comments (mostly cosmetic issues) in the code, also could you please:
|
All done, if squash needed or something else, let me know. Also does I need add some tests for increase code-coverage? |
@im-denisenko @ewgRa Looks good to me. |
@ewgRa Thanks, merged. If you still want add more test for coverage, feel free to open another PR. |
Looks like the next Elastica version will be 2.3.0 because of the BC changes. We should get this out of the door as soon as possible and mention the changes. @ewgRa did a good job in the pull request explaining it. |
Ok, thanks! I will add some tests later. |
@ewgRa @im-denisenko There as an issue with the anonymous filters: 5a08b5f I think it is fixed now. The main issue is actually that even though some tests fail on travis, it still reports green. I have to look into this. |
5a08b5f must be not affect of or affected due to this PR, as I understand. Green travis with fail tests that strange, yes. When you fix it and some test will be broken because of this PR - write it here. As I remember when I work on this PR all tests was passed on my local computer. I will check again when I will be at home. |
@ewgRa It looks good now. I just checked the build and this pull request was the first time it was broken. But with the commit above it is fixed. |
$filterArray[] = $filter->toArray(); | ||
$filterArray = array(); | ||
|
||
if (is_string($name)) { |
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.
this looks broken as the default value of the empty string is still a string
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.
@stof Agree. There is something wrong here. Did you spot this because of the discussion or did you run already in some issues with it?
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 looked at this PR from the release changelog
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.
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.
@ruflin change, that @stof notice I made to sync this check between toArray and addFilter, because they must be same. I think additionally to 5a08b5f there is must be changed addFilter method in same way. What do you think? Or I was wrong when say that check must be same between this two methods.
This change came from #916 (diff)
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.
@ewgRa Not sure what you meant with your second last sentence. Please open a pull request with some tests if possible for the suggested changes, so we can directly discuss it based on code.
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.
Ok, I will write tests on this case and we will discuss.
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.
👍
There is another thing which might not possible anymore: cloning a Query object (or any other objects impacted here): given you keep objects internally, most changes on 1 query could affect the other one too if you have any method mutating an inner object (I don't remember the API of all these classes enough to know whether this happens anywhere), while it would have worked before as arrays where used. |
Nice notice. Looks like another projects clone all inner objects and this is a good practice and this make sense. Also this will be similar to how clone work before. But, if it will be implemented via __clone, there is no possibility to clone just only object, without clone inner objects. And there is not a small chance that somebody need this feature. I look to symfony code for example, and there is in many places __clone cause clone of inner objects. And how developer can just clone only object if needed? If implement this, can it be considered as bugfix to 2.3.0? Because it is kind of broke BC :( |
@ruflin @stof I think that object that can be set via setters can't be considered as "inner" objects and must be not cloned. Good example is symfony Request::duplicate and Request::__clone. If for example Param::$_params will be an SplObjectStorage instance - than we must clone it, because for example $cloned->removeParam call must haven't affect on $original. But because it is array now, we don't need to clone objects inside it. So. I +1 for duplicate() when it will be requested by someone, but -1 for __clone() as duplicate(). |
@stof Thanks for bringing up this discussion. A few notes/thoughts here:
|
Ok, I will try to write something more verbose with examples and explanations. |
@ruflin respecting semver, this means the release should have been numbered 3.0 btw. |
@stof Yep. If we are strict with semver ofr every BC break we must increase the full version. I normally sneak smaller BC breaks also into the MINOR releases. I think we should keep 3.0 for the changes to elasticsearch 2.0. |
@ewgRa Don't worry, most of us are not native english writers. Let me know in case you have a draft and I can take a look at it. Otherwise just drop me a line and will check if I can do it. |
Article about broken BC: https://gist.github.com/ewgRa/217bb9226943309b1974 Please review, how it is looks like, is this exactly what needed, or not, and so on. Feel free to change, add you as co-author, publish and so on. I have vacation from 23 Sep and there is not so much time left to complete future requested changes in article. Do it yourself since my vacation will be started, or wait till I return from vacation. |
@ewgRa That is exactly what we needed. That is where we can point people to in case questions pop up. I revised the article and published it here on Elastica.io: http://elastica.io/2015/09/22/elastica-2-dot-3-0-broken-backward-compatibility-explanation/ It is linked in the release notes so it is easy to find. @ewgRa Thanks a lot and enjoy your vacations. |
This is PR for #783, convert object toArray when it is really needed. Comments, tests, review - welcome.
BC:
For example such test:
with previous code will be not passed. With this PR - it is passed.
For example, before:
Now:
Same as some named object:
before:
after:
As you can see, aggregation name in toArray also become lazy.