[Bug]: typ-bug in user_ldap app when using memcache.kvstore - KeyValueCache::normalizeTtl() expects type int for $ttl
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 36.9k
- Forks
- 5.2k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 713
Description
⚠️ This issue respects the following points: ⚠️
- This is not a troubleshooting question, general support matter, or webserver/proxy problem, but likely a bug (if unsure, ask the Community Help Forum).
- This issue is not already reported on Github OR solved at the Community Help Forum (I've searched!).
- I'm using a maintained major version of Nextcloud Server and tested against the latest patch level. (Supported major versions and current patch levels).
- I agree to follow Nextcloud's Code of Conduct.
- I've tried my best to provide clear reproduction steps that someone unfamiliar with this bug could use to reproduce it.
Bug description
Nextcloud Version: 34.0.3.2
user_ldap: 1.25.0
Redis Sentinel Cluster (Redis Version: 8.10.1)
Nextcloud Server is setup with the new 'memcache.kvstore' memory caching backend.
Failure:
When logging in to the Nextcloud Server the user gets displayed "internal server error".
The Nextcloud log shows:
"CustomMessage":"OC\\Memcache\\KeyValueCache::normalizeTtl(): Argument #1 ($ttl) must be of type int, string given, called in /var/www/html/lib/private/Memcache/KeyValueCache.php on line 70"
This problem is caused by apps/user_ldap/lib/Connection.php:312 providing the param ttl as string.
The trace shows:
"Exception": "TypeError",
"Message": "OC\\Memcache\\KeyValueCache::normalizeTtl(): Argument #1 ($ttl) must be of type int, string given, called in /var/www/html/lib/private/Memcache/KeyValueCache.php on line 70",
"Code": 0,
"Trace": [{
"file": "/var/www/html/lib/private/Memcache/KeyValueCache.php",
"line": 70,
"function": "normalizeTtl",
"class": "OC\\Memcache\\KeyValueCache",
"type": "->",
"args": ["600"]
}, {
"file": "/var/www/html/apps/user_ldap/lib/Connection.php",
"line": 312,
"function": "set",
"class": "OC\\Memcache\\KeyValueCache",
"type": "->",
"args": ["LDAP-user_ldap-s01-< id >", "\"W10=\"", "600"]
}, {
"file": "/var/www/html/apps/user_ldap/lib/Group_LDAP.php",
"line": 684,
"function": "writeToCache",
"class": "OCA\\User_LDAP\\Connection",
"type": "->",
"args": ["LDAP-user_ldap-s01-< id >", "W10="]
}, {
Connection::writeToCache() passes the LDAP-Cache-TTL value (ldapCacheTTL (default 600 secunds) as string "600" instead of int to the KeyValueCache.
Used Helm Chart values:
nextcloud:
defaultConfigs:
redis.config.php: false
configs:
zz-redis-sentinel.config.php: |-
<?php
$CONFIG = [
'memcache.locking' => '\OC\Memcache\KeyValueCache',
'memcache.distributed' => '\OC\Memcache\KeyValueCache',
'memcache.kvstore' => [
'sentinel' => [
'service' => 'mymaster',
'seeds' => [
['host' => 'nextcloud-redis-sentinel.nextcloud.svc.cluster.local', 'port' => 26379],
['host' => 'nextcloud-redis-0.nextcloud-redis-headless.nextcloud.svc.cluster.local', 'port' => 26379],
['host' => 'nextcloud-redis-1.nextcloud-redis-headless.nextcloud.svc.cluster.local', 'port' => 26379],
['host' => 'nextcloud-redis-2.nextcloud-redis-headless.nextcloud.svc.cluster.local', 'port' => 26379],
],
],
'password' => getenv('NEXTCLOUD_REDIS_PASSWORD') ?: null,
'timeout' => 1.5,
'read_timeout' => 1.5,
],
];
extraEnv:
- name: NEXTCLOUD_REDIS_PASSWORD
valueFrom:
secretKeyRef:
name: nextcloud-redis-credentials
key: password
Steps to reproduce
- Nextcloud Deployment with LDAP config and Redis Sentinel as memory caching backend.
- Login to the Nextcloud Server
- Login fails with internal server
error
Expected behavior
Since KeyValueCache enforces a strict type check, there is a explicite (int)-cast in Connection::writeToCache() for the ldapCacheTTL required.
Nextcloud Server version
34
Operating system
Debian/Ubuntu
PHP engine version
PHP 8.5
Web server
Apache (supported)
Database engine version
PostgreSQL
Is this bug present after an update or on a fresh install?
Fresh Nextcloud Server install
Are you using the Nextcloud Server Encryption module?
Encryption is Disabled
What user-backends are you using?
- Default user-backend (database)
- LDAP/ Active Directory
- SSO - SAML
- Other
Configuration report
occ config:list system
{
"system": {
"htaccess.RewriteBase": "\/",
"memcache.local": "\\OC\\Memcache\\APCu",
"apps_paths": [
{
"path": "\/var\/www\/html\/apps",
"url": "\/apps",
"writable": false
},
{
"path": "\/var\/www\/html\/custom_apps",
"url": "\/custom_apps",
"writable": true
}
],
"appstoreenabled": true,
"appstoreurl": "https:\/\/<appstore host>\/api\/v1",
"allow_local_remote_servers": true,
"auth.bruteforce.protection.enabled": false,
"check_for_working_wellknown_setup": false,
"debug": false,
"defaultapp": "files,dashboard",
"default_locale": "de_DE",
"default_phone_region": "DE",
"default_timezone": "Europe\/Berlin",
"enable_previews": false,
"force_language": "de",
"forwarded_for_headers": [
"HTTP_X_FORWARDED_FOR",
"HTTP_X_FORWARDED",
"HTTP_FORWARDED_FOR"
],
"has_internet_connection": false,
"mail_smtpmode": "null",
"maintenance_window_start": 1,
"no_unsupported_browser_warning": true,
"overwriteprotocol": "https",
"serverid": 0,
"skeletondirectory": "\/var\/www\/user-template",
"trusted_proxies": "***REMOVED SENSITIVE VALUE***",
"updatechecker": false,
"openmetrics_allowed_clients": [
"127.0.0.1",
"10.42.0.0\/16",
"10.43.0.0\/16"
],
"log_condition": {
"apps": [
"admin_audit"
],
"matches": [
{
"apps": [
"user_saml"
],
"loglevel": 0
}
]
},
"log_type": "file",
"log_type_audit": "file",
"logfilemode": 416,
"loglevel": 0,
"upgrade.disable-web": true,
"memcache.locking": "\\OC\\Memcache\\KeyValueCache",
"memcache.distributed": "\\OC\\Memcache\\KeyValueCache",
"memcache.kvstore": {
"sentinel": {
"service": "mymaster",
"seeds": [
{
"host": "nextcloud-redis-sentinel.nextcloud.svc.cluster.local",
"port": 26379
},
{
"host": "nextcloud-redis-0.nextcloud-redis-headless.nextcloud.svc.cluster.local",
"port": 26379
},
{
"host": "nextcloud-redis-1.nextcloud-redis-headless.nextcloud.svc.cluster.local",
"port": 26379
},
{
"host": "nextcloud-redis-2.nextcloud-redis-headless.nextcloud.svc.cluster.local",
"port": 26379
}
]
},
"password": "< redis repassword >"
},
"passwordsalt": "***REMOVED SENSITIVE VALUE***",
"secret": "***REMOVED SENSITIVE VALUE***",
"trusted_domains": [
"localhost",
"< some more trusted domains >"
],
"datadirectory": "***REMOVED SENSITIVE VALUE***",
"dbtype": "pgsql",
"version": "34.0.3.2",
"overwrite.cli.url": "https:\/\/localhost",
"instanceid": "***REMOVED SENSITIVE VALUE***",
"dbname": "***REMOVED SENSITIVE VALUE***",
"dbhost": "***REMOVED SENSITIVE VALUE***",
"dbtableprefix": "oc_",
"dbuser": "***REMOVED SENSITIVE VALUE***",
"dbpassword": "***REMOVED SENSITIVE VALUE***",
"installed": true,
"ldapProviderFactory": "OCA\\User_LDAP\\LDAPProviderFactory",
"maintenance": false,
"templatedirectory": ""
}
}
List of activated Apps
occ config:list system
{
"system": {
"htaccess.RewriteBase": "\/",
"memcache.local": "\\OC\\Memcache\\APCu",
"apps_paths": [
{
"path": "\/var\/www\/html\/apps",
"url": "\/apps",
"writable": false
},
{
"path": "\/var\/www\/html\/custom_apps",
"url": "\/custom_apps",
"writable": true
}
],
"appstoreenabled": true,
"appstoreurl": "https:\/\/<appstore host>\/api\/v1",
"allow_local_remote_servers": true,
"auth.bruteforce.protection.enabled": false,
"check_for_working_wellknown_setup": false,
"debug": false,
"defaultapp": "files,dashboard",
"default_locale": "de_DE",
"default_phone_region": "DE",
"default_timezone": "Europe\/Berlin",
"enable_previews": false,
"force_language": "de",
"forwarded_for_headers": [
"HTTP_X_FORWARDED_FOR",
"HTTP_X_FORWARDED",
"HTTP_FORWARDED_FOR"
],
"has_internet_connection": false,
"mail_smtpmode": "null",
"maintenance_window_start": 1,
"no_unsupported_browser_warning": true,
"overwriteprotocol": "https",
"serverid": 0,
"skeletondirectory": "\/var\/www\/user-template",
"trusted_proxies": "***REMOVED SENSITIVE VALUE***",
"updatechecker": false,
"openmetrics_allowed_clients": [
"127.0.0.1",
"10.42.0.0\/16",
"10.43.0.0\/16"
],
"log_condition": {
"apps": [
"admin_audit"
],
"matches": [
{
"apps": [
"user_saml"
],
"loglevel": 0
}
]
},
"log_type": "file",
"log_type_audit": "file",
"logfilemode": 416,
"loglevel": 0,
"upgrade.disable-web": true,
"memcache.locking": "\\OC\\Memcache\\KeyValueCache",
"memcache.distributed": "\\OC\\Memcache\\KeyValueCache",
"memcache.kvstore": {
"sentinel": {
"service": "mymaster",
"seeds": [
{
"host": "nextcloud-redis-sentinel.nextcloud.svc.cluster.local",
"port": 26379
},
{
"host": "nextcloud-redis-0.nextcloud-redis-headless.nextcloud.svc.cluster.local",
"port": 26379
},
{
"host": "nextcloud-redis-1.nextcloud-redis-headless.nextcloud.svc.cluster.local",
"port": 26379
},
{
"host": "nextcloud-redis-2.nextcloud-redis-headless.nextcloud.svc.cluster.local",
"port": 26379
}
]
},
"password": "< redis repassword >"
},
"passwordsalt": "***REMOVED SENSITIVE VALUE***",
"secret": "***REMOVED SENSITIVE VALUE***",
"trusted_domains": [
"localhost",
"< some more trusted domains >"
],
"datadirectory": "***REMOVED SENSITIVE VALUE***",
"dbtype": "pgsql",
"version": "34.0.3.2",
"overwrite.cli.url": "https:\/\/localhost",
"instanceid": "***REMOVED SENSITIVE VALUE***",
"dbname": "***REMOVED SENSITIVE VALUE***",
"dbhost": "***REMOVED SENSITIVE VALUE***",
"dbtableprefix": "oc_",
"dbuser": "***REMOVED SENSITIVE VALUE***",
"dbpassword": "***REMOVED SENSITIVE VALUE***",
"installed": true,
"ldapProviderFactory": "OCA\\User_LDAP\\LDAPProviderFactory",
"maintenance": false,
"templatedirectory": ""
}
}
Nextcloud Signing status
Due to the bug I cannot login.
Nextcloud Logs
"Exception": "TypeError",
"Message": "OC\\Memcache\\KeyValueCache::normalizeTtl(): Argument #1 ($ttl) must be of type int, string given, called in /var/www/html/lib/private/Memcache/KeyValueCache.php on line 70",
"Code": 0,
"Trace": [{
"file": "/var/www/html/lib/private/Memcache/KeyValueCache.php",
"line": 70,
"function": "normalizeTtl",
"class": "OC\\Memcache\\KeyValueCache",
"type": "->",
"args": ["600"]
}, {
"file": "/var/www/html/apps/user_ldap/lib/Connection.php",
"line": 312,
"function": "set",
"class": "OC\\Memcache\\KeyValueCache",
"type": "->",
"args": ["LDAP-user_ldap-s01-< id >", "\"W10=\"", "600"]
}, {
"file": "/var/www/html/apps/user_ldap/lib/Group_LDAP.php",
"line": 684,
"function": "writeToCache",
"class": "OCA\\User_LDAP\\Connection",
"type": "->",
"args": ["LDAP-user_ldap-s01-< id >", "W10="]
}, {
Additional info
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in apps/user_ldap/lib/Connection.php around line 312, where writeToCache() passes the LDAP cache TTL, and compare that call with the strict parameter expected by lib/private/Memcache/KeyValueCache.php. Reproduce the LDAP login using the memcache.kvstore Redis Sentinel configuration and confirm that the login succeeds without the TypeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, redis
- Domain
- authentication, backend
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 86/100