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

transChoice method is deprecated in Symfony 4.2 #1548

Closed
robbydooo opened this issue Dec 13, 2018 · 5 comments

Comments

Projects
None yet
2 participants
@robbydooo
Copy link

commented Dec 13, 2018

Hello,

I encountered an issue with the following code:

echo $post->approved_date->diffForHumans();

Carbon version: 1.36
PHP version: 7.2
Laravel 5.7

I expected to get:

2 Months ago

But I actually get:

ErrorException: The "Symfony\Component\Translation\Translator::transChoice()" method is deprecated since Symfony 4.2, use the trans() one instead with a "%count%" parameter.

Error is from /app/vendor/nesbot/carbon/src/Carbon/Carbon.php:4233

Only started happening in the past 48 hours after doing a composer update on my laravel project.

I would do a pull request but I don't know the translation library well enough to know what exactly is happening here.

Let me know if you need any further information.
Thanks!

@kylekatarnls

This comment has been minimized.

Copy link
Collaborator

commented Dec 14, 2018

Hi,

symfony/translation recently deprecated a method we use from it. And by default in Laravel any notice even deprecation will stop the process throwing an exception.

Symfony let us no choice, all existing version of Carbon are incompatible with symfony/translation 4.2, so we have to publish new version (1.37 and 2.8) using the new translation method.

Meanwhile, you can force downgrade symfony/translation:

composer require symfony/translation:~4.1
@kylekatarnls

This comment has been minimized.

Copy link
Collaborator

commented Dec 14, 2018

Before doing a painful or radical choice, I will discuss it with Symfony staff: symfony/symfony#29607

@kylekatarnls

This comment has been minimized.

Copy link
Collaborator

commented Dec 14, 2018

Hi, @robbydooo, regarding new information provided in symfony/symfony#29607 I put this on hold and will not change Carbon until having a way to reproduce it and see if carbon or symfony really do something invalid.

@robbydooo

This comment has been minimized.

Copy link
Author

commented Dec 14, 2018

Hi @kylekatarnls I have been reading this, thanks for looking into this.
Based on the comments in that discussion i have looked into the reporting service we use which is HoneyBadger and it appears that there must be an issue in this file
https://github.com/honeybadger-io/honeybadger-php/blob/c6747a54c3ac7b788bbf8a7398011e5e49a62317/src/Handlers/ErrorHandler.php

If i disable the error handling it no longer reports the issue.

I will open up a bug with Honeybadger. Apologies for opening this bug on here although the reporting of the error was originating from Carbon so this was pretty well hidden.

@kylekatarnls

This comment has been minimized.

Copy link
Collaborator

commented Dec 14, 2018

Good news so we have enough time to handle properly this deprecation. Thanks for your investigation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.