[Bug]: PHP Deprecated:Function utf8_encode()
⚠️ This issue respects the following points: ⚠️
- [X] This is a bug, not a question or a configuration/webserver/proxy issue.
- [X] This issue is not already reported on Github OR Nextcloud Community Forum (I've searched it).
- [X] Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
- [X] I agree to follow Nextcloud's Code of Conduct.
Bug description
after local external storage and system completed scanning the mount I found following logs when files with international characters are scanned (using occ files:scan):
PHP Deprecated: Function utf8_encode() is deprecated in /var/www/html/lib/private/Log/LogDetails.php on line 109
according to https://wiki.php.net/rfc/remove_utf8_decode_and_utf8_encode functions utf8_encode() and utf8_decode() can produce unintended results and deprecated for this reason. multiple ways to replace the function are described in the article.
code search shows utf8_encode() is used only once:
https://github.com/nextcloud/server/blob/9c00d128f5fe4774c011e4a0936b2cf831fcd371/lib/private/Log/LogDetails.php#L109
would be great deprecated function is replaced timely.
Steps to reproduce
- add local external storage with files names including international character e.g. éèáã etc.. some of my real life examples:
- Entry ".../Верн Жюль - Двадцать тысяч лье под водой" will not be accessible due to incompatible encoding
- Entry ".../Perry Rhodan, komplett/[heft] Perry Rhodan 2605 - Die Planetenbrücke.epub" will not be accessible due to incompatible encoding
- Entry ".../John Sinclair, Heftfolgen/[heft] Dark, Jason - John Sinclair 0238 - Belphégors Rueckkehr (2 of 3).epub" will not be accessible due to incompatible encoding
- scan the storage using
occ files:scan - see an issue
Expected behavior
no deperecation notice (and ideally files successfully added to system)
Installation method
Community Docker image
Nextcloud Server version
28
Operating system
Debian/Ubuntu
PHP engine version
PHP 8.2
Web server
Apache (supported)
Database engine version
MariaDB
Is this bug present after an update or on a fresh install?
None
Are you using the Nextcloud Server Encryption module?
None
What user-backends are you using?
- [X] Default user-backend (database)
- [ ] LDAP/ Active Directory
- [ ] SSO - SAML
- [ ] Other
Configuration report
No response
List of activated Apps
No response
Nextcloud Signing status
No response
Nextcloud Logs
No response
Additional info
No response
In addition: the deprecation started with PHP 8.2. Also see https://www.php.net/manual/en/function.utf8-encode.php
There are also hints how to replace it here: https://php.watch/versions/8.2/utf8_encode-utf8_decode-deprecated
Feel free to try https://github.com/nextcloud/server/pull/43637
worked like a charm, no more deprecated logs :)