nextcloud / server

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

Personal settings are broken because some locales are gone #18412

Closed schinni15 closed 4 years ago

schinni15 commented 4 years ago

Personal Settings are broken. See errors from syslog Dec 15 10:06:33 linus Nextcloud[16449]: {"reqId":"JA5sfDetN3tNcaYa85On","level":3,"time":"2019-12-15T10:06:33+01:00","remoteAddr":"192.168.10.206","user":"wolfi","app":"PHP","method":"GET","url":"/nextcloud/index.php/settings/user","message":"Undefined index: code at /var/www/nextcloud/apps/settings/templates/settings/personal/personal.info.php#348","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:71.0) Gecko/20100101 Firefox/71.0","version":"18.0.0.4"} Dec 15 10:06:33 linus Nextcloud[16449]: {"reqId":"JA5sfDetN3tNcaYa85On","level":3,"time":"2019-12-15T10:06:33+01:00","remoteAddr":"192.168.10.206","user":"wolfi","app":"PHP","method":"GET","url":"/nextcloud/index.php/settings/user","message":"Undefined index: name at /var/www/nextcloud/apps/settings/templates/settings/personal/personal.info.php#349","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:71.0) Gecko/20100101 Firefox/71.0","version":"18.0.0.4"} Dec 15 10:06:33 linus Nextcloud[16449]: {"reqId":"JA5sfDetN3tNcaYa85On","level":3,"time":"2019-12-15T10:06:33+01:00","remoteAddr":"192.168.10.206","user":"wolfi","app":"index","method":"GET","url":"/nextcloud/index.php/settings/user","message":"{\"Exception\":\"Exception\",\"Message\":\"Argument 1 passed to OC\\L10N\\LazyL10N::t() must be of the type string, null given, called in /var/www/nextcloud/apps/settings/templates/settings/personal/personal.info.php on line 349\",\"Code\":0,\"Trace\":[{\"file\":\"/var/www/nextcloud/lib/private/AppFramework/App.php\",\"line\":125,\"function\":\"dispatch\",\"class\":\"OC\\AppFramework\\Http\\Dispatcher\",\"type\":\"->\",\"args\":[{\"class\":\"OCA\\Settings\\Controller\\PersonalSettingsController\"},\"index\"]},{\"file\":\"/var/www/nextcloud/lib/private/AppFramework/Routing/RouteActionHandler.php\",\"line\":47,\"function\":\"main\",\"class\":\"OC\\AppFramework\\App\",\"type\":\"::\",\"args\":[\"OCA\\Settings\\Controller\\PersonalSettingsController\",\"index\",{\"class\":\"OC\\AppFramework\\DependencyInjection\\DIContainer\"},{\"section\":\"personal-info\",\"_route\":\"settings.PersonalSettings.index\"}]},{\"function\":\"__invoke\",\"class\":\"OC\\AppFramework\\Routing\\RouteActionHandler\",\"type\":\"->\",\"args\":[{\"section\":\"personal-info\",\"_route\":\"settings.PersonalSettings.index\"}]},{\"file\":\"/var/www/nextcloud/lib/private/Route/Router.php\",\"line\":299,\"function\":\"call_user_func\",\"args\":[{\"class\":\"OC\\AppFramework\\Routing\\RouteActionHandler\"},{\"section\":\"personal-info\",\"_route\":\"settings.PersonalSettings.index\"}]},{\"file\":\"/var/www/nextcloud/lib/base.php\",\"line\":1008,\"function\":\"match\",\"class\":\"OC\\Route\\Router\",\"type\":\"->\",\"args\":[\"/settings/user\"]},{\"file\":\"/var/www/nextcloud/index.php\",\"line\":38,\"function\":\"handleRequest\",\"class\":\"OC\",\"type\":\"::\",\"args\":[]}],\"File\":\"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php\",\"Line\":109,\"Previous\":{\"Exception\":\"TypeError\",\"Message\":\"Argument 1 passed to OC\\L10N\\LazyL10N::t() must be of the type string, null given, called in /var/www/nextcloud/apps/settings/templates/settings/personal/personal.info.php on line 349\",\"Code\":0,\"Trace\":[{\"file\":\"/var/www/nextcloud/apps/settings/templates/settings/personal/personal.info.php\",\"line\":349,\"function\":\"t\",\"class\":\"OC\\L10N\\LazyL10N\",\"type\":\"->\",\"args\":[null]},{\"file\":\"/var/www/nextcloud/lib/private/Template/Base.php\",\"line\":179,\"args\":[\"/var/www/nextcloud/apps/settings/templates/settings/personal/personal.info.php\"],\"function\":\"include\"},{\"file\":\"/var/www/nextcloud/lib/private/Template/Base.php\",\"line\":151,\"function\":\"load\",\"class\":\"OC\\Template\\Base\",\"type\":\"->\",\"args\":[\"/var/www/nextcloud/apps/settings/templates/settings/personal/personal.info.php\",{\"total_space\":\"Unbegrenzt\",\"usage\":\"6.9 GB\",\"usage_relative\":3,\"quota\":-3,\"avatarChangeSupported\":true,\"lookupServerUploadEnabled\":true,\"avatarScope\":\"contacts\",\"displayNameChangeSupported\":false,\"displayName\":\"Schinni\",\"displayNameScope\":\"contacts\",\"email\":\"wolfi@***.com\",\"emailScope\":\"contacts\",\"emailVerification\":\"0\",\"phone\":\"\",\"phoneScope\":\"private\",\"address\":\"\",\"addressScope\":\"private\",\"website\":\"\",\"websiteScope\":\"private\",\"websiteVerification\":\"0\",\"twitter\":\"\",\"twitterScope\":\"private\",\"twitterVerification\":\"0\",\"groups\":[\"Domain Users\",\"Parents\"],\"emailMessage\":\"\u00dcberpr\u00fcfen\",\"websiteMessage\":\"\u00dcberpr\u00fcfen\",\"twitterMessage\":\"\u00dcberpr\u00fcfen\",\"activelanguage\":{\"code\":\"de\",\"name\":\"Deutsch (Pers\u00f6nlich: Du)\"},\"commonlanguages\":[{\"code\":\"en\",\"name\":\"English (US)\"},{\"code\":\"es\",\"name\":\"Espa\u00f1ol (Espa\u00f1a)\"},{\"code\":\"fr\",\"name\":\"Fran\u00e7ais\"},{\"code\":\"de\",\"name\":\"Deutsch (Pers\u00f6nlich: Du)\"},{\"code\":\"de_DE\",\"name\":\"Deutsch (F\u00f6rmlich: Sie)\"},{\"code\":\"ja\",\"name\":\"Japanese (\u65e5\u672c\u8a9e)\"},{\"code\":\"ar\",\"name\":\"\u0627\u0644\u0644\u063a\u0629 \u0627\u0644\u0639\u0631\u0628\u064a\u0629\"},{\"code\":\"ru\",\"name\":\"\u0420\u0443\u0441\u0441\u043a\u0438\u0439\"},{\"code\":\"nl\",\"name\":\"Nederlands\"},{\"code\":\"it\",\"name\":\"Italiano\"},{\"code\":\"pt_BR\",\"name\":\"Portugu\u00eas Brasileiro\"},{\"code\":\"pt_PT\",\"name\":\"Portugu\u00eas\"},{\"code\":\"da\",\"name\":\"Dansk\"},{\"code\":\"sv\",\"name\":\"Svenska\"},{\"code\":\"tr\",\"name\":\"T\u00fcrk\u00e7e\"},{\"code\":\"zh_CN\",\"name\":\"\u7b80\u4f53\u4e2d\u6587\"},{\"code\":\"ko\",\"name\":\"\ud55c\uad6d\uc5b4\"}],\"languages\":[{\"code\":\"af\",\"name\":\"Afrikaans\"},{\"code\":\"ast\",\"name\":\"Asturianu\"},{\"code\":\"id\",\"name\":\"Bahasa Indonesia\"},{\"code\":\"ca\",\"name\":\"Catal\u00e0\"},{\"code\":\"et_EE\",\"name\":\"Eesti\"},{\"code\":\"en_GB\",\"name\":\"English (British English)\"},{\"code\":\"es_AR\",\"name\":\"Espa\u00f1ol (Argentina)\"},{\"code\":\"es_CL\",\"name\":\"Espa\u00f1ol (Chile)\"},{\"code\":\"es_CO\",\"name\":\"Espa\u00f1ol (Colombia)\"},{\"code\":\"es_CR\",\"name\":\"Espa\u00f1ol (Costa Rica)\"},{\"code\":\"es_DO\",\"name\":\"Espa\u00f1ol (Dominican Republic)\"},{\"code\":\"es_EC\",\"name\":\"Espa\u00f1ol (Ecuador)\"},{\"code\":\"es_SV\",\"name\":\"Espa\u00f1ol (El Salvador)\"},{\"code\":\"es_GT\",\"name\":\"Espa\u00f1ol (Guatemala)\"},{\"code\":\"es_HN\",\"name\":\"Espa\u00f1ol (Honduras)\"},{\"code\":\"es_419\",\"name\":\"Espa\u00f1ol (Latin America)\"},{\"code\":\"es_MX\",\"name\":\"Espa\u00f1ol (M\u00e9xico)\"},{\"code\":\"es_NI\",\"name\":\"Espa\u00f1ol (Nicaragua)\"},{\"code\":\"es_PA\",\"name\":\"Espa\u00f1ol (Panama)\"},{\"code\":\"es_PY\",\"name\":\"Espa\u00f1ol (Paraguay)\"},{\"code\":\"es_PE\",\"name\":\"Espa\u00f1ol (Peru)\"},{\"code\":\"es_PR\",\"name\":\"Espa\u00f1ol (Puerto Rico)\"},{\"code\":\"es_UY\",\"name\":\"Espa\u00f1ol (Uruguay)\"},{\"code\":\"eo\",\"name\":\"Esperanto\"},{\"code\":\"eu\",\"name\":\"Euskara\"},{\"code\":\"gl\",\"name\":\"Galego\"},{\"code\":\"lv\",\"name\":\"Latvie\u0161u\"},{\"code\":\"lt_LT\",\"name\":\"Lietuvi\u0173\"},{\"code\":\"hu\",\"name\":\"Magyar\"},{\"code\":\"nb\",\"name\":\"Norsk bokm\u00e5l\"},{\"code\":\"pl\",\"name\":\"Polski\"},{\"code\":\"ro\",\"name\":\"Rom\u00e2n\u0103\"},{\"code\":\"sq\",\"name\":\"Shqip\"},{\"code\":\"sk\",\"name\":\"Sloven\u010dina\"},{\"code\":\"sl\",\"name\":\"Sloven\u0161\u010dina\"},{\"code\":\"vi\",\"name\":\"Ti\u1ebfng Vi\u1ec7t\"},{\"code\":\"fi\",\"name\":\"suomi\"},{\"code\":\"is\",\"name\":\"\u00cdslenska\"},{\"code\":\"cs\",\"name\":\"\u010de\u0161tina\"},{\"code\":\"el\",\"name\":\"\u0395\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac\"},{\"code\":\"bg\",\"name\":\"\u0411\u044a\u043b\u0433\u0430\u0440\u0441\u043a\u0438\"},{\"code\":\"mk\",\"name\":\"\u041c\u0430\u043a\u0435\u0434\u043e\u043d\u0441\u043a\u0438\"},{\"code\":\"sr\",\"name\":\"\u0421\u0440\u043f\u0441\u043a\u0438\"},{\"code\":\"uk\",\"name\":\"\u0423\u043a\u0440\u0430\u0457\u043d\u0441\u044c\u043a\u0430\"},{\"code\":\"he\",\"name\":\"\u05e2\u05d1\u05e8\u05d9\u05ea\"},{\"code\":\"fa\",\"name\":\"\u0641\u0627\u0631\u0633\u0649\"},{\"code\":\"ka_GE\",\"name\":\"\u10e5\u10d0\u10e0\u10d7\u10e3\u10da\u10d8\"},{\"code\":\"zh_TW\",\"name\":\"\u6b63\u9ad4\u4e2d\u6587\uff08\u81fa\u7063\uff09\"},{\"code\":\"hr\",\"name\":\"hr\"}],\"activelocaleLang\":\"de_AT\",\"activelocale\":[],\"locales\":[{\"code\":\"af\",\"name\":\"Afrikaans\"},{\"code\":\"am\",\"name\":\"Amharic\"},{\"code\":\"ar\",\"name\":\"Arabic\"},{\"code\":\"as\",\"name\":\"Assamese\"},{\"code\":\"az\",\"name\":\"Azerbaijani\"},{\"code\":\"bal\",\"name\":\"Balochi\"},{\"code\":\"be\",\"name\":\"Belarusian\"},{\"code\":\"bg\",\"name\":\"Bulgarian\"},{\"code\":\"bn\",\"name\":\"Bengali\"

kesselb commented 4 years ago

Hmm. $_['activelocale'] is set but $_['activelocale']['code'] not. Which locale is configured for the user?

Index: apps/settings/templates/settings/personal/personal.info.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- apps/settings/templates/settings/personal/personal.info.php (revision 42c8f9f679e61acd7a29ab9e1a457bda094a4a2c)
+++ apps/settings/templates/settings/personal/personal.info.php (date 1576407881631)
@@ -339,7 +339,7 @@
            <?php } ?>
        </div>
        <div class="personal-settings-setting-box personal-settings-locale-box">
-           <?php if (isset($_['activelocale'])) { ?>
+           <?php if (isset($_['activelocale']['code'], $_['activelocale']['name'])) { ?>
                <form id="locale" class="section">
                    <h3>
                        <label for="localeinput"><?php p($l->t('Locale'));?></label>

Probably a more specific check could help. But activelocale seems to be broken.

schinni15 commented 4 years ago

I'am using de_AT as locale. I changed the entry in the database table oc_preferences and everything is working fine. The entry de_AT is obviously missing.

kesselb commented 4 years ago

Regression from https://github.com/nextcloud/server/pull/17222

The following locales are not available anymore with Nextcloud 18:

af_NA
ak_GH
ar_AE
ar_BH
ar_DZ
ar_EG
ar_IQ
ar_JO
ar_KW
ar_LB
ar_LY
ar_MA
ar_OM
ar_QA
ar_SD
ar_SY
ar_TN
ar_YE
asa
asa_TZ
az_Cyrl
az_Cyrl_AZ
az_Latn
az_Latn_AZ
bem
bem_ZM
bez
bez_TZ
b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_Latn
sr_Latn_BA
sr_Latn_ME
sr_Latn_RS
sw_TZ
teo
teo_KE
teo_UG
ti_ER
ti_ET
to_TO
tzm
tzm_Latn
tzm_Latn_MA
ur_IN
uz_Arab
uz_Arab_AF
uz_Cyrl
uz_Cyrl_UZ
uz_Latn
uz_Latn_UZ
vun
vun_TZ
xog
xog_UG
yo_NG
zh_Hans
zh_Hans_CN
zh_Hans_HK
zh_Hans_MO
zh_Hans_SG
zh_Hant
zh_Hant_HK
zh_Hant_MO
zh_Hant_TW
<?php

function fetchLocales(string $url) {
    return array_column(json_decode(file_get_contents($url), false), 'code');
}

$stable17 = fetchLocales('https://raw.githubusercontent.com/nextcloud/server/stable17/resources/locales.json');
$master = fetchLocales('https://raw.githubusercontent.com/nextcloud/server/master/resources/locales.json');

$missing = array_diff($stable17, $master);
sort($missing);
echo implode(PHP_EOL, $missing);

cc @skjnldsv @georgehrke

skjnldsv commented 4 years ago

Hum, I guess the used file list is not correct. https://www.transifex.com/explore/languages/

kesselb commented 4 years ago

https://github.com/transifex/transifex/blob/devel/transifex/languages/fixtures/all_languages.json the file is around 7 years old. I'm not sure if using languages as source for locales makes sense :thinking:

skjnldsv commented 4 years ago

I'm not sure if using languages as source for locales makes sense

Nope indeed! Let's see if I can find a more up to date, or else we'll revert the other commit

kesselb commented 4 years ago
<?php

$data = [];
$locales = ResourceBundle::getLocales('');

foreach ($locales as $localeCode) {
    $data[] = [
        'code' => $localeCode,
        'name' => Locale::getDisplayName($localeCode, 'en')
    ];
}

echo json_encode($data, JSON_PRETTY_PRINT);

If the php-intl extension is available. These locales are missing then. Don't know if they are valid.

bs_BA
ff_SN
gv_GB
ha_Latn
ha_Latn_GH
ha_Latn_NE
ha_Latn_NG
kk_Cyrl
kk_Cyrl_KZ
tzm_Latn
tzm_Latn_MA
skjnldsv commented 4 years ago

https://www.transifex.com/api/2/languages

kesselb commented 4 years ago

https://www.transifex.com/api/2/languages

af_NA
ak_GH
ar_BH
ar_KW
ar_LY
ar_MA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z_Cyrl
uz_Cyrl_UZ
uz_Latn
uz_Latn_UZ
vun
vun_TZ
xog
xog_UG
yo_NG
zh_Hans
zh_Hans_CN
zh_Hans_HK
zh_Hans_MO
zh_Hans_SG
zh_Hant
zh_Hant_HK
zh_Hant_MO
zh_Hant_TW
<?php

function fetchLocales(string $url) {
    return array_column(json_decode(file_get_contents($url), false), 'code');
}

$stable17 = fetchLocales('https://raw.githubusercontent.com/nextcloud/server/stable17/resources/locales.json');
//$master = fetchLocales('https://raw.githubusercontent.com/nextcloud/server/master/resources/locales.json');
//$intlTest = ResourceBundle::getLocales('');
$transifex = fetchLocales('https://www.transifex.com/api/2/languages');

//$missing = array_diff($stable17, $master);
//sort($missing);
//echo implode(PHP_EOL, $missing);

//$missing2 = array_diff($stable17, $intlTest);
//sort($missing2);
//echo implode(PHP_EOL, $missing2);

$missing3 = array_diff($stable17, $transifex);
sort($missing3);
echo implode(PHP_EOL, $missing3);
skjnldsv commented 4 years ago

Shall we drop them? If even transifex doesn't support them, does it make sense?

kesselb commented 4 years ago

Shall we drop them?

I don't think so. The transifex response is a list of languages. Locales is a different story. We can use https://github.com/nextcloud/server/issues/18412#issuecomment-566071176 to generate the list of locales. Even if we don't support the language itself we can still support their locale because the information itself should be present (like date format or currency).

But we should ask someone else for a third opinion ;)

skjnldsv commented 4 years ago

Do we require the php intl ? cc @rullzer

kesselb commented 4 years ago

Do we require the php intl ?

No. But instead of asking the transifex api for a list of languages you can use above script to generate the same list ;) For your development machine php-intl is required then.

skjnldsv commented 4 years ago

Ah right, that is a fair point! :) Mind to open a pr?