[21.0.1] "Error: Trying to access array offset on value of type bool" at lib/private/Files/Storage/Wrapper/Encryption.php#441
How to use GitHub
- Please use the 👍 reaction to show that you are affected by the same issue.
- Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
- Subscribe to receive notifications on status change and new comments.
Steps to reproduce
- Open Administration / Logging
Expected behaviour
There should be no errors.
Actual behaviour
See Encryption errors:
See multiple errors:
[PHP] Error: Error: Trying to access array offset on value of type bool at /www/htdocs/w***/nextcloud/lib/private/Files/Storage/Wrapper/Encryption.php#441 at <<closure>>
0. /www/htdocs/w***/nextcloud/lib/private/Files/Storage/Wrapper/Encryption.php line 441
OC\Log\ErrorHandler::onError(8, "Trying to acces ... l", "/www/htdocs/w01 ... p", 441, {0: "And 10 more ... l})
1. /www/htdocs/w***/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php line 302
OC\Files\Storage\Wrapper\Encryption->fopen("uploads/2778862 ... t", "r")
2. /www/htdocs/w***/nextcloud/lib/private/Files/Storage/Wrapper/Encryption.php line 753
OC\Files\Storage\Wrapper\Wrapper->fopen("uploads/2778862 ... t", "r")
3. /www/htdocs/w***/nextcloud/lib/private/Files/Storage/Wrapper/Encryption.php line 623
OC\Files\Storage\Wrapper\Encryption->copyBetweenStorage(OCA\Files_Trashb ... l}, "uploads/2778862 ... t", "uploads/2778862110/00000089", true, true)
4. /www/htdocs/w***/nextcloud/apps/files_trashbin/lib/Storage.php line 240
OC\Files\Storage\Wrapper\Encryption->moveFromStorage(OCA\Files_Trashb ... l}, "uploads/2778862 ... t", "uploads/2778862110/00000089")
5. /www/htdocs/w***/nextcloud/apps/dav/lib/Connector/Sabre/File.php line 292
OCA\Files_Trashbin\Storage->moveFromStorage(OCA\Files_Trashb ... l}, "uploads/2778862 ... t", "uploads/2778862110/00000089")
6. /www/htdocs/w***/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php line 156
OCA\DAV\Connector\Sabre\File->put(null)
7. /www/htdocs/w***/nextcloud/apps/dav/lib/Upload/UploadFolder.php line 46
OCA\DAV\Connector\Sabre\Directory->createFile("00000089", null)
8. /www/htdocs/w***/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 1098
OCA\DAV\Upload\UploadFolder->createFile("00000089", null)
9. /www/htdocs/w***/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php line 504
Sabre\DAV\Server->createFile("uploads/***/2778862110/00000089", null, null)
10. /www/htdocs/w***/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php line 89
Sabre\DAV\CorePlugin->httpPut(Sabre\HTTP\Request {}, Sabre\HTTP\Response {})
11. /www/htdocs/w***/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 472
Sabre\DAV\Server->emit("method:PUT", [Sabre\HTTP\Requ ... }])
12. /www/htdocs/w***/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 253
Sabre\DAV\Server->invokeMethod(Sabre\HTTP\Request {}, Sabre\HTTP\Response {})
13. /www/htdocs/w***/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 321
Sabre\DAV\Server->start()
14. /www/htdocs/w***/nextcloud/apps/dav/lib/Server.php line 332
Sabre\DAV\Server->exec()
15. /www/htdocs/w***/nextcloud/apps/dav/appinfo/v2/remote.php line 35
OCA\DAV\Server->exec()
16. /www/htdocs/w***/nextcloud/remote.php line 167
require_once("/www/htdocs/w01 ... p")
PUT /remote.php/dav/uploads/***/2778862110/00000089
from ***.***.***.*** by *** at 2021-04-09T10:02:40+00:00
Server configuration
Operating system: Ubuntu
Web server: Apache 2.4
Database: MySQL 5.7.28-nmm1-log (c.f. #26470)
PHP version: 7.4.14
Nextcloud version: 21.0.1
Updated from an older Nextcloud/ownCloud or fresh install: Update from 20.0.8 (c.f. #26469)
Where did you install Nextcloud from: Updater
Signing status:
Signing status
No errors have been found.
</details>
**List of activated apps:**
<details>
<summary>App list</summary>
n/a
</details>
**Nextcloud configuration:**
<details>
<summary>Config report</summary>
n/a
</details>
**Are you using external storage, if yes which one:** no
**Are you using encryption:** no
**Are you using an external user-backend, if yes which one:** no
### Client configuration
**Browser:** Firefox Browser Nightly (2021-04-09)
**Operating system:** Windows 10
### Logs
<!--- Reports without logs might be closed as unqualified reports! -->
#### Web server error log
<details>
<summary>Web server error log</summary>
n/a
</details>
#### Nextcloud log (data/nextcloud.log)
<details>
<summary>Nextcloud log</summary>
n/a
</details>
#### Browser log
<details>
<summary>Browser log</summary>
n/a
</details>
Same issue appears right after upgrade from NC 20.0.8 to 20.0.9 (message never seen on 20.0.8).
Log from NC 20.0.9
{
"reqId": "tJTPnzsZTjlh60DEcxmd",
"level": 4,
"time": "2021-04-13T10:28:17+00:00",
"remoteAddr": "<removed>",
"user": "<removed>",
"app": "webdav",
"method": "DELETE",
"url": "/remote.php/dav/files/<removed>/Joplin/locks/sync_desktop_a535d7e027ae44a7b0b7bdc72b971073.json",
"message": {
"Exception": "Error",
"Message": "Call to a member function getId() on array",
"Code": 0,
"Trace": [
{
"file": "/var/www/html/lib/private/Files/Cache/Updater.php",
"line": 160,
"function": "remove",
"class": "OC\\Files\\Cache\\Cache",
"type": "->",
"args": [
"files/Joplin/locks/sync_desktop_a535d7e027ae44a7b0b7bdc72b971073.json"
]
},
{
"file": "/var/www/html/lib/private/Files/View.php",
"line": 329,
"function": "remove",
"class": "OC\\Files\\Cache\\Updater",
"type": "->",
"args": [
"files/Joplin/locks/sync_desktop_a535d7e027ae44a7b0b7bdc72b971073.json"
]
},
{
"file": "/var/www/html/lib/private/Files/View.php",
"line": 1179,
"function": "removeUpdate",
"class": "OC\\Files\\View",
"type": "->",
"args": [
{
"cache": null,
"scanner": {
"__class__": "OC\\Files\\Cache\\Scanner"
},
"watcher": null,
"propagator": null,
"updater": {
"__class__": "OC\\Files\\Cache\\Updater"
},
"__class__": "OCA\\Files_Trashbin\\Storage"
},
"files/Joplin/locks/sync_desktop_a535d7e027ae44a7b0b7bdc72b971073.json"
]
},
{
"file": "/var/www/html/lib/private/Files/View.php",
"line": 724,
"function": "basicOperation",
"class": "OC\\Files\\View",
"type": "->",
"args": [
"unlink",
"/Joplin/locks/sync_desktop_a535d7e027ae44a7b0b7bdc72b971073.json",
[
"delete"
]
]
},
{
"file": "/var/www/html/apps/dav/lib/Connector/Sabre/File.php",
"line": 466,
"function": "unlink",
"class": "OC\\Files\\View",
"type": "->",
"args": [
"/Joplin/locks/sync_desktop_a535d7e027ae44a7b0b7bdc72b971073.json"
]
},
{
"file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/Tree.php",
"line": 183,
"function": "delete",
"class": "OCA\\DAV\\Connector\\Sabre\\File",
"type": "->",
"args": []
},
{
"file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/CorePlugin.php",
"line": 295,
"function": "delete",
"class": "Sabre\\DAV\\Tree",
"type": "->",
"args": [
"files/<removed>/Joplin/locks/sync_desktop_a535d7e027ae44a7b0b7bdc72b971073.json"
]
},
{
"file": "/var/www/html/3rdparty/sabre/event/lib/WildcardEmitterTrait.php",
"line": 89,
"function": "httpDelete",
"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": 474,
"function": "emit",
"class": "Sabre\\DAV\\Server",
"type": "->",
"args": [
"method:DELETE",
[
{
"__class__": "Sabre\\HTTP\\Request"
},
{
"__class__": "Sabre\\HTTP\\Response"
}
]
]
},
{
"file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php",
"line": 251,
"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": 319,
"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/Files/Cache/Cache.php",
"Line": 528,
"CustomMessage": "--"
},
"userAgent": "Joplin/1.0",
"version": "20.0.9.1"
}
This issue (as reported by @caugner) seems to be caused by a change in the filesystem cache code that was introduced in 20.0.9 and 21.0.1. It crashes here:
https://github.com/nextcloud/server/blob/23b8e4a1d4e3d3f54d18f6c7f1be57baf8f75795/lib/private/Files/Storage/Wrapper/Encryption.php#L441
but $info is actually assigned here:
https://github.com/nextcloud/server/blob/23b8e4a1d4e3d3f54d18f6c7f1be57baf8f75795/lib/private/Files/Storage/Wrapper/Encryption.php#L435
So something in the cache code causes $info to be different than it was in previous versions of Nextcloud. One commit that caught my attention is https://github.com/nextcloud/server/commit/b8442935361703ce6cd9e17ec50d64584cd35673#diff-2b1f228ea5cf1c94347251d18c7a94f86bfb229573277dd160cb57cd7b16c864 by @icewind1991 (and committed by @rullzer). It documents the possibility of a null return for metadata requests, so that's in line with the issue we're seeing here. But I am not sure how that commit (which addresses an issue with SMB) relates to the context we have here (no SMB).
Anyone a suggestion? @nextcloud/encryption
Of course we'll likely have to catch the changed output of $this->getCache()->get($path) in https://github.com/nextcloud/server/blob/23b8e4a1d4e3d3f54d18f6c7f1be57baf8f75795/lib/private/Files/Storage/Wrapper/Encryption.php but I would prefer to first understand what causes empty an empty/null cache result. One can only end up in the code where the issue happens in case of reading an existing file. That should not be consistent with absent metadata.
@doc75 I opened a separate ticket #26544 for the issue you're reporting; it's something different.
@jknockaert my apologies, it appears that I took the wrong log.
Here is the log I have a lot on 20.0.9
{
"reqId": "goJnpbOy1wgPKnL9UHfF",
"level": 3,
"time": "2021-04-13T18:28:15+00:00",
"remoteAddr": "<removed>",
"user": "<removed>",
"app": "PHP",
"method": "PUT",
"url": "/remote.php/webdav/Nextcloud/Photos/2021/04/IMG_9453.JPG",
"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#439",
"Code": 0,
"Trace": [
{
"file": "/var/www/html/lib/private/Files/Storage/Wrapper/Encryption.php",
"line": 439,
"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",
439,
{
"path": "files/Nextcloud/Photos/2021/04/IMG_9453.JPG.ocTransferId1287283558.part",
"mode": "r",
"encryptionEnabled": true,
"shouldEncrypt": false,
"encryptionModule": null,
"0": "And 10 more entries, set log level to debug to see all entries"
}
]
},
{
"file": "/var/www/html/lib/private/Files/Storage/Wrapper/Wrapper.php",
"line": 300,
"function": "fopen",
"class": "OC\\Files\\Storage\\Wrapper\\Encryption",
"type": "->",
"args": [
"files/Nextcloud/Photos/2021/04/IMG_9453.JPG.ocTransferId1287283558.part",
"r"
]
},
{
"file": "/var/www/html/lib/private/Files/Storage/Wrapper/Encryption.php",
"line": 751,
"function": "fopen",
"class": "OC\\Files\\Storage\\Wrapper\\Wrapper",
"type": "->",
"args": [
"files/Nextcloud/Photos/2021/04/IMG_9453.JPG.ocTransferId1287283558.part",
"r"
]
},
{
"file": "/var/www/html/lib/private/Files/Storage/Wrapper/Encryption.php",
"line": 621,
"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"
},
"files/Nextcloud/Photos/2021/04/IMG_9453.JPG.ocTransferId1287283558.part",
"files/Nextcloud/Photos/2021/04/IMG_9453.JPG",
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"
},
"files/Nextcloud/Photos/2021/04/IMG_9453.JPG.ocTransferId1287283558.part",
"files/Nextcloud/Photos/2021/04/IMG_9453.JPG"
]
},
{
"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"
},
"files/Nextcloud/Photos/2021/04/IMG_9453.JPG.ocTransferId1287283558.part",
"files/Nextcloud/Photos/2021/04/IMG_9453.JPG"
]
},
{
"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/3rdparty/sabre/dav/lib/DAV/Server.php",
"line": 1104,
"function": "createFile",
"class": "OCA\\DAV\\Connector\\Sabre\\Directory",
"type": "->",
"args": [
"IMG_9453.JPG",
null
]
},
{
"file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/CorePlugin.php",
"line": 527,
"function": "createFile",
"class": "Sabre\\DAV\\Server",
"type": "->",
"args": [
"Nextcloud/Photos/2021/04/IMG_9453.JPG",
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": 474,
"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": 251,
"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": 319,
"function": "start",
"class": "Sabre\\DAV\\Server",
"type": "->",
"args": []
},
{
"file": "/var/www/html/apps/dav/appinfo/v1/webdav.php",
"line": 84,
"function": "exec",
"class": "Sabre\\DAV\\Server",
"type": "->",
"args": []
},
{
"file": "/var/www/html/remote.php",
"line": 167,
"args": [
"/var/www/html/apps/dav/appinfo/v1/webdav.php"
],
"function": "require_once"
}
],
"File": "/var/www/html/lib/private/Log/ErrorHandler.php",
"Line": 91,
"CustomMessage": "--"
},
"userAgent": "Mozilla/5.0 (iOS) Nextcloud-iOS/3.4.0",
"version": "20.0.9.1"
}
Hmm. Just drag-n-drop a file in the web interface generates this error in the log. Then when deleting the file the error is again there plus #26544. Also when deleting an error shows in the webinterface and the file is still present in the folder view. Only after a browser reload the deleted file is gone. This is something nasty.
@icewind1991 Could there be a relation with PR #25136?
Looking at the stack trace I noticed that this function is called: https://github.com/nextcloud/server/blob/f031dd61c14a093effeb5773323f578abd65d54f/apps/files_trashbin/lib/Storage.php#L231 This happens both upon upload when the partfile is moved and upon delete when the filed is moved to the thrashbin. That function is something that has been introduced in this commit: https://github.com/nextcloud/server/commit/b5db4502d02dda5becbe3e10b469c65fad969a7b @icewind1991 Can you have a look pls?
I still can't make much of this issue. Looking at the stack trace posted by @doc75 (https://github.com/nextcloud/server/issues/26473#issuecomment-818980800) I notice that sabredav somehow identifies OCA\Files_Trashbin\Storage as the appropriate partstorage class. That happens here:
https://github.com/nextcloud/server/blob/8ef920fdf90bc54d6f17134ebd80a71db2f9d8ea/apps/dav/lib/Connector/Sabre/File.php#L147
So in the example posted by @doc75 $this->path would have a value /Nextcloud/Photos/2021/04/IMG_9453.JPG (note: with a leading slash and without a storage prefix).
Looking further up in the stack the internal path of the partfile becomes files/Nextcloud/Photos/2021/04/IMG_9453.JPG.ocTransferId1287283558.part. That's not really in the trashbin. So I'm not sure why the OCA\Files_Trashbin\Storage is involved here at all.
@ChristophWurst Could you have a look into this behaviour of the Sabre connector?
I'm not familiar with the files aspect of DAV, sorry, I'm as clueless as you :/
So adding files results in an inter-storage copy (from partfile to file) rather than an intra-storage rename. The behaviour we're seeing here implies a write amplification with a factor of two (including all the file handling overhead such as encryption). That's pretty inefficient, perhaps we should fix this. @ChristophWurst who's familiar with this part of the code? Perhaps @juliushaertl, @icewind1991, @MorrisJobke or @rullzer? I'm not sure if this was already happening before 20.0.9/21.0.1, but if not, it may have been triggered by https://github.com/nextcloud/server/commit/b5db4502d02dda5becbe3e10b469c65fad969a7b.
@jknockaert it did not happened on my side before 20.0.9
@jknockaert it did not happened on my side before 20.0.9
No I mean the inter-storage copying upon upload. It may have happened already before but without resulting in a cache-related error.
I have the same issue
I am having the same issue; reproducible on a fresh installation of Nextcloud, directly after enabling the encryption app.
@schiessle @th3fallen Sorry for the direct reference, but I saw your names in the app description, and it seems there is a fundamental issue going on here with the encryption app. Who can take a look at this?

+1, same issue here!
https://github.com/nextcloud/server/pull/26980 might help with this one as well
#26980 might help with this one as well
I just edited that file manually and it seems to work. Thanks for your work and the reference! 👍
@juliushaertl I've suggested before that #25568 (corresponding commit is https://github.com/nextcloud/server/commit/b5db4502d02dda5becbe3e10b469c65fad969a7b) may have been causing this issue. So you're right that your fix may well help with this one as well.
#26980 might help with this one as well
I just edited that file manually and it seems to work. Thanks for your work and the reference! 👍
Just to give a hopefully last feedback: After 3 days still no errors. Had hundreds of log entrys before. Problem seems fixed to me with what @juliushaertl posted.
I can confirm #26980 fixes issue for me