Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PROPFIND causes Error: Call to a member function getCache() on null #3110

Closed
despens opened this issue Jan 16, 2017 · 36 comments · Fixed by #5091
Closed

PROPFIND causes Error: Call to a member function getCache() on null #3110

despens opened this issue Jan 16, 2017 · 36 comments · Fixed by #5091

Comments

@despens
Copy link

despens commented Jan 16, 2017

Steps to reproduce

  1. Upgrade to Nextcloud 11.0.1
  2. 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';


@despens despens changed the title Error: Call to a member function getCache() on null PROPFIND causes Error: Call to a member function getCache() on null Jan 16, 2017
@nickvergessen
Copy link
Member

@icewind1991 please have a look.
Null is actually injected, but in theory the value should never be used:

@RodneyRussell
Copy link

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.

@kahlertl
Copy link

kahlertl commented Feb 4, 2017

Any hint what is the problem here? I encountered the same problem after upgrading to version 11.0.1.

@RodneyRussell
Copy link

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!!!

@kahlertl
Copy link

kahlertl commented Feb 5, 2017

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?

@despens
Copy link
Author

despens commented Feb 5, 2017

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?

@kahlertl
Copy link

kahlertl commented Feb 6, 2017

@despens I resolved the issue for my installation! 😄

Here is what I have done:

  • Create storage entries in oc_storages if home::$username does not already exist
  • Fix the referenced fileids item_source, item_target and file_source in the oc_share table. In my installation I had tons of duplicates because the same files where referenced by a legacy local::... storage as well as by a home::$username storage. I replaced the fileids in the oc_share table with the fileids of the entries using the home::$username storage.
  • Adjust the objid references in the oc_vcategory_to_object table
  • Remove legacy storages from oc_storages
  • Remove the legacy entries in oc_filecache where 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 ;)

@despens
Copy link
Author

despens commented Feb 6, 2017

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.

@kahlertl
Copy link

kahlertl commented Feb 6, 2017

@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 🤕

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?

@nickvergessen
Copy link
Member

@icewind1991 please have a look.

@despens
Copy link
Author

despens commented Feb 12, 2017

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. 😞

@kahlertl
Copy link

@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.

@despens
Copy link
Author

despens commented Feb 13, 2017

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?

@kahlertl
Copy link

@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.

@despens
Copy link
Author

despens commented Feb 14, 2017

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.

@marcochiodo
Copy link

@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

@kahlertl
Copy link

kahlertl commented Feb 15, 2017

@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).

@marcochiodo
Copy link

marcochiodo commented Feb 16, 2017

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"

@4001982248998
Copy link

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?

@kahlertl
Copy link

@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::%';

@4001982248998
Copy link

dirty or beautifully, I don't really care, as long as it works…
this is what I tried and how it failed:

MariaDB [nextcloud]> select * from oc_storages where id like "local::%";
+-----------------------------------------+------------+-----------+--------------+
| id                                      | numeric_id | available | last_checked |
+-----------------------------------------+------------+-----------+--------------+
| local::/srv/data/                       |       1501 |         1 |         NULL |
| local::/var/vhost/oc5/public/data/      |          4 |         1 |         NULL |
| local::/var/vhost/oc5/public/data/root/ |          1 |         1 |         NULL |
| local::/var/www/vhost/oc5/public/data/  |         11 |         1 |         NULL |
+-----------------------------------------+------------+-----------+--------------+
4 rows in set (0.00 sec)

MariaDB [nextcloud]> update oc_storages set id="home::" where id="local::/srv/data/";
ERROR 1062 (23000): Duplicate entry 'home::' for key 'storages_id_index'

I also tried simply deleting them (this is a snapshotted test system), but this also does not help overcome the files-scan:

MariaDB [nextcloud]> delete FROM oc_storages WHERE id LIKE 'local::%';
Query OK, 4 rows affected (0.00 sec)
$ occ files:scan --all

Scanning files for 719 users
Starting scan for user 1 out of 719 (008cb8c8-d538-102f-8304-7508311fc1d9)
Starting scan for user 2 out of 719 (00D16B67-1ACD-4F5C-9FFA-CB0C0A0FAF6E)
Starting scan for user 3 out of 719 (016435FF-9F53-4154-8DDF-455688BA53C4)
Starting scan for user 4 out of 719 (018DB8D4-8154-4D72-AA7B-7E161320835C)
Starting scan for user 5 out of 719 (022ED596-7A9D-4C62-924F-AE51BC1A5346)
Starting scan for user 6 out of 719 (023D037B-4564-4CD9-BA66-7C7B6428FB13)
An unhandled exception has been thrown:
Error: Call to a member function getCache() on null in /var/www/nextcloud/apps/files_sharing/lib/Cache.php:69
Stack trace:
#0 /var/www/nextcloud/lib/private/Files/Cache/Wrapper/CacheJail.php(296): OCA\Files_Sharing\Cache->getCache()
#1 /var/www/nextcloud/lib/private/Files/View.php(1687): OC\Files\Cache\Wrapper\CacheJail->getPathById(3925)
#2 /var/www/nextcloud/apps/files_sharing/lib/SharedStorage.php(117): OC\Files\View->getPath(3925)
#3 /var/www/nextcloud/apps/files_sharing/lib/SharedStorage.php(454): OCA\Files_Sharing\SharedStorage->init()
#4 /var/www/nextcloud/lib/private/Files/Storage/Wrapper/Jail.php(463): OCA\Files_Sharing\SharedStorage->getWrapperStorage()
#5 /var/www/nextcloud/apps/files_sharing/lib/SharedStorage.php(394): OC\Files\Storage\Wrapper\Jail->resolvePath('scanner::')
#6 /var/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php(588): OCA\Files_Sharing\SharedStorage->acquireLock('scanner::', 2, Object(OC\Lock\MemcacheLockingProvider))
#7 /var/www/nextcloud/lib/private/Files/Cache/Scanner.php(316): OC\Files\Storage\Wrapper\Wrapper->acquireLock('scanner::', 2, Object(OC\Lock\MemcacheLockingProvider))
#8 /var/www/nextcloud/lib/private/Files/Utils/Scanner.php(196): OC\Files\Cache\Scanner->scan('', true, 3)
#9 /var/www/nextcloud/apps/files/lib/Command/Scan.php(159): OC\Files\Utils\Scanner->scan('/023D037B-4564-...')
#10 /var/www/nextcloud/apps/files/lib/Command/Scan.php(227): OCA\Files\Command\Scan->scanFiles('023D037B-4564-4...', '/023D037B-4564-...', false, Object(Symfony\Component\Console\Output\ConsoleOutput), false)
#11 /var/www/nextcloud/3rdparty/symfony/console/Command/Command.php(256): OCA\Files\Command\Scan->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 /var/www/nextcloud/core/Command/Base.php(161): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /var/www/nextcloud/3rdparty/symfony/console/Application.php(818): OC\Core\Command\Base->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /var/www/nextcloud/3rdparty/symfony/console/Application.php(186): Symfony\Component\Console\Application->doRunCommand(Object(OCA\Files\Command\Scan), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /var/www/nextcloud/3rdparty/symfony/console/Application.php(117): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /var/www/nextcloud/lib/private/Console/Application.php(169): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 /var/www/nextcloud/console.php(90): OC\Console\Application->run()
#18 /var/www/nextcloud/occ(11): require_once('/var/www/nextcl...')
#19 {main}

@kahlertl
Copy link

  1. You cannot simply set the storage id to home:: - this is an invalid storage ID. It must be formated like home::$username. Besides I meant to replace the invalid legacy storage with a correct legacy storage (as I stated here):

    local::/invalid/data/path -> local::/path/to/new/data
    
  2. Your DELTE FROM oc_storages WHERE id LIKE 'local::%'; does not clear the oc_filecache table as nextclouds database lacks foreign key constraints. You have to do this manually. Be adviced: this procedure nukes all shares regarding files in this storages.

@4001982248998
Copy link

I am too dense for this.

MariaDB [nextcloud]> update oc_storages set id="local::/srv/data/" where id="local::/var/vhost/oc5/public/data/";
ERROR 1062 (23000): Duplicate entry 'local::/srv/data/' for key 'storages_id_index'

@nickvergessen
Copy link
Member

Well you could try to check which entries in oc_filecache are related to that storage.
If there are none, you can also simply delete that storage.

@icewind1991
Copy link
Member

I believe this has been fixed with f2e981e

@4001982248998
Copy link

This patch is indeed looking very good, because now the scan does not cancel the process. Now it continues until all user's files have been scanned. Thumbs up!

@4001982248998
Copy link

After upgrading to 11.0.3, I had to re-apply the patch.

@idmacdonald
Copy link

Hi,
I have come across this issue as well. I recently upgraded an install to NextCloud 11. It seems to work fine, except certain users get an error message when trying to access the root level of their files via the web interface: 'This directory is unavailable, please check the logs or contact the administrator'.

In the log files, I see this error: "Call to a member function getCache() on null at /var/www/web07/web/apps/files_sharing/lib/Cache.php#69"

This particular install has been around a long time, since OwnCloud v 3 or something. It was moved onto our servers and into our control a couple of years ago. I know we've had problems with the 'local::' storage entries in the past. It looks like it's the user accounts that have been around for the longest who are experiencing this problem, so it is likely related to the storage ids in the database.

I have tried applying f2e981e as recommeded above, but that doesn't appear to have solved the problem for me.

The same getCache() error comes up when I run something like 'occ files:scan username' for one of the user accounts in question. Here's the stack trace:
PHP 1. {main}() /var/www/web07/web/occ:0
PHP 2. require_once() /var/www/web07/web/occ:11
PHP 3. OC\Console\Application->run() /var/www/web07/web/console.php:90
PHP 4. Symfony\Component\Console\Application->run() /var/www/web07/web/lib/private/Console/Application.php:169
PHP 5. Symfony\Component\Console\Application->doRun() /var/www/web07/web/3rdparty/symfony/console/Application.php:117
PHP 6. Symfony\Component\Console\Application->doRunCommand() /var/www/web07/web/3rdparty/symfony/console/Application.php:186
PHP 7. OC\Core\Command\Base->run() /var/www/web07/web/3rdparty/symfony/console/Application.php:818
PHP 8. Symfony\Component\Console\Command\Command->run() /var/www/web07/web/core/Command/Base.php:161
PHP 9. OCA\Files\Command\Scan->execute() /var/www/web07/web/3rdparty/symfony/console/Command/Command.php:256
PHP 10. OCA\Files\Command\Scan->scanFiles() /var/www/web07/web/apps/files/lib/Command/Scan.php:227
PHP 11. OC\Files\Utils\Scanner->scan() /var/www/web07/web/apps/files/lib/Command/Scan.php:159
PHP 12. OC\Files\Cache\Scanner->scan() /var/www/web07/web/lib/private/Files/Utils/Scanner.php:196
PHP 13. OC\Files\Storage\Wrapper\Wrapper->acquireLock() /var/www/web07/web/lib/private/Files/Cache/Scanner.php:316
PHP 14. OCA\Files_Sharing\SharedStorage->acquireLock() /var/www/web07/web/lib/private/Files/Storage/Wrapper/Wrapper.php:588
PHP 15. OC\Files\Storage\Wrapper\Jail->resolvePath() /var/www/web07/web/apps/files_sharing/lib/SharedStorage.php:398
PHP 16. OCA\Files_Sharing\SharedStorage->getWrapperStorage() /var/www/web07/web/lib/private/Files/Storage/Wrapper/Jail.php:463
PHP 17. OCA\Files_Sharing\SharedStorage->init() /var/www/web07/web/apps/files_sharing/lib/SharedStorage.php:458
PHP 18. OC\Files\View->getPath() /var/www/web07/web/apps/files_sharing/lib/SharedStorage.php:118
PHP 19. OC\Files\Cache\Wrapper\CacheJail->getPathById() /var/www/web07/web/lib/private/Files/View.php:1687
PHP 20. OCA\Files_Sharing\Cache->getCache() /var/www/web07/web/lib/private/Files/Cache/Wrapper/CacheJail.php:296
PHP 21. OCA\Files_Trashbin\Storage->getSourceStorage() /var/www/web07/web/apps/files_sharing/lib/Cache.php:69
PHP 22. OC\Files\Storage\Wrapper\Wrapper->__call() /var/www/web07/web/apps/files_sharing/lib/Cache.php:69
PHP 23. call_user_func_array:{/var/www/web07/web/lib/private/Files/Storage/Wrapper/Wrapper.php:501}() /var/www/web07/web/lib/private/Files/Storage/Wrapper/Wrapper.php:501
PHP 24. OCA\Files_Sharing\SharedStorage->getSourceStorage() /var/www/web07/web/lib/private/Files/Storage/Wrapper/Wrapper.php:501
PHP 25. OCA\Files_Sharing\SharedStorage->init() /var/www/web07/web/apps/files_sharing/lib/SharedStorage.php:453
PHP 26. OC\Files\View->getPath() /var/www/web07/web/apps/files_sharing/lib/SharedStorage.php:118
PHP 27. OC\Files\Cache\Wrapper\CacheJail->getPathById() /var/www/web07/web/lib/private/Files/View.php:1687
PHP 28. OCA\Files_Sharing\Cache->getCache() /var/www/web07/web/lib/private/Files/Cache/Wrapper/CacheJail.php:296
PHP 29. OCA\Files_Trashbin\Storage->getSourceStorage() /var/www/web07/web/apps/files_sharing/lib/Cache.php:69
PHP 30. OC\Files\Storage\Wrapper\Wrapper->__call() /var/www/web07/web/apps/files_sharing/lib/Cache.php:69
PHP 31. call_user_func_array:{/var/www/web07/web/lib/private/Files/Storage/Wrapper/Wrapper.php:501}() /var/www/web07/web/lib/private/Files/Storage/Wrapper/Wrapper.php:501
PHP 32. OCA\Files_Sharing\SharedStorage->getSourceStorage() /var/www/web07/web/lib/private/Files/Storage/Wrapper/Wrapper.php:501
PHP 33. OCA\Files_Sharing\SharedStorage->init() /var/www/web07/web/apps/files_sharing/lib/SharedStorage.php:453
PHP 34. OC\Files\View->getPath() /var/www/web07/web/apps/files_sharing/lib/SharedStorage.php:118
PHP 35. OC\Files\Cache\Wrapper\CacheJail->getPathById() /var/www/web07/web/lib/private/Files/View.php:1687
PHP 36. OCA\Files_Sharing\Cache->getCache() /var/www/web07/web/lib/private/Files/Cache/Wrapper/CacheJail.php:296

I was able to use a stack trace in order to get the file ID apparently causing the problem. That file belongs to a storage id of 'home::karen'. It doesn't seem to have anything to do with any of the 'local::' entries in the oc_storages table. In fact, there is only one 'local::' entry left in the oc_storages table now, which points to the install's data directory ('local::/var/www/web07/web/data/'). However, there are various oc_storages IDs with hex values.

Anyone have any suggestions? It would be great if I could get this sorted out. I'm willing to try and follow the stack trace to figure out why this particular file is causing the problem. But first I thought I'd check and see if there are any other suggested fixes.

Many thanks,
-Ian

@znerol
Copy link

znerol commented May 23, 2017

php occ status
  - installed: true
  - version: 12.0.0.29
  - versionstring: 12.0.0
  - edition: 

Similar stacktrace here. In my case the following command helped:

php occ files:cleanup
5000 orphaned file cache entries deleted

I got to that solution after running files:scan in very-verbose mode with xdebug.collect_params = On

php occ -vvvvvvvvvvv files:scan myuser

Starting scan for user 1 out of 1 (myuser)
	Folder /myuser/
	[...]
	Folder /myuser/cache
PHP Fatal error:  Call to a member function getCache() on null in /var/www/nextcloud/apps/files_sharing/lib/Cache.php on line 71
PHP Stack trace:
PHP   1. {main}() /var/www/nextcloud/occ:0
PHP   2. require_once() /var/www/nextcloud/occ:11
PHP   3. OC\Console\Application->run($input = *uninitialized*, $output = *uninitialized*) /var/www/nextcloud/console.php:92
PHP   4. Symfony\Component\Console\Application->run($input = NULL, $output = NULL) /var/www/nextcloud/lib/private/Console/Application.php:170
PHP   5. Symfony\Component\Console\Application->doRun($input = class Symfony\Component\Console\Input\ArgvInput { private $tokens = array (0 => '-vvvvvvvvvvv', 1 => 'files:scan', 2 => 'myuser'); private $parsed = array (); protected $definition = class Symfony\Component\Console\Input\InputDefinition { private $arguments = array (...); private $requiredCount = 1; private $hasAnArrayArgument = TRUE; private $hasOptional = TRUE; private $options = array (...); private $shortcuts = array (...) }; protected $options = array ('verbose' => TRUE); protected $arguments = array ('command' => 'files:scan', 'user_id' => array (...)); protected $interactive = TRUE }, $output = class Symfony\Component\Console\Output\ConsoleOutput { private $stderr = class Symfony\Component\Console\Output\StreamOutput { private $stream = resource(636) of type (stream); private ${Symfony\Component\Console\Output\Output}:verbosity = 32; private ${Symfony\Component\Console\Output\Output}:formatter = class Symfony\Component\Console\Formatter\OutputFormatter { ... } }; private ${Symfony\Component\Console\Output\StreamOutput}:stream = resource(635) of type (stream); private ${Symfony\Component\Console\Output\Output}:verbosity = 32; private ${Symfony\Component\Console\Output\Output}:formatter = class Symfony\Component\Console\Formatter\OutputFormatter { private $decorated = TRUE; private $styles = array (...); private $styleStack = class Symfony\Component\Console\Formatter\OutputFormatterStyleStack { ... } } }) /var/www/nextcloud/3rdparty/symfony/console/Application.php:117
PHP   6. Symfony\Component\Console\Application->doRunCommand($command = class OCA\Files\Command\Scan { private $userManager = class OC\User\Manager { private $backends = array (...); private $cachedUsers = array (...); private $config = class OC\AllConfig { ... }; protected $listeners = array (...) }; protected $execTime = -1495556155.6777; protected $foldersCounter = 17; protected $filesCounter = 176; protected $defaultOutputFormat = 'plain'; private ${OC\Core\Command\Base}:php_pcntl_signal = TRUE; private ${OC\Core\Command\Base}:interrupted = FALSE; private ${Symfony\Component\Console\Command\Command}:application = class Symfony\Component\Console\Application { private $commands = array (...); private $wantHelps = FALSE; private $runningCommand = ...; private $name = 'Nextcloud'; private $version = '12.0.0'; private $catchExceptions = TRUE; private $autoExit = TRUE; private $definition = class Symfony\Component\Console\Input\InputDefinition { ... }; private $helperSet = class Symfony\Component\Console\Helper\HelperSet { ... }; private $dispatcher = NULL; private $terminalDimensions = NULL; private $defaultCommand = 'list' }; private ${Symfony\Component\Console\Command\Command}:name = 'files:scan'; private ${Symfony\Component\Console\Command\Command}:processTitle = NULL; private ${Symfony\Component\Console\Command\Command}:aliases = array (); private ${Symfony\Component\Console\Command\Command}:definition = class Symfony\Component\Console\Input\InputDefinition { private $arguments = array (...); private $requiredCount = 1; private $hasAnArrayArgument = TRUE; private $hasOptional = TRUE; private $options = array (...); private $shortcuts = array (...) }; private ${Symfony\Component\Console\Command\Command}:help = NULL; private ${Symfony\Component\Console\Command\Command}:description = 'rescan filesystem'; private ${Symfony\Component\Console\Command\Command}:ignoreValidationErrors = FALSE; private ${Symfony\Component\Console\Command\Command}:applicationDefinitionMerged = TRUE; private ${Symfony\Component\Console\Command\Command}:applicationDefinitionMergedWithArgs = TRUE; private ${Symfony\Component\Console\Command\Command}:code = NULL; private ${Symfony\Component\Console\Command\Command}:synopsis = array ('short' => 'files:scan [options] [--] [<user_id>]...', 'long' => 'files:scan [--output [OUTPUT]] [-p|--path PATH] [-q|--quiet] [-v|vv|vvv|--verbose] [--all] [--unscanned] [--] [<user_id>]...'); private ${Symfony\Component\Console\Command\Command}:usages = array (); private ${Symfony\Component\Console\Command\Command}:helperSet = class Symfony\Component\Console\Helper\HelperSet { private $helpers = array (...); private $command = NULL } }, $input = class Symfony\Component\Console\Input\ArgvInput { private $tokens = array (0 => '-vvvvvvvvvvv', 1 => 'files:scan', 2 => 'myuser'); private $parsed = array (); protected $definition = class Symfony\Component\Console\Input\InputDefinition { private $arguments = array (...); private $requiredCount = 1; private $hasAnArrayArgument = TRUE; private $hasOptional = TRUE; private $options = array (...); private $shortcuts = array (...) }; protected $options = array ('verbose' => TRUE); protected $arguments = array ('command' => 'files:scan', 'user_id' => array (...)); protected $interactive = TRUE }, $output = class Symfony\Component\Console\Output\ConsoleOutput { private $stderr = class Symfony\Component\Console\Output\StreamOutput { private $stream = resource(636) of type (stream); private ${Symfony\Component\Console\Output\Output}:verbosity = 32; private ${Symfony\Component\Console\Output\Output}:formatter = class Symfony\Component\Console\Formatter\OutputFormatter { ... } }; private ${Symfony\Component\Console\Output\StreamOutput}:stream = resource(635) of type (stream); private ${Symfony\Component\Console\Output\Output}:verbosity = 32; private ${Symfony\Component\Console\Output\Output}:formatter = class Symfony\Component\Console\Formatter\OutputFormatter { private $decorated = TRUE; private $styles = array (...); private $styleStack = class Symfony\Component\Console\Formatter\OutputFormatterStyleStack { ... } } }) /var/www/nextcloud/3rdparty/symfony/console/Application.php:186
PHP   7. OC\Core\Command\Base->run($input = class Symfony\Component\Console\Input\ArgvInput { private $tokens = array (0 => '-vvvvvvvvvvv', 1 => 'files:scan', 2 => 'myuser'); private $parsed = array (); protected $definition = class Symfony\Component\Console\Input\InputDefinition { private $arguments = array (...); private $requiredCount = 1; private $hasAnArrayArgument = TRUE; private $hasOptional = TRUE; private $options = array (...); private $shortcuts = array (...) }; protected $options = array ('verbose' => TRUE); protected $arguments = array ('command' => 'files:scan', 'user_id' => array (...)); protected $interactive = TRUE }, $output = class Symfony\Component\Console\Output\ConsoleOutput { private $stderr = class Symfony\Component\Console\Output\StreamOutput { private $stream = resource(636) of type (stream); private ${Symfony\Component\Console\Output\Output}:verbosity = 32; private ${Symfony\Component\Console\Output\Output}:formatter = class Symfony\Component\Console\Formatter\OutputFormatter { ... } }; private ${Symfony\Component\Console\Output\StreamOutput}:stream = resource(635) of type (stream); private ${Symfony\Component\Console\Output\Output}:verbosity = 32; private ${Symfony\Component\Console\Output\Output}:formatter = class Symfony\Component\Console\Formatter\OutputFormatter { private $decorated = TRUE; private $styles = array (...); private $styleStack = class Symfony\Component\Console\Formatter\OutputFormatterStyleStack { ... } } }) /var/www/nextcloud/3rdparty/symfony/console/Application.php:818
PHP   8. Symfony\Component\Console\Command\Command->run($input = class Symfony\Component\Console\Input\ArgvInput { private $tokens = array (0 => '-vvvvvvvvvvv', 1 => 'files:scan', 2 => 'myuser'); private $parsed = array (); protected $definition = class Symfony\Component\Console\Input\InputDefinition { private $arguments = array (...); private $requiredCount = 1; private $hasAnArrayArgument = TRUE; private $hasOptional = TRUE; private $options = array (...); private $shortcuts = array (...) }; protected $options = array ('verbose' => TRUE); protected $arguments = array ('command' => 'files:scan', 'user_id' => array (...)); protected $interactive = TRUE }, $output = class Symfony\Component\Console\Output\ConsoleOutput { private $stderr = class Symfony\Component\Console\Output\StreamOutput { private $stream = resource(636) of type (stream); private ${Symfony\Component\Console\Output\Output}:verbosity = 32; private ${Symfony\Component\Console\Output\Output}:formatter = class Symfony\Component\Console\Formatter\OutputFormatter { ... } }; private ${Symfony\Component\Console\Output\StreamOutput}:stream = resource(635) of type (stream); private ${Symfony\Component\Console\Output\Output}:verbosity = 32; private ${Symfony\Component\Console\Output\Output}:formatter = class Symfony\Component\Console\Formatter\OutputFormatter { private $decorated = TRUE; private $styles = array (...); private $styleStack = class Symfony\Component\Console\Formatter\OutputFormatterStyleStack { ... } } }) /var/www/nextcloud/core/Command/Base.php:161
PHP   9. OCA\Files\Command\Scan->execute($input = class Symfony\Component\Console\Input\ArgvInput { private $tokens = array (0 => '-vvvvvvvvvvv', 1 => 'files:scan', 2 => 'myuser'); private $parsed = array (); protected $definition = class Symfony\Component\Console\Input\InputDefinition { private $arguments = array (...); private $requiredCount = 1; private $hasAnArrayArgument = TRUE; private $hasOptional = TRUE; private $options = array (...); private $shortcuts = array (...) }; protected $options = array ('verbose' => TRUE); protected $arguments = array ('command' => 'files:scan', 'user_id' => array (...)); protected $interactive = TRUE }, $output = class Symfony\Component\Console\Output\ConsoleOutput { private $stderr = class Symfony\Component\Console\Output\StreamOutput { private $stream = resource(636) of type (stream); private ${Symfony\Component\Console\Output\Output}:verbosity = 32; private ${Symfony\Component\Console\Output\Output}:formatter = class Symfony\Component\Console\Formatter\OutputFormatter { ... } }; private ${Symfony\Component\Console\Output\StreamOutput}:stream = resource(635) of type (stream); private ${Symfony\Component\Console\Output\Output}:verbosity = 32; private ${Symfony\Component\Console\Output\Output}:formatter = class Symfony\Component\Console\Formatter\OutputFormatter { private $decorated = TRUE; private $styles = array (...); private $styleStack = class Symfony\Component\Console\Formatter\OutputFormatterStyleStack { ... } } }) /var/www/nextcloud/3rdparty/symfony/console/Command/Command.php:256
PHP  10. OCA\Files\Command\Scan->scanFiles($user = 'myuser', $path = '/myuser', $verbose = TRUE, $output = class Symfony\Component\Console\Output\ConsoleOutput { private $stderr = class Symfony\Component\Console\Output\StreamOutput { private $stream = resource(636) of type (stream); private ${Symfony\Component\Console\Output\Output}:verbosity = 32; private ${Symfony\Component\Console\Output\Output}:formatter = class Symfony\Component\Console\Formatter\OutputFormatter { ... } }; private ${Symfony\Component\Console\Output\StreamOutput}:stream = resource(635) of type (stream); private ${Symfony\Component\Console\Output\Output}:verbosity = 32; private ${Symfony\Component\Console\Output\Output}:formatter = class Symfony\Component\Console\Formatter\OutputFormatter { private $decorated = TRUE; private $styles = array (...); private $styleStack = class Symfony\Component\Console\Formatter\OutputFormatterStyleStack { ... } } }, $backgroundScan = FALSE) /var/www/nextcloud/apps/files/lib/Command/Scan.php:234
PHP  11. OC\Files\Utils\Scanner->scan($dir = '/myuser') /var/www/nextcloud/apps/files/lib/Command/Scan.php:161
PHP  12. OC\Files\Storage\Wrapper\Wrapper->instanceOfStorage($class = 'OC\\Files\\Storage\\FailedStorage') /var/www/nextcloud/lib/private/Files/Utils/Scanner.php:197
PHP  13. OCA\Files_Sharing\SharedStorage->instanceOfStorage($class = 'OC\\Files\\Storage\\FailedStorage') /var/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php:490
PHP  14. OC\Files\Storage\Wrapper\Wrapper->instanceOfStorage($class = 'OC\\Files\\Storage\\FailedStorage') /var/www/nextcloud/apps/files_sharing/lib/SharedStorage.php:156
PHP  15. OCA\Files_Sharing\SharedStorage->getWrapperStorage() /var/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php:490
PHP  16. OCA\Files_Sharing\SharedStorage->init() /var/www/nextcloud/apps/files_sharing/lib/SharedStorage.php:475
PHP  17. OC\Files\View->getPath($id = 16674) /var/www/nextcloud/apps/files_sharing/lib/SharedStorage.php:118
PHP  18. OC\Files\Cache\Wrapper\CacheJail->getPathById($id = 16674) /var/www/nextcloud/lib/private/Files/View.php:1697
PHP  19. OCA\Files_Sharing\Cache->getCache() /var/www/nextcloud/lib/private/Files/Cache/Wrapper/CacheJail.php:298
PHP  20. OCA\Files_Trashbin\Storage->getSourceStorage() /var/www/nextcloud/apps/files_sharing/lib/Cache.php:71
PHP  21. OC\Files\Storage\Wrapper\Wrapper->__call($method = 'getSourceStorage', $args = array ()) /var/www/nextcloud/apps/files_sharing/lib/Cache.php:71
PHP  22. call_user_func_array:{/var/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php:501}(array (0 => class OCA\Files_Sharing\SharedStorage { private $superShare = class OC\Share20\Share { ... }; private $groupedShares = array (...); private $ownerView = class OC\Files\View { ... }; private $initialized = TRUE; private $sourceRootInfo = class OC\Files\Cache\CacheEntry { ... }; private $user = 'Carlos Hanimann'; private $logger = class OC\Log { ... }; private $nonMaskedStorage = NULL; private $options = NULL; protected $rootPath = NULL; protected $storage = NULL; public $cache = class OCA\Files_Sharing\Cache { ... }; public $scanner = NULL; public $watcher = NULL; public $propagator = NULL; public $updater = NULL; public $mountOptions = array (...) }, 1 => 'getSourceStorage'), array ()) /var/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php:501
PHP  23. OCA\Files_Sharing\SharedStorage->getSourceStorage() /var/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php:501
PHP  24. OCA\Files_Sharing\SharedStorage->init() /var/www/nextcloud/apps/files_sharing/lib/SharedStorage.php:470
PHP  25. OC\Files\View->getPath($id = 12187) /var/www/nextcloud/apps/files_sharing/lib/SharedStorage.php:118
PHP  26. OC\Files\Cache\Wrapper\CacheJail->getPathById($id = 12187) /var/www/nextcloud/lib/private/Files/View.php:1697
PHP  27. OCA\Files_Sharing\Cache->getCache() /var/www/nextcloud/lib/private/Files/Cache/Wrapper/CacheJail.php:298

The interesting bit is stack frames 11/12. It looks like the scanner tries to check whether the storage is valid (i.e. it checks whether it is not failed) but that check actually triggers the error :/

Lucky enough the faulty instanceOfStorage check does not trigger anymore after clearing the file cache.

@koep
Copy link

koep commented Jun 16, 2017

I ran into the same thing @znerol described (running nc version 11.0.2.7).
Is it actually safe to run php occ files:cleanup without a proper files:scan beforehand?
Many thanks in advance.

@icewind1991
Copy link
Member

@koep @znerol can you see if #5091 fixes the problem for you

@koep
Copy link

koep commented Jun 16, 2017

Thanks for your reply @icewind1991
Can I apply this patch while on version 11.0.2.7?
Or do I need to apply something else as well? e.g. f2e981e

@icewind1991
Copy link
Member

f2e981e should already be backported to 11, the patch should apply cleanly on 11

@koep
Copy link

koep commented Jun 16, 2017

Worked for me. Thanks!

@idmacdonald
Copy link

I did a lot of manual cleanup of the NC database in order to get around this problem. While I do have backups, it wouldn't be easy for me to setup a clone of the NC in order to test. So, I'm afraid I'm probably not going to be much help in terms of testing...

@bl4ckOut
Copy link

Had this problem a few days after moving data directory to new location and creating symlink.
f2e981e
and
#5091
with "occ files:scan --all" fixed it for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.