Skip to content
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

Make sure Period::toString() handles case when child period returns array and add a unit test. #13762

Merged
merged 4 commits into from Dec 9, 2018

Conversation

diosmosis
Copy link
Member

Fixes #13709

@diosmosis diosmosis added the Needs Review PRs that need a code review label Nov 25, 2018
@diosmosis diosmosis added this to the 3.8.0 milestone Nov 25, 2018
public function __toString()
{
return $this->toString();
return [$this->date->toString($format)];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking this would eg break Search Engine Keywords...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@tsteur
Copy link
Member

tsteur commented Nov 25, 2018

For some reason I can't reproduce the notice... could you? I assume it is fine to merge. Not sure where/if we use $period . '' or something similar in any meaningful context besides debug logs.

@diosmosis
Copy link
Member Author

It's reproducible in tests, I didn't try to reproduce through the UI, I think there must have been some error that occurs w/ a week or month period that might trigger it. Ie, something that actually triggers the $period->toString() method.

@diosmosis diosmosis added the not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. label Nov 25, 2018
@diosmosis diosmosis changed the title Make sure Period::toString() always returns array of strings and add a unit test. Make sure Period::toString() handles case when child period returns array and add a unit test. Dec 4, 2018
@tsteur
Copy link
Member

tsteur commented Dec 6, 2018

some failing tests but otherwise good to merge 👍

@diosmosis
Copy link
Member Author

@tsteur had to make a bunch of changes to the range period test and noticed that it might be possible for a plugin to use Period::toString() and expect arrays of arrays. Think this might be a BC issue?

@tsteur
Copy link
Member

tsteur commented Dec 9, 2018

I don't think it is a BC concern but hard to say. But thinking about it again... a toString method should really not return arrays. Not sure how it is used... but ideally it would actually return a string and not arrays.

@diosmosis
Copy link
Member Author

I think currently __toString() returns a string, and toString() returns an array of strings. Could try and change it to return a string, will have to see how much code uses it.

@tsteur
Copy link
Member

tsteur commented Dec 9, 2018

All good, don't worry about it right now 👍

@tsteur
Copy link
Member

tsteur commented Dec 9, 2018

Feel free to merge if it fixes the problem. Only usage I could find was SearchEngine feature that used the day period and it doesn't seem to regress there.

@diosmosis diosmosis merged commit 1b113ae into 3.x-dev Dec 9, 2018
@diosmosis diosmosis deleted the 13709-tostring-fix branch December 9, 2018 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants