server icon indicating copy to clipboard operation
server copied to clipboard

[Bug]: PHP Deprecated:Function utf8_encode()

Open isdnfan opened this issue 1 year ago • 2 comments

⚠️ This issue respects the following points: ⚠️

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

  1. 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
  1. scan the storage using occ files:scan
  2. 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

isdnfan avatar Feb 15 '24 13:02 isdnfan

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

igefa-awelzel avatar Feb 15 '24 13:02 igefa-awelzel

Feel free to try https://github.com/nextcloud/server/pull/43637

solracsf avatar Feb 18 '24 08:02 solracsf

worked like a charm, no more deprecated logs :)

isdnfan avatar Feb 19 '24 20:02 isdnfan