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

Add Symfony 3.4 compatibility, without deprecation notices #47

Merged
merged 1 commit into from
Dec 8, 2017
Merged

Add Symfony 3.4 compatibility, without deprecation notices #47

merged 1 commit into from
Dec 8, 2017

Conversation

ChristianRiesen
Copy link
Contributor

@ChristianRiesen ChristianRiesen commented Dec 6, 2017

Added reset function that caused deprecation notices in Symfony 3.4+ upgrades.

@ChristianRiesen ChristianRiesen changed the title Add Symfony 4 compatibility, without deprecation notices Add Symfony 3.4 compatibility, without deprecation notices Dec 6, 2017
*/
public function reset()
{
$this->data = [];
Copy link
Member

Choose a reason for hiding this comment

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

I'd rather do:

$this->data['commands'] = [];

(because this is what is done in __construct())

but maybe I misunderstood the "reset" purpose?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should be the entire data, not just commands.

Copy link
Member

@Oliboy50 Oliboy50 Dec 6, 2017

Choose a reason for hiding this comment

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

this DataCollector seems to require the commands key for data array

otherwise we'll have some issues with other methods (i.e. getCommands, getTotalExecutionTime and getAvgExecutionTime)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll have a closer look at it again today to make sure this works as intended.

@Oliboy50
Copy link
Member

Oliboy50 commented Dec 6, 2017

@ChristianRiesen could you please also do what has been done in https://github.com/M6Web/AmqpBundle/pull/46/files please? 🙏

If this bundle could be compatible with SF4 too, that would be nice :)

Or we could merge your PR before merging #46, as you want
cc @romain-pierre

@ChristianRiesen
Copy link
Contributor Author

@Oliboy50 There is a problem with Symfony 4, that's why I backed it down to 3.4 to be compatible, so that can be used without having tons of deprecation notices. For 4.0 you need a bit more work. I had it in originally, but that went bad. See here: https://travis-ci.org/M6Web/AmqpBundle/builds/312455080

I'd be very happy to have this merged as is and tagged.

My suspicion is that there is something going wrong with the tests because of how PHP 7.1 handles the error triggering now, but that's just a hunch, and I think it would be best to address that in another PR.

@Oliboy50
Copy link
Member

Oliboy50 commented Dec 6, 2017

@ChristianRiesen thanks for your feedback about SF4 👍

@ChristianRiesen
Copy link
Contributor Author

No problem. It gave me some headaches today, but thankfully I don't need SF4, yet :)

@ChristianRiesen
Copy link
Contributor Author

@Oliboy50 I went over it again and made sure there will be no states that could cause an error. I cleaned up some small things (also in regard to PHP7) in this PR as well since probably nobody will touch the datacollector in a long time anyways :)

If this works for you, please merge and tag. Thank you!

Copy link
Member

@Oliboy50 Oliboy50 left a comment

Choose a reason for hiding this comment

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

LGTM :)

{
return ($this->getTotalExecutionTime()) ? ($this->getTotalExecutionTime() / count($this->data['commands'])) : 0;
$this->data = [];
Copy link
Member

Choose a reason for hiding this comment

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

could be $this->data = ['commands' => []]; and remove the next line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, let me fix that quickly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed the line. Thanks for catching that :)

Copy link
Contributor

@b-viguier b-viguier left a comment

Choose a reason for hiding this comment

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

Thanks @ChristianRiesen 👍

Copy link
Contributor

@fabdsp fabdsp left a comment

Choose a reason for hiding this comment

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

thx !

Added small cleanups and PHP 7 enhancements while I was at it to the datacollector.
{
return ($this->getTotalExecutionTime()) ? ($this->getTotalExecutionTime() / count($this->data['commands'])) : 0;
$this->data = [['commands' => []];
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't you need to call parent::reset() to ensure proper $this-data reset? 🤔

parent::reset();
$this->data['commands'] = [];

I didn't find where is defined data and who is in charge of its default initialization 😕

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really, most other data collectors I ran into so far do just reset to empty array, as do most of the official ones from symfony itself.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good 😃
Let's go for v3.0.1 🎉

@b-viguier b-viguier merged commit ec7a846 into BedrockStreaming:master Dec 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants