PROPFIND causes Error: Call to a member function getCache() on null
Steps to reproduce
- Upgrade to Nextcloud 11.0.1
- Launch Files app
Expected behaviour
Directory of current user should be displayed.
Actual behaviour
Windows stays empty, error message displayed: This directory is unavailable, please check the logs or contact the administrator
Server configuration
Operating system: Ubutu 16.04
Web server: Apache
Database: MariaDB
PHP version: 7
Nextcloud version: 11.0.1
Updated from an older Nextcloud/ownCloud or fresh install: updated from 11
Where did you install Nextcloud from: updater app
Signing status:
Signing status
No errors have been found.
List of activated apps:
App list
$ sudo -u www-data php occ app:list
Enabled:
- activity: 2.4.1
- admin_audit: 1.1.0
- announcementcenter: 3.0.0
- calendar: 1.4.1
- comments: 1.1.0
- contacts: 1.5.2
- dav: 1.1.1
- federatedfilesharing: 1.1.1
- federation: 1.1.1
- files: 1.6.1
- files_accesscontrol: 1.1.2
- files_automatedtagging: 1.1.1
- files_external: 1.1.2
- files_markdown: 1.0.0
- files_sharing: 1.1.1
- files_texteditor: 2.2
- files_trashbin: 1.1.0
- files_versions: 1.4.0
- files_videoplayer: 1.0.0
- firstrunwizard: 2.0
- gallery: 16.0.0
- logreader: 2.0.0
- lookup_server_connector: 1.0.0
- nextcloud_announcements: 1.0
- notifications: 1.0.1
- password_policy: 1.1.0
- provisioning_api: 1.1.0
- serverinfo: 1.1.1
- sharebymail: 1.0.1
- survey_client: 0.1.5
- systemtags: 1.1.3
- templateeditor: 0.2
- theming: 1.1.1
- twofactor_backupcodes: 1.0.0
- updatenotification: 1.1.1
- user_external: 0.4
- workflowengine: 1.1.1
Disabled:
- direct_menu
- encryption
- external
- files_pdfviewer
- files_retention
- nextant
- spreed
- tasks
- user_ldap
- user_saml
The content of config/config.php:
Config report
# sudo -u www-data php occ config:list system
{
"system": {
"instanceid": "51e29b69eaed2",
"passwordsalt": "***REMOVED SENSITIVE VALUE***",
"datadirectory": "\/var\/nextcloud",
"dbtype": "mysql",
"version": "11.0.1.2",
"dbname": "nextcloud",
"dbhost": "localhost",
"dbtableprefix": "oc_",
"dbuser": "***REMOVED SENSITIVE VALUE***",
"dbpassword": "***REMOVED SENSITIVE VALUE***",
"installed": true,
"mail_smtpmode": "sendmail",
"forcessl": true,
"loglevel": 0,
"overwrite.cli.url": 1,
"theme": "",
"maintenance": false,
"trusted_domains": [
"***REMOVED SENSITIVE VALUE***"
],
"blacklisted_files": [],
"secret": "***REMOVED SENSITIVE VALUE***",
"enabledPreviewProviders": [
"OC\\Preview\\Image",
"OC\\Preview\\MP3",
"OC\\Preview\\TXT",
"OC\\Preview\\OpenDocument",
"OC\\Preview\\PDF",
"OC\\Preview\\SVG",
"OC\\Preview\\Movie",
"OC\\Preview\\MSOffice2003",
"OC\\Preview\\MSOffice2007",
"OC\\Preview\\MSOfficeDoc"
],
"memcache.local": "\\OC\\Memcache\\APCu",
"trashbin_retention_obligation": "auto",
"mail_from_address": "robobot",
"mail_domain": "***REMOVED SENSITIVE VALUE***",
"htaccess.RewriteBase": "\/",
"appstore.experimental.enabled": true,
"updater.release.channel": "stable",
"updater.secret": "***REMOVED SENSITIVE VALUE***"
}
}
Are you using external storage, if yes which one: sftp
Are you using encryption: no
Are you using an external user-backend, if yes which one: none
Client configuration
Browser: "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
Operating system:
Logs
Web server error log
Web server error log
``` [Mon Jan 16 07:35:03.753368 2017] [mpm_prefork:notice] [pid 29689] AH00163: Apache/2.4.18 (Ubuntu) OpenSSL/1.0.2g configured -- resuming normal operations [Mon Jan 16 07:35:03.753412 2017] [core:notice] [pid 29689] AH00094: Command line: '/usr/sbin/apache2' ```Nextcloud log (data/nextcloud.log)
Nextcloud log
Error: Call to a member function getCache() on null
/var/www/nextcloud/lib/private/Files/Cache/Wrapper/CacheJail.php - line 296: OCA\Files_Sharing\Cache->getCache()
/var/www/nextcloud/lib/private/Files/View.php - line 1687: OC\Files\Cache\Wrapper\CacheJail->getPathById(212215)
/var/www/nextcloud/apps/files_sharing/lib/SharedStorage.php - line 117: OC\Files\View->getPath(212215)
/var/www/nextcloud/apps/files_sharing/lib/SharedStorage.php - line 449: OCA\Files_Sharing\SharedStorage->init()
[internal function] OCA\Files_Sharing\SharedStorage->getSourceStorage()
/var/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php - line 501: call_user_func_array(Array, Array)
/var/www/nextcloud/apps/files_sharing/lib/Cache.php - line 69: OC\Files\Storage\Wrapper\Wrapper->__call('getSourceStorag...', Array)
/var/www/nextcloud/lib/private/Files/Cache/Wrapper/CacheJail.php - line 296: OCA\Files_Sharing\Cache->getCache()
/var/www/nextcloud/lib/private/Files/View.php - line 1687: OC\Files\Cache\Wrapper\CacheJail->getPathById(210445)
/var/www/nextcloud/apps/files_sharing/lib/SharedStorage.php - line 117: OC\Files\View->getPath(210445)
/var/www/nextcloud/apps/files_sharing/lib/SharedStorage.php - line 449: OCA\Files_Sharing\SharedStorage->init()
[internal function] OCA\Files_Sharing\SharedStorage->getSourceStorage()
/var/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php - line 501: call_user_func_array(Array, Array)
/var/www/nextcloud/apps/files_sharing/lib/Cache.php - line 69: OC\Files\Storage\Wrapper\Wrapper->__call('getSourceStorag...', Array)
/var/www/nextcloud/lib/private/Files/Cache/Wrapper/CacheJail.php - line 296: OCA\Files_Sharing\Cache->getCache()
/var/www/nextcloud/lib/private/Files/View.php - line 1687: OC\Files\Cache\Wrapper\CacheJail->getPathById(206443)
/var/www/nextcloud/apps/files_sharing/lib/SharedStorage.php - line 117: OC\Files\View->getPath(206443)
/var/www/nextcloud/apps/files_sharing/lib/SharedStorage.php - line 454: OCA\Files_Sharing\SharedStorage->init()
/var/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php - line 490: OCA\Files_Sharing\SharedStorage->getWrapperStorage()
/var/www/nextcloud/apps/files_sharing/lib/SharedStorage.php - line 143: OC\Files\Storage\Wrapper\Wrapper->instanceOfStorage('\\OCP\\Files\\IHom...')
/var/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php - line 490: OCA\Files_Sharing\SharedStorage->instanceOfStorage('\\OCP\\Files\\IHom...')
/var/www/nextcloud/lib/private/Files/FileInfo.php - line 310: OC\Files\Storage\Wrapper\Wrapper->instanceOfStorage('\\OCP\\Files\\IHom...')
/var/www/nextcloud/apps/dav/lib/Connector/Sabre/Node.php - line 297: OC\Files\FileInfo->isMounted()
/var/www/nextcloud/apps/dav/lib/Connector/Sabre/FilesPlugin.php - line 300: OCA\DAV\Connector\Sabre\Node->getDavPermissions()
/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/PropFind.php - line 98: OCA\DAV\Connector\Sabre\FilesPlugin->OCA\DAV\Connector\Sabre\{closure}()
/var/www/nextcloud/apps/dav/lib/Connector/Sabre/FilesPlugin.php - line 306: Sabre\DAV\PropFind->handle('{http //ownclou...', Object(Closure))
[internal function] OCA\DAV\Connector\Sabre\FilesPlugin->handleGetProperties(Object(Sabre\DAV\PropFind), Object(OCA\DAV\Connector\Sabre\Directory))
/var/www/nextcloud/3rdparty/sabre/event/lib/EventEmitterTrait.php - line 105: call_user_func_array(Array, Array)
/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 1035: Sabre\Event\EventEmitter->emit('propFind', Array)
/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 955: Sabre\DAV\Server->getPropertiesByNode(Object(Sabre\DAV\PropFind), Object(OCA\DAV\Connector\Sabre\Directory))
/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php - line 336: Sabre\DAV\Server->getPropertiesForPath('', Array, 1)
[internal function] Sabre\DAV\CorePlugin->httpPropFind(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response))
/var/www/nextcloud/3rdparty/sabre/event/lib/EventEmitterTrait.php - line 105: call_user_func_array(Array, Array)
/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 479: Sabre\Event\EventEmitter->emit('method PROPFIND', Array)
/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 254: Sabre\DAV\Server->invokeMethod(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response))
/var/www/nextcloud/apps/dav/appinfo/v1/webdav.php - line 60: Sabre\DAV\Server->exec()
/var/www/nextcloud/remote.php - line 165: require_once('/var/www/nextcl...')
{main}
Browser log
Browser log
Network log:
PROPFIND https://nc.1x-upon.com/remote.php/webdav/
Host: example.com
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,de-DE;q=0.8,de;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate, br
X-Requested-With: XMLHttpRequest
requesttoken: cYAQjhVL3gKQwIPoB9A1dM4UH1Ojgny8l19l4MBfVD8=:NfRh+1sdiXq79c+hSJlGMZR4fmSX7xrsuBdQppQ3A3s=
Depth: 1
Content-Type: application/xml; charset=utf-8
Content-Length: 471
Cookie: nc_sameSiteCookielax=true; nc_sameSiteCookiestrict=true; __Host-nc_sameSiteCookielax=true; __Host-nc_sameSiteCookiestrict=true; 51e29b69eaed2=m13ri3k8qvqvgrlpiv7qodhb14; oc_sessionPassphrase=aHorr1KOOHsTOzov04feNmCqv0Rb4rzXLwXrlHMzrPqgewX8IZPKmS2v6F8bohthLc0in55qqYbRm2mBtmQQX9qG9AAM3vP%2B%2FMMVjqjAoLeqI9CVOtde%2B4bkYvsabCfh
Connection: keep-alive
Cache-Control: max-age=0
Response:
Status Code: 500 internal server error
Cache-Control: no-store, no-cache, must-revalidate
Connection: close
Content-Type: text/html; charset=UTF-8
Date: Mon, 16 Jan 2017 19:51:17 GMT
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Pragma: no-cache
Server: Apache/2.4.18 (Ubuntu)
Transfer-Encoding: chunked
X-Content-Type-Options: nosniff
X-Download-Options: noopen
X-Frame-Options: Sameorigin
X-Permitted-Cross-Domain-Policies: none
X-Robots-Tag: none
X-XSS-Protection: 1; mode=block
content-security-policy: default-src 'none';
@icewind1991 please have a look. Null is actually injected, but in theory the value should never be used: https://github.com/nextcloud/server/blob/6c11c54434b29bb9f7f07ba9a8070ed8308bc5a4/apps/files_sharing/lib/Cache.php#L62-L62
Had just upgraded to 11.0.1 and found some users getting the same error. When running occ files:scan UID I get the Error: Call to a member function getCache() on null error as mentioned above. Update was done via same methods mentioned above. Only difference is OS is RHEL6 and Web server is NGINX.
Any hint what is the problem here? I encountered the same problem after upgrading to version 11.0.1.
Something with the file cache or user's files. We've rolled back our installation now.
Something you could try and clear the file cache table in the database and run a full file scan. Take a backup first!!!
We rolled back our installation, too.
I have encountered a problem with legacy storages as discussed here. I had to fix the problem manually. Maybe the legacy storages cause this error?
Thanks for the link to that discussion. Indeed, in my oc_storage table, there are several types of storage. The first users' storage seems to start with local::/some/path, and that path is not correct anymore.
Would it help if I manually changed these entries to home::$username? Or is this not something to be tampered with?
@despens I resolved the issue for my installation! 😄
Here is what I have done:
- Create storage entries in
oc_storagesifhome::$usernamedoes not already exist - Fix the referenced fileids
item_source,item_targetandfile_sourcein theoc_sharetable. In my installation I had tons of duplicates because the same files where referenced by a legacylocal::...storage as well as by ahome::$usernamestorage. I replaced the fileids in theoc_sharetable with the fileids of the entries using thehome::$usernamestorage. - Adjust the
objidreferences in theoc_vcategory_to_objecttable - Remove legacy storages from
oc_storages - Remove the legacy entries in
oc_filecachewhere a legacy storage is referenced - Finally: Upgrade from nextcloud 10 to nextcloud 11
I think this is more a quick'N'dirty solution but it worked for me.
Btw: nextcloud's database layout would benefit from some foreign keys ;)
Thanks a ton, I will try this!
Indeed this is missing from my bug-report: I did move the main storage directory to another place. Since this is a config file option, I had no idea there would be any absolute paths in the database and didn't think it was worth mentioning.
It would be great if there was a tool in nextcloud that would take care of moving legacy storage locations to the updated format.
@despens I did exactly the same thing - moved the main storage directory. The problem is already known. There is a migration step for this issue in owncloud. You can see it in the oc_appconfig table - there exists a repairlegacystoragesdone key. This migration step should be executed during update to ownCloud 8.
I removed the repairlegacystoragesdone key from the table and re-run occ maintenance:repair but it told me that some legacy storages could not be migrated automatically #never-lucky :face_with_head_bandage:
After that, I repaired my installation manually.
Maybe you can just fix the local::/path/to/your/new/data/directory in the oc_storages table instead of messing with the fileids?
@icewind1991 please have a look.
My table oc_storage contains legacy (local::) and new (home::) definitions. oc_filecache is using both of them intermixed. When I try to replace the legacy storage id with the new one, this happens:
MariaDB [nextcloud]> update oc_filecache set storage=11 where storage = 1;
ERROR 1062 (23000): Duplicate entry '11-d41d8cd98f00b204e9800998ecf8427e' for key 'fs_storage_path_hash'
So I wonder if there is a way to start again and have nextcloud scan the users' directories without any assumptions being made? This is quite frustrating. :disappointed:
@despens You cannot simply replace the storage id because this would yield duplicates (as mentioned in the error message). You can try my proposed procedure. You have to fix the oc_share and oc_vcategory_to_object tables and later remove the legacy storages from oc_storages.
Hey @f3anaro, I have difficulties following your procedure. I would have to translate storage ids like this:
1 → 11
3 → 12
5 → 46
4 → 13
However, in oc_share these numbers do not appear, instead there are much higher id numbers and I am not sure what they are referencing. Example:
MariaDB [nextcloud]> select item_source, item_target, file_source from oc_share limit 10;
+-------------+-------------+-------------+
| item_source | item_target | file_source |
+-------------+-------------+-------------+
| 181969 | /181969 | 181969 |
| 206443 | /206443 | 206443 |
| 207146 | /207146 | 207146 |
| 207161 | /207161 | 207161 |
| 207158 | /207158 | 207158 |
| 207149 | /207149 | 207149 |
| 207141 | /207141 | 207141 |
| 207155 | /207155 | 207155 |
| 207138 | /207138 | 207138 |
| 207152 | /207152 | 207152 |
+-------------+-------------+-------------+
I would be grateful for any further help. Are you on the nextcloud IRC channel?
@despens Sry, I am from Germany - so we have a little bit shifted schedules ^^
You have to find the corresponding fileids in oc_filecache that are using the home::$username path
SELECT oc_share.id AS share_id,
old_cache.fileid AS old_fileid,
new_cache.fileid AS new_fileid,
old_cache.path
FROM oc_share
INNER JOIN oc_filecache AS old_cache ON oc_share.file_source = old_cache.fileid
-- Find the fileid of the cache entries with the 'home::$username' storage
INNER JOIN oc_filecache AS new_cache ON old_cache.path = new_cache.path
INNER JOIN oc_storages ON
new_cache.storage = oc_storages.numeric_id
AND oc_storages.id LIKE 'home::%'
-- select only legacy storages
WHERE old_cache.storage IN (
SELECT numeric_id FROM oc_storages WHERE id LIKE 'local::%'
)
Maybe you have to create the new home::$username storages first, then run a occ files:scan --all to create the duplicates in the oc_filecache for the newly created storages.
You can update the oc_share table by nesting the above SQL query (at least, this works in PostgreSQL). Please double check the output of the above query.
UPDATE oc_share
SET file_source = subquery.new_fileid,
item_source = subquery.new_fileid,
-- Attention!
-- This takes not into account if item_target was previously NULL.
-- You have to construct an IF-like statement for that.
-- In my case, I overwrote all previous values with the concatentation
item_target = CONCAT('/', subquery.new_fileid)
FROM (
SELECT oc_share.id AS share_id,
old_cache.fileid AS old_fileid,
new_cache.fileid AS new_fileid,
old_cache.path
FROM oc_share
INNER JOIN oc_filecache AS old_cache ON oc_share.file_source = old_cache.fileid
-- Find the fileid of the cache entries with the 'home::$username' storage
INNER JOIN oc_filecache AS new_cache ON old_cache.path = new_cache.path
INNER JOIN oc_storages ON
new_cache.storage = oc_storages.numeric_id
AND oc_storages.id LIKE 'home::%'
-- select only legacy storages
WHERE old_cache.storage IN (
SELECT numeric_id FROM oc_storages WHERE id LIKE 'local::%'
)
) AS subquery
WHERE id = subquery.share_id
You can do a similar thing with the oc_vcategory_to_object table.
Thanks @f3anaro — now I know how to proceed! Unfortunately I didn't chose to install Postgres but used the "default" MariaDB, which is not able to execute this sub-query. But luckily the amount of affected files seems small.
@f3anaro thank you for query. My nextcloud 11.0.1 has some problem
I test the SELECT before run update. It return 0 rows. :(
oc_storages.id LIKE 'home::%'
&&
WHERE old_cache.storage IN (
SELECT numeric_id FROM oc_storages WHERE id LIKE 'local::%'
)
are mutually exclusive.
I can not understand how to proceed
@marcochiodo The two conditions do not exclude each other because we are doing a double INNER JOIN with the oc_filecache table -- see new_cache and old_cache.
old_cache -> 'local::%'new_cache -> 'home::%'
Have you checked if your oc_storages table does contain any legacy storage?
Maybe you have to create the home::$username storages first to create the duplicates in the oc_filecache table (see comment above).
You are right ;)
I'm watching for oc_storages. Table contain either, legacy and home::% storages.
This is content of oc_storages
"id" "numeric_id" "available" "last_checked" "home::marco" "1" "1" "\N" "local::/var/www/owncloud-solver/data/" "2" "1" "\N" "local::/srv/ssd1/owncloud-solver-data/default/" "3" "1" "\N" "home::riccardo" "4" "1" "\N" "home::andrea" "5" "1" "\N" "home::matteo" "6" "1" "\N" "shared::/Project1" "7" "1" "\N" "shared::/Project2" "8" "1" "\N" "shared::/Project3" "9" "1" "\N" "shared::/Project4" "10" "1" "\N" "shared::/Project5" "11" "1" "\N" "shared::/Project6" "12" "1" "\N" "local::/srv/hd/owncloud-data/default/" "13" "1" "\N" "home::mauro" "14" "1" "\N" "shared::/3.Graphic" "15" "1" "\N" "local::/srv/hd/owncloud-solver/manual/" "16" "0" "1468573136" "shared::/Project7" "18" "1" "\N" "shared::/Project7" "19" "1" "\N" "1" "21" "1" "\N" "4" "22" "1" "\N" "swift::KCc...." "23" "1" "1487110533" "home::simone" "20" "1" "\N"
I am rather uncomfortable writing this, and perhaps this is the wrong place, but: I seem to have the very same problem, have had issues with a moved data directory in the past but somehow, after a lot of semi-knowledgeable hacking got Owncloud to upgrade from 7 to 8 to 9, and now have that problem after migrating this installation (as a test clone) to Nextcloud and updating to version 11. I may have read everything concering that problem BUT I fail to finally get my head around it.
I guess it would not be possible to produce a step-by-step documentation regarding this seemingly not-so-rare and very annoying issue?
@4001982248998 I do not think a step-by-step guide is advisable here because - as I mentioned above - my work around is a dirty hack in underlying database.
Another thing you could try: Replace all legacy storage entries containing the old filesystem path with the appropriate new filesystem path.
You can get all legacy storages with:
SELECT id FROM oc_storages WHERE id LIKE 'local::%';