-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/src/PhpSpreadsheet/Reader/Csv.php:280 - auto_detect_line_endings is deprecated #2609
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
Comments
The warning message is already suppressed. Why are you seeing a warning? |
We use a custom error handler and suppress only based on a set of rules. However, I did not create this for it to be suppressed, but for it to be fixed (replaced or removed). |
It will be removed when it is no longer supported. Deprecated or not, it is supported in 8.1, and removing might (agree that it is unlikely) be a problem for existing users. There is already a unit test in place which will fail when it is no longer supported, and we will respond to the test failure when that time comes. |
Ok, that's fine. Like I said, I did not see an issue open (or closed) for it, so I wanted to make sure it was not missed (or submit a patch if needed). |
Thank you for being proactive. The test which will eventually fail is Reader/Csv/CsvLineEndingTest. I will leave this issue open for about a week to see if it sparks any other discussion. |
With the deprecation of `auto_detect_line_endings` in Php8.1, there have been some tickets (issue PHPOffice#2609 and PR PHPOffice#2438). Although the deprecation message is suppressed, users with a homegrown error handler may still see it. I am not very concerned about that symptom, but I imagine that there will be more similar tickets in future. This PR adds a new property/method to Reader/CSV to allow the user to avoid the deprecated code, at the negligible cost of being unable to read a CSV with Mac line endings even on a Php version that could support it.
With the deprecation of `auto_detect_line_endings` in Php8.1, there have been some tickets (issue #2609 and PR #2438). Although the deprecation message is suppressed, users with a homegrown error handler may still see it. I am not very concerned about that symptom, but I imagine that there will be more similar tickets in future. This PR adds a new property/method to Reader/CSV to allow the user to avoid the deprecated code, at the negligible cost of being unable to read a CSV with Mac line endings even on a Php version that could support it.
Closing. Merged PR 2623 to give people a means to avoid deprecation notice even with custom error handler. Test which will fail in Php9 should guarantee that the deprecation is not overlooked. |
There is no need to comment out any code. Add the following to your application instead. $reader = new \PhpOffice\PhpSpreadsheet\Reader\Csv();
$reader->setTestAutoDetect(false); |
Aah. I see. It turns out the instance calling is different... So, I just need to modify the instance according to the input type, using either new \PhpOffice\PhpSpreadsheet\Reader\Csv() or Xlsx(), right? |
That should work. If you're not sure of the reader type, as in your first example, you might try: if (method_exists($reader, 'setTestAutoDetect')) {
$reader->setTestAutoDetect(false);
} |
Ah, alright, got it. Thank you very much. |
I see the comment that this is deprecated, but I don't see an issue open to replace/remove this code, so I'm opening one as we just moved to 8.1 and are getting this warning. We'll suppress it for now, but just wanted to make sure it was addressed:
The text was updated successfully, but these errors were encountered: