`Error: Trying to access array offset on value of type bool at /lib/private/Files/Storage/Wrapper/Encryption.php#441`
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 36.9k
- Forks
- 5.2k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 713
Description
Apache dockered system, with server-side encryption. Every time a file is uploaded it causes this title error.
Nextcloud 21.0.2 - docker (apache version 21)
Staff, server-side encryption enabled, I send a file to nextcloud and keep giving this error:
{"reqId":"nAU9EEOe7Yk3F4w9OKFH","level":3,"time":"2021-06-27T03:13:34+00:00","remoteAddr":"198.98.60.69","user":"admin","app":"PHP","method":"PUT","url":"/remote.php/dav/uploads/admin/web-file-upload-2bb04d3a2365a787a83d9e564ce62762-1624763522335/94371840","message":{"Exception":"Error","Message":"Trying to access array offset on value of type bool at /var/www/html/lib/private/Files/Storage/Wrapper/Encryption.php#441","Code":0,"Trace":[{"file":"/var/www/html/lib/private/Files/Storage/Wrapper/Encryption.php","line":441,"function":"onError","class":"OC\\Log\\ErrorHandler","type":"::","args":[8,"Trying to access array offset on value of type bool","/var/www/html/lib/private/Files/Storage/Wrapper/Encryption.php",441,{"0":"And 10 more entries, set log level to debug to see all entries","path":"uploads/web-file-upload-2bb04d3a2365a787a83d9e564ce62762-1624763522335/94371840.ocTransferId1651349529.part","mode":"r","encryptionEnabled":true,"shouldEncrypt":false,"encryptionModule":null}]},{"file":"/var/www/html/lib/private/Files/Storage/Wrapper/Wrapper.php","line":302,"function":"fopen","class":"OC\\Files\\Storage\\Wrapper\\Encryption","type":"->","args":["uploads/web-file-upload-2bb04d3a2365a787a83d9e564ce62762-1624763522335/94371840.ocTransferId1651349529.part","r"]},{"file":"/var/www/html/lib/private/Files/Storage/Wrapper/Encryption.php","line":753,"function":"fopen","class":"OC\\Files\\Storage\\Wrapper\\Wrapper","type":"->","args":["uploads/web-file-upload-2bb04d3a2365a787a83d9e564ce62762-1624763522335/94371840.ocTransferId1651349529.part","r"]},{"file":"/var/www/html/lib/private/Files/Storage/Wrapper/Encryption.php","line":623,"function":"copyBetweenStorage","class":"OC\\Files\\Storage\\Wrapper\\Encryption","type":"->","args":[{"cache":null,"scanner":{"__class__":"OC\\Files\\Cache\\Scanner"},"watcher":null,"propagator":null,"updater":null,"__class__":"OCA\\Files_Trashbin\\Storage"},"uploads/web-file-upload-2bb04d3a2365a787a83d9e564ce62762-1624763522335/94371840.ocTransferId1651349529.part","uploads/web-file-upload-2bb04d3a2365a787a83d9e564ce62762-1624763522335/94371840",true,true]},{"file":"/var/www/html/apps/files_trashbin/lib/Storage.php","line":240,"function":"moveFromStorage","class":"OC\\Files\\Storage\\Wrapper\\Encryption","type":"->","args":[{"cache":null,"scanner":{"__class__":"OC\\Files\\Cache\\Scanner"},"watcher":null,"propagator":null,"updater":null,"__class__":"OCA\\Files_Trashbin\\Storage"},"uploads/web-file-upload-2bb04d3a2365a787a83d9e564ce62762-1624763522335/94371840.ocTransferId1651349529.part","uploads/web-file-upload-2bb04d3a2365a787a83d9e564ce62762-1624763522335/94371840"]},{"file":"/var/www/html/apps/dav/lib/Connector/Sabre/File.php","line":292,"function":"moveFromStorage","class":"OCA\\Files_Trashbin\\Storage","type":"->","args":[{"cache":null,"scanner":{"__class__":"OC\\Files\\Cache\\Scanner"},"watcher":null,"propagator":null,"updater":null,"__class__":"OCA\\Files_Trashbin\\Storage"},"uploads/web-file-upload-2bb04d3a2365a787a83d9e564ce62762-1624763522335/94371840.ocTransferId1651349529.part","uploads/web-file-upload-2bb04d3a2365a787a83d9e564ce62762-1624763522335/94371840"]},{"file":"/var/www/html/apps/dav/lib/Connector/Sabre/Directory.php","line":156,"function":"put","class":"OCA\\DAV\\Connector\\Sabre\\File","type":"->","args":[null]},{"file":"/var/www/html/apps/dav/lib/Upload/UploadFolder.php","line":46,"function":"createFile","class":"OCA\\DAV\\Connector\\Sabre\\Directory","type":"->","args":["94371840",null]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php","line":1098,"function":"createFile","class":"OCA\\DAV\\Upload\\UploadFolder","type":"->","args":["94371840",null]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/CorePlugin.php","line":504,"function":"createFile","class":"Sabre\\DAV\\Server","type":"->","args":["uploads/admin/web-file-upload-2bb04d3a2365a787a83d9e564ce62762-1624763522335/94371840",null,null]},{"file":"/var/www/html/3rdparty/sabre/event/lib/
WildcardEmitterTrait.php","line":89,"function":"httpPut","class":"Sabre\\DAV\\CorePlugin","type":"->","args":[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php","line":472,"function":"emit","class":"Sabre\\DAV\\Server","type":"->","args":["method:PUT",[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php","line":253,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->","args":[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php","line":321,"function":"start","class":"Sabre\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/html/apps/dav/lib/Server.php","line":332,"function":"exec","class":"Sabre\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/html/apps/dav/appinfo/v2/remote.php","line":35,"function":"exec","class":"OCA\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/html/remote.php","line":167,"args":["/var/www/html/apps/dav/appinfo/v2/remote.php"],"function":"require_once"}],"File":"/var/www/html/lib/private/Log/ErrorHandler.php","Line":92,"CustomMessage":"--"},"userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36","version":"21.0.2.1","id":"60d7ecdf0d073"}

How does the error happen?
Just upload any file to nextcloud with encryption enabled.
My docker-compose.yml
version: '3.9'
services:
nc_db:
image: postgres:13-alpine
container_name: nc_db
restart: always
volumes:
- ./volumes/db:/var/lib/postgresql/data
env_file:
- db.env
nc:
image: nextcloud:21
container_name: nc
restart: always
volumes:
- ./volumes/nextcloud:/var/www/html
- /home/tales/nfs/Nextcloud/data:/var/www/html/data
environment:
- PHP_MEMORY_LIMIT=2G
- PHP_UPLOAD_LIMIT=5G
- POSTGRES_HOST=nc_db
- REDIS_HOST_PASSWORD=SENHA
env_file:
- db.env
depends_on:
- nc_db
- rds
rds:
image: redis:alpine
container_name: rds
restart: unless-stopped
command: redis-server --requirepass SENHA
volumes:
- ./volumes/redis:/data
networks:
default:
external:
name: nginxproxymanager_default
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 with lib/private/Files/Storage/Wrapper/Encryption.php around line 441 and follow the upload path shown in the trace through apps/dav/lib/Upload/UploadFolder.php. Reproduce an upload with server-side encryption enabled in the Nextcloud 21 Docker setup, then inspect why the encryption lookup is returning a boolean. Done means uploads complete without the array-offset error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, php
- Domain
- backend, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100