nextcloud / server

☁️ Nextcloud server, a safe home for all your data
https://nextcloud.com
GNU Affero General Public License v3.0
27.45k stars 4.08k forks source link

[Bug]: Locale detection still does not work properly #35721

Open DagNygren opened 1 year ago

DagNygren commented 1 year ago

⚠️ This issue respects the following points: ⚠️

Bug description

Every time after upgrade for a longer time now I have had to edit the function isSetLocaleWorking() function in lib/private/legacy/OC_Util.php to always return "true" as the detection doesn't work properly but returns false in my Apache. The locale list does contain en_US.UTF-8 but it is not detected. I will not tweak the Apache very much as it is serving a wide range of other endpoints too and any tweak could break those.

Changing the function mentioned above to always return true makes everything work as expected.

Steps to reproduce

  1. Upgrade the Nextcloud installation 2.Logout and try to login again

Expected behavior

I expect to get a login window also after upgrade without having to patch the software every time.

Installation method

Community Manual installation with Archive

Operating system

RHEL/CentOS

PHP engine version

PHP 7.4

Web server

Apache (supported)

Database engine version

MariaDB

Is this bug present after an update or on a fresh install?

Updated from a minor version (ex. 22.2.3 to 22.2.4)

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?

Configuration report

{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "owncloud.newtech.fi"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "25.0.2.3",
        "installed": true,
        "theme": "",
        "maintenance": false,
        "ldapIgnoreNamingRules": false,
        "forcessl": true,
        "loglevel": 0,
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpmode": "smtp",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "enable_certificate_management": true,
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "default_phone_region": "FI",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 6379,
            "dbindex": 0,
            "timeout": 1.5
        },
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trashbin_retention_obligation": "auto",
        "mail_smtpauthtype": "LOGIN",
        "mail_smtpsecure": "tls",
        "mail_smtpauth": 1,
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "user_backends": [
            {
                "class": "OC_User_IMAP",
                "arguments": [
                    "imap.newtech.fi",
                    "993",
                    "ssl",
                    "novalidate-cert"
                ]
            }
        ],
        "mail_smtpport": "2025",
        "ldapProviderFactory": "\\OCA\\User_LDAP\\LDAPProviderFactory",
        "overwrite.cli.url": "https:\/\/owncloud.newtech.fi",
        "mysql.utf8mb4": true,
        "mail_sendmailmode": "smtp",
        "mail_smtpsecureselfsigned": 1,
        "app_install_overwrite": [
            "calendar",
            "keeweb",
            "user_external",
            "external",
            "joplin",
            "grauphel"
        ],
        "has_rebuilt_cache": true,
        "app.mail.verify-tls-peer": false,
        "app.mail.accounts.default": {
            "email": "%USERID%@newtech.fi",
            "imapHost": "imap.newtech.fi",
            "imapPort": 3993,
            "imapSslMode": "ssl",
            "smtpHost": "smtp.newtech.fi",
            "smtpPort": 486,
            "smtpSslMode": "tls"
        },
        "updater.secret": "***REMOVED SENSITIVE VALUE***"
    }
}

List of activated Apps

Enabled:
  - activity: 2.17.0
  - calendar: 4.1.0
  - circles: 25.0.0
  - cloud_federation_api: 1.8.0
  - comments: 1.15.0
  - contacts: 5.0.1
  - contactsinteraction: 1.6.0
  - dashboard: 7.5.0
  - dav: 1.24.0
  - external: 5.0.0
  - federatedfilesharing: 1.15.0
  - federation: 1.15.0
  - files: 1.20.1
  - files_external: 1.17.0
  - files_pdfviewer: 2.6.0
  - files_rightclick: 1.4.0
  - files_sharing: 1.17.0
  - files_trashbin: 1.15.0
  - files_versions: 1.18.0
  - firstrunwizard: 2.14.0
  - gpxpod: 5.0.4
  - keeweb: 0.6.10
  - logreader: 2.10.0
  - lookup_server_connector: 1.13.0
  - mail: 2.2.1
  - nextcloud_announcements: 1.14.0
  - notes: 4.6.0
  - notifications: 2.13.1
  - oauth2: 1.13.0
  - onlyoffice: 7.6.8
  - password_policy: 1.15.0
  - photos: 2.0.1
  - privacy: 1.9.0
  - provisioning_api: 1.15.0
  - qownnotesapi: 22.10.0
  - recommendations: 1.4.0
  - related_resources: 1.0.3
  - serverinfo: 1.15.0
  - settings: 1.7.0
  - sharebymail: 1.15.0
  - spreed: 15.0.2
  - support: 1.8.0
  - survey_client: 1.13.0
  - systemtags: 1.15.0
  - text: 3.6.0
  - theming: 2.0.1
  - twofactor_backupcodes: 1.14.0
  - updatenotification: 1.15.0
  - user_external: 0.6.1
  - user_ldap: 1.15.0
  - user_status: 1.5.0
  - viewer: 1.9.0
  - weather_status: 1.5.0
  - workflowengine: 2.7.0
Disabled:
  - admin_audit
  - bruteforcesettings: 1.2.0
  - carnet: 0.24.6
  - drawio: 1.0.5
  - encryption
  - files_markdown: 2.3.6
  - grauphel: 1.0.18
  - suspicious_login
  - twofactor_totp

Nextcloud Signing status

No errors have been found.

Nextcloud Logs

{"reqId":"Y5RV-Jb9fpTSTgptZ6bRewAAAA4","level":1,"time":"2022-12-10T09:48:41+00:00","remoteAddr":"10.0.0.96","user":"--","app":"no app in context","method":"GET","url":"/index.php/204","message":"Unable to generate a URL for the named route \"notes.page.index\" as s
uch route does not exist.","userAgent":"Mozilla/5.0 (Android) Nextcloud-android/3.20.3","version":"25.0.2.3","exception":{"Exception"
:"Symfony\\Component\\Routing\\Exception\\RouteNotFoundException","Message":"Unable to generate a URL for the named route \"notes.pag
e.index\" as such route does not exist.","Code":0,"Trace":[{"file":"/usr/local/owncloud/nextcloud-22.2.3/lib/private/Route/Router.php
","line":361,"function":"generate","class":"Symfony\\Component\\Routing\\Generator\\UrlGenerator","type":"->","args":["notes.page.ind
ex",[],1]},{"file":"/usr/local/owncloud/nextcloud-22.2.3/lib/private/Route/CachingRouter.php","line":58,"function":"generate","class"
:"OC\\Route\\Router","type":"->","args":["notes.page.index",[],false]},{"file":"/usr/local/owncloud/nextcloud-22.2.3/lib/private/URLG
enerator.php","line":103,"function":"generate","class":"OC\\Route\\CachingRouter","type":"->","args":["notes.page.index",[]]},{"file"
:"/usr/local/owncloud/nextcloud-22.2.3/lib/private/NavigationManager.php","line":318,"function":"linkToRoute","class":"OC\\URLGenerator","type":"->","args":["notes.page.index"]},{"file":"/usr/local/owncloud/nextcloud-22.2.3/lib/private/NavigationManager.php","line":
113,"function":"init","class":"OC\\NavigationManager","type":"->","args":[]},{"file":"/usr/local/owncloud/nextcloud-22.2.3/apps/theming/lib/ThemingDefaults.php","line":188,"function":"getAll","class":"OC\\NavigationManager","type":"->","args":["guest"]},{"file":"/usr/local/owncloud/nextcloud-22.2.3/lib/private/legacy/OC_Defaults.php","line":280,"function":"getShortFooter","class":"OCA\\Theming\\ThemingDefaults","type":"->","args":[]},{"file":"/usr/local/owncloud/nextcloud-22.2.3/lib/public/Defaults.php","line":177,"function":"
getLongFooter","class":"OC_Defaults","type":"->","args":[]},{"file":"/usr/local/owncloud/nextcloud-22.2.3/core/templates/layout.guest
.php","line":52,"function":"getLongFooter","class":"OCP\\Defaults","type":"->","args":[]},{"file":"/usr/local/owncloud/nextcloud-22.2
.3/lib/private/Template/Base.php","line":180,"args":["/usr/local/owncloud/nextcloud-22.2.3/core/templates/layout.guest.php"],"functio
n":"include"},{"file":"/usr/local/owncloud/nextcloud-22.2.3/lib/private/Template/Base.php","line":150,"function":"load","class":"OC\\
Template\\Base","type":"->","args":["/usr/local/owncloud/nextcloud-22.2.3/core/templates/layout.guest.php",null]},{"file":"/usr/local
/owncloud/nextcloud-22.2.3/lib/private/legacy/OC_Template.php","line":181,"function":"fetchPage","class":"OC\\Template\\Base","type":
"->","args":[null]},{"file":"/usr/local/owncloud/nextcloud-22.2.3/lib/private/legacy/OC_Template.php","line":212,"function":"fetchPag
e","class":"OC_Template","type":"->","args":[null]},{"file":"/usr/local/owncloud/nextcloud-22.2.3/lib/private/Template/Base.php","lin
e":132,"function":"fetchPage","class":"OC_Template","type":"->","args":[]},{"file":"/usr/local/owncloud/nextcloud-22.2.3/lib/private/
legacy/OC_Template.php","line":274,"function":"printPage","class":"OC\\Template\\Base","type":"->","args":[]},{"file":"/usr/local/own
cloud/nextcloud-22.2.3/lib/base.php","line":693,"function":"printGuestPage","class":"OC_Template","type":"::","args":["","error",[[["
Setting locale to en_US.UTF-8/fr_FR.UTF-8/es_ES.UTF-8/de_DE.UTF-8/ru_RU.UTF-8/pt_BR.UTF-8/it_IT.UTF-8/ja_JP.UTF-8/zh_CN.UTF-8 failed.
","Please install one of these locales on your system and restart your web server."]]]]},{"file":"/usr/local/owncloud/nextcloud-22.2.
3/lib/base.php","line":1144,"function":"init","class":"OC","type":"::","args":[]},{"file":"/usr/local/owncloud/nextcloud-22.2.3/index
.php","line":34,"args":["/usr/local/owncloud/nextcloud-22.2.3/lib/base.php"],"function":"require_once"}],"File":"/usr/local/owncloud/
nextcloud-22.2.3/3rdparty/symfony/routing/Generator/UrlGenerator.php","Line":143,"message":"Unable to generate a URL for the named route \"notes.page.index\" as such route does not exist.","exception":{"xdebug_message":"<tr><th align='left' bgcolor='#f57900' colspan
=\"5\"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Symfony\\Component\\Routing\\Excepti
on\\RouteNotFoundException: Unable to generate a URL for the named route \"notes.page.index\" as such route does not exist. in /usr/l
ocal/owncloud/nextcloud-22.2.3/3rdparty/symfony/routing/Generator/UrlGenerator.php on line <i>143</i></th></tr>\n<tr><th align='left'
 bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>\n<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec
'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#e
eeeec'>Location</th></tr>\n<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0008</td><td bgcolor='#eeeeec' align='right'>362840</td><td bgcolor='#eeeeec'>{main}(  )</td><td title='/usr/local/owncloud/nextcloud-22.2.3/index.php' bgcolor='#eeeeec'>.../index.php<b>:</b>0</td></tr>\n<tr><td bgcolor='#eeeeec' align='center'>2</td><td bgcolor='#eeeeec' align='center'>0.0008</td><td bgcolor='#eeeeec' align='right'>363088</td><td bgcolor='#eeeeec'>require_once( <font color='#00bb00'>'/usr/local/owncloud/nextcloud-22.2.3/lib/base.php</font> )</td><td title='/usr/local/owncloud/nextcloud-22.2.3/index.php' bgcolor='#eeeeec'>.../index.php<b>:</b>34</td></tr>\n<tr><td bgcolor='#eeeeec' align='center'>3</td><td bgcolor='#eeeeec' align='center'>0.0008</td><td bgcolor='#eeeeec' align='right'>363152</td><td bgcolor='#eeeeec'>OC::init(  )</td><td title='/usr/local/owncloud/nextcloud-22.2.3/lib/base.php' bgcolor='#eeeeec'>.../base.php<b>:</b>1144</td></tr>\n<tr><td bgcolor='#eeeeec' align='center'>4</td><td bgcolor='#eeeeec' align='center'>0.1067</td><td bgcolor='#eeeeec' align='right'>4694632</td><td bgcolor='#eeeeec'>OC_Template::printGuestPage( <span>$application = </span><span>&#39;&#39;</span>, <span>$name = </span><span>&#39;error&#39;</span>, <span>$parameters = </span><span>[&#39;errors&#39; =&gt; [0 =&gt; [...]]]</span> )</td><td title='/usr/local/owncloud/nextcloud-22.2.3/lib/base.php' bgcolor='#eeeeec'>.../base.php<b>:</b>693</td></tr>\n<tr><td bgcolor='#eeeeec' align='center'>5</td><td bgcolor='#eeeeec' align='center'>0.1090</td><td bgcolor='#eeeeec' align='right'>4769184</td><td bgcolor='#eeeeec'>OC\\Template\\Base->printPage(  )</td><td title='/usr/local/owncloud/nextcloud-22.2.3/lib/private/legacy/OC_Template.php' bgcolor='#eeeeec'>.../OC_Template.php<b>:</b>274</td></tr>\n<tr><td bgcolor='#eeeeec' align='center'>6</td><td bgcolor='#eeeeec' align='center'>0.1090</td><td bgcolor='#eeeeec' align='right'>4769184</td><td bgcolor='#eeeeec'>OC_Template->fetchPage( <span>$additionalParams = </span>??? )</td><td title='/usr/local/owncloud/nextcloud-22.2.3/lib/private/Template/Base.php' bgcolor='#eeeeec'>.../Base.php<b>:</b>132</td></tr>\n<tr><td bgcolor='#eeeeec' align='center'>7</td><td bgcolor='#eeeeec' align='center'>0.2710</td><td bgcolor='#eeeeec' align='right'>6973728</td><td bgcolor='#eeeeec'>OC_Template->fetchPage( <span>$additionalParams = </span><span>NULL</span> )</td><td title='/usr/local/owncloud/nextcloud-22.2.3/lib/private/legacy/OC_Template.php' bgcolor='#eeeeec'>.../OC_Template.php<b>:</b>212</td></tr>\n<tr><td bgcolor='#eeeeec' align='center'>8</td><td bgcolor='#eeeeec' align='center'>0.2710</td><td bgcolor='#eeeeec' align='right'>6973728</td><td bgcolor='#eeeeec'>OC\\Template\\Base->fetchPage( <span>$additionalParams = </span><span>NULL</span> )</td><td title='/usr/local/owncloud/nextcloud-22.2.3/lib/private/legacy/OC_Template.php' bgcolor='#eeeeec'>.../OC_Template.php<b>:</b>181</td></tr>\n<tr><td bgcolor='#eeeeec' align='center'>9</td><td bgcolor='#eeeeec' align='center'>0.2710</td><td bgcolor='#eeeeec' align='right'>6973728</td><td bgcolor='#eeeeec'>OC\\Template\\Base->load( <span>$file = </span><span>&#39;/usr/local/owncloud/nextcloud-22.2.3/core/templates/layout.guest.php&#39;</span>, <span>$additionalParams = </span><span>NULL</span> )</td><td title='/usr/local/owncloud/nextcloud-22.2.3/lib/private/Template/Base.php' bgcolor='#eeeeec'>.../Base.php<b>:</b>150</td></tr>\n<tr><td bgcolor='#eeeeec' align='center'>10</td><td bgcolor='#eeeeec' align='center'>0.2714</td><td bgcolor='#eeeeec' align='right'>6996384</td><td bgcolor='#eeeeec'>include( <font color='#00bb00'>'/usr/local/owncloud/nextcloud-22.2.3/core/templates/layout.guest.php</font> )</td><td title='/usr/local/owncloud/nextcloud-22.2.3/lib/private/Template/Base.php' bgcolor='#eeeeec'>.../Base.php<b>:</b>180</td></tr>\n<tr><td bgcolor='#eeeeec' align='center'>11</td><td bgcolor='#eeeeec' align='center'>0.5960</td><td bgcolor='#eeeeec' align='right'>7519480</td><td bgcolor='#eeeeec'>OCP\\Defaults->getLongFooter(  )</td><td title='/usr/local/owncloud/nextcloud-22.2.3/core/templates/layout.guest.php' bgcolor='#eeeeec'>.../layout.guest.php<b>:</b>52</td></tr>\n<tr><td bgcolor='#eeeeec' align='center'>12</td><td bgcolor='#eeeeec' align='center'>0.5960</td><td bgcolor='#eeeeec' align='right'>7519480</td><td bgcolor='#eeeeec'>OC_Defaults->getLongFooter(  )</td><td title='/usr/local/owncloud/nextcloud-22.2.3/lib/public/Defaults.php' bgcolor='#eeeeec'>.../Defaults.php<b>:</b>177</td></tr>\n<tr><td bgcolor='#eeeeec' align='center'>13</td><td bgcolor='#eeeeec' align='center'>0.5960</td><td bgcolor='#eeeeec' align='right'>7519480</td><td bgcolor='#eeeeec'>OCA\\Theming\\ThemingDefaults->getShortFooter(  )</td><td title='/usr/local/owncloud/nextcloud-22.2.3/lib/private/legacy/OC_Defaults.php' bgcolor='#eeeeec'>.../OC_Defaults.php<b>:</b>280</td></tr>\n<tr><td bgcolor='#eeeeec' align='center'>14</td><td bgcolor='#eeeeec' align='center'>0.5963</td><td bgcolor='#eeeeec' align='right'>7522160</td><td bgcolor='#eeeeec'>OC\\NavigationManager->getAll( <span>$type = </span><span>&#39;guest&#39;</span> )</td><td title='/usr/local/owncloud/nextcloud-22.2.3/apps/theming/lib/ThemingDefaults.php' bgcolor='#eeeeec'>.../ThemingDefaults.php<b>:</b>188</td></tr>\n<tr><td bgcolor='#eeeeec' align='center'>15</td><td bgcolor='#eeeeec' align='center'>0.5963</td><td bgcolor='#eeeeec'>OC\\Route\\Router->generate( <span>$name = </span><span>&#39;notes.page.index&#39;</span>, <span>$parameters = </span><span>[]</span>, <span>$absolute = </span><span>FALSE</span> )</td><td title='/usr/local/owncloud/nextcloud-22.2.3/lib/private/Route/CachingRouter.php' bgcolor='#eeeeec'>.../CachingRouter.php<b>:</b>58</td></tr>\n<tr><td bgcolor='#eeeeec' align='center'>19</td><td bgcolor='#eeeeec' align='center'>0.6071</td><td bgcolor='#eeeeec' align='right'>7567800</td><td bgcolor='#eeeeec'>Symfony\\Component\\Routing\\Generator\\UrlGenerator->generate( <span>$name = </span><span>&#39;notes.page.index&#39;</span>, <span>$parameters = </span><span>[]</span>, <span>$referenceType = </span><span>1</span> )</td><td title='/usr/local/owncloud/nextcloud-22.2.3/lib/private/Route/Router.php' bgcolor='#eeeeec'>.../Router.php<b>:</b>361</td></tr>\n"},"CustomMessage":"Unable to generate a URL for the named route \"notes.page.index\" as such route does not exist."}}

Additional info

This is not a new thing. I saw the same behaviuor some years ago already. It was then fixed and has now about (approx) since summer reappeared. Was some old code reintroduced?

kesselb commented 1 year ago

https://github.com/nextcloud/server/pull/29695 maybe?

DagNygren commented 1 year ago

Maybe. But I am using PHP 7.4...

kesselb commented 1 year ago

image

Please update your bug report then.

DagNygren commented 1 year ago

Where did that come from? I am pretty sure I entered 7.4. Even checked for it using php --version ... I cannot find a way to update the original. But it IS 7.4 Edit: Found a way and now updated.

RainerKlute commented 1 year ago

I just stumbled over the same bug after a regular openSUSE Tumbleweed system update which among other stuff brought my apache2 package to version 2.4.57-2.1. My PHP version is 8.2.8.

The workaround described above, i. e., having the isSetLocaleWorking() function in lib/private/legacy/OC_Util.php always return "true", works fine. Many thanks for that!

joshtrichards commented 1 week ago

What happens when you run occ check?

https://github.com/nextcloud/server/blob/3eadae3a69462dba2407a81a2325c9c61ee70adc/lib/private/legacy/OC_Util.php#L463-L470

There are three fallback approaches:

https://github.com/nextcloud/server/blob/3eadae3a69462dba2407a81a2325c9c61ee70adc/lib/private/legacy/OC_Util.php#L844-L853

Are any functions disabled in your php environment?