Update from 7 to 9.1 - You don't have permission to upload or create files here

### Steps to reproduce

  1. manual update procedure:
    owncloud-7.0.5.zip
    owncloud-8.0.0.zip
    owncloud-8.1.0.zip
    owncloud-8.2.0.zip
    owncloud-9.0.0.zip
    owncloud-9.0.3.zip
    owncloud-9.1.0.zip

### Expected behaviour
Uploading files

### Actual behaviour
Login with existing or NEW user:
“You don’t have permission to upload or create files here”

### Server configuration
Operating system: RHEL 6.8 with SCL

Web server: Apache 2.4

Database: Oracle v5.5

PHP version: php55 (with all required modules)

ownCloud version: (9.1.0.15)

Updated from an older ownCloud or fresh install: Updated from v7

Where did you install ownCloud from: manual installation

Signing status (ownCloud 9.0 and above):

Login as admin user into your ownCloud and access 
http://example.com/index.php/settings/integrity/failed 

paste the results here.
``` "No errors have been found."

**List of activated apps:**
Enabled:
  - activity: 2.3.2
  - comments: 0.3.0
  - dav: 0.2.5
  - federatedfilesharing: 0.3.0
  - federation: 0.1.0
  - files: 1.5.1
  - files_pdfviewer: 0.8.1
  - files_sharing: 0.10.0
  - files_texteditor: 2.1
  - files_trashbin: 0.9.0
  - files_versions: 1.3.0
  - files_videoplayer: 0.9.8
  - firstrunwizard: 1.1
  - gallery: 15.0.0
  - notifications: 0.3.0
  - provisioning_api: 0.5.0
  - systemtags: 0.3.0
  - templateeditor: 0.1
  - updatenotification: 0.2.1
Disabled:
  - encryption
  - external
  - files_antivirus
  - files_external
  - user_external
  - user_ldap


**The content of config/config.php:**
{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "owncloud.example.com"
        ],
        "datadirectory": "\/var\/www\/html\/owncloud\/data",
        "overwrite.cli.url": "https:\/\/owncloud.example.com",
        "dbtype": "mysql",
        "version": "9.1.0.15",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "theme": "our-own-custom-theme",
        "defaultapp": "files",
        "skeletondirectory": "",
        "mail_domain": "example.com",
        "mail_from_address": "info",
        "overwritehost": "owncloud.example.com",
        "overwriteprotocol": "https",
        "has_internet_connection": false,
        "check_for_working_webdav": false,
        "appstoreenabled": false,
        "mail_smtpmode": "smtp",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "25",
        "maintenance": false,
        "loglevel": 2,
        "trashbin_retention_obligation": "auto",
        "htaccess.RewriteBase": "\/"
    }
}


**Are you using external storage, if yes which one:** local/smb/sftp/...
NO

**Are you using encryption:** yes/no
NO

**Are you using an external user-backend, if yes which one:** LDAP/ActiveDirectory/Webdav/...
NO

### Client configuration
**Browser:**
Firefox 45+

**Operating system:**
Ubuntu 14+

### Logs
#### Web server error log
Shows nothing specific to this error

#### ownCloud log (data/owncloud.log)
{"reqId":"V8P7YDRb0oj8e@IwmedCZgAAAAc","remoteAddr":"xxx.xxx.xxx.xxx","app":"no app in context","message":"CSRF check failed","level":0,"time":"2016-08-29T09:07:44+00:00","method":"POST","url":"\/index.php\/login","user":"--"}
{"reqId":"V8aCFfYV-1ffsmD2z6LjbAAAAAA","remoteAddr":"xxx.xxx.xxx.xxx","app":"files","message":"Exception: {\"Exception\":\"BadMethodCallException\",\"Message\":\"Not in batch\",\"Code\":0,\"Trace\":\"#0 \\/opt\\/rh\\/httpd24\\/root\\/var\\/www\\/html\\/owncloud\\/lib\\/private\\/Files\\/Utils\\/Scanner.php(143): OC\\Files\\Cache\\Propagator->commitBatch()\n#1 \\/opt\\/rh\\/httpd24\\/root\\/var\\/www\\/html\\/owncloud\\/apps\\/files\\/lib\\/BackgroundJob\\/ScanFiles.php(87): OC\\Files\\Utils\\Scanner->backgroundScan('')\n#2 \\/opt\\/rh\\/httpd24\\/root\\/var\\/www\\/html\\/owncloud\\/apps\\/files\\/lib\\/BackgroundJob\\/ScanFiles.php(111): OCA\\Files\\BackgroundJob\\ScanFiles->runScanner(Object(OC\\User\\User))\n#3 \\/opt\\/rh\\/httpd24\\/root\\/var\\/www\\/html\\/owncloud\\/lib\\/private\\/BackgroundJob\\/Job.php(52): OCA\\Files\\BackgroundJob\\ScanFiles->run(NULL)\n#4 \\/opt\\/rh\\/httpd24\\/root\\/var\\/www\\/html\\/owncloud\\/lib\\/private\\/BackgroundJob\\/TimedJob.php(53): OC\\BackgroundJob\\Job->execute(Object(OC\\BackgroundJob\\JobList), Object(OC\\Log))\n#5 \\/opt\\/rh\\/httpd24\\/root\\/var\\/www\\/html\\/owncloud\\/cron.php(144): OC\\BackgroundJob\\TimedJob->execute(Object(OC\\BackgroundJob\\JobList), Object(OC\\Log))\n#6 {main}\",\"File\":\"\\/opt\\/rh\\/httpd24\\/root\\/var\\/www\\/html\\/owncloud\\/lib\\/private\\/Files\\/Cache\\/Propagator.php\",\"Line\":145}","level":3,"time":"2016-08-31T07:07:01+00:00","method":"GET","url":"\/cron.php","user":"--"}
{"reqId":"V8aWpfYV-1ffsmD2z6LkKQAAAAA","remoteAddr":"xxx.xxx.xxx.xxx","app":"no app in context","message":"Invalidating tokens older than 2016-08-30T08:34:45+00:00","level":1,"time":"2016-08-31T08:34:45+00:00","method":"GET","url":"\/cron.php","user":"--"}
{"reqId":"V8aW7-YV-1ffsmD2z6LkMwAAAAA","remoteAddr":"xxx.xxx.xxx.xxx","app":"DeleteOrphanedSharesJob","message":"0 orphaned share(s) deleted","level":0,"time":"2016-08-31T08:35:59+00:00","method":"GET","url":"\/cron.php","user":"--"}
{"reqId":"V8acnHQqSiPdCLMyyu0rMAAAAAI","remoteAddr":"xxx.xxx.xxx.xxx","app":"files","message":"Exception: {\"Exception\":\"BadMethodCallException\",\"Message\":\"Not in batch\",\"Code\":0,\"Trace\":\"#0 \\/opt\\/rh\\/httpd24\\/root\\/var\\/www\\/html\\/owncloud\\/lib\\/private\\/Files\\/Utils\\/Scanner.php(143): OC\\Files\\Cache\\Propagator->commitBatch()\n#1 \\/opt\\/rh\\/httpd24\\/root\\/var\\/www\\/html\\/owncloud\\/apps\\/files\\/lib\\/BackgroundJob\\/ScanFiles.php(87): OC\\Files\\Utils\\Scanner->backgroundScan('')\n#2 \\/opt\\/rh\\/httpd24\\/root\\/var\\/www\\/html\\/owncloud\\/apps\\/files\\/lib\\/BackgroundJob\\/ScanFiles.php(111): OCA\\Files\\BackgroundJob\\ScanFiles->runScanner(Object(OC\\User\\User))\n#3 \\/opt\\/rh\\/httpd24\\/root\\/var\\/www\\/html\\/owncloud\\/lib\\/private\\/BackgroundJob\\/Job.php(52): OCA\\Files\\BackgroundJob\\ScanFiles->run(NULL)\n#4 \\/opt\\/rh\\/httpd24\\/root\\/var\\/www\\/html\\/owncloud\\/lib\\/private\\/BackgroundJob\\/TimedJob.php(53): OC\\BackgroundJob\\Job->execute(Object(OC\\BackgroundJob\\JobList), Object(OC\\Log))\n#5 \\/opt\\/rh\\/httpd24\\/root\\/var\\/www\\/html\\/owncloud\\/cron.php(144): OC\\BackgroundJob\\TimedJob->execute(Object(OC\\BackgroundJob\\JobList), Object(OC\\Log))\n#6 {main}\",\"File\":\"\\/opt\\/rh\\/httpd24\\/root\\/var\\/www\\/html\\/owncloud\\/lib\\/private\\/Files\\/Cache\\/Propagator.php\",\"Line\":145}","level":3,"time":"2016-08-31T09:00:12+00:00","method":"GET","url":"\/cron.php","user":"--"}
{"reqId":"V8ad7@PseOdGO965Oqp5FgAAAAQ","remoteAddr":"xxx.xxx.xxx.xxx","app":"DeleteOrphanedItems","message":"0 orphaned system tag relations deleted","level":0,"time":"2016-08-31T09:05:51+00:00","method":"GET","url":"\/cron.php","user":"--"}
{"reqId":"V8ad7@PseOdGO965Oqp5FgAAAAQ","remoteAddr":"xxx.xxx.xxx.xxx","app":"DeleteOrphanedItems","message":"0 orphaned user tag relations deleted","level":0,"time":"2016-08-31T09:05:51+00:00","method":"GET","url":"\/cron.php","user":"--"}
{"reqId":"V8ad7@PseOdGO965Oqp5FgAAAAQ","remoteAddr":"xxx.xxx.xxx.xxx","app":"DeleteOrphanedItems","message":"0 orphaned comments deleted","level":0,"time":"2016-08-31T09:05:51+00:00","method":"GET","url":"\/cron.php","user":"--"}
{"reqId":"V8ad7@PseOdGO965Oqp5FgAAAAQ","remoteAddr":"xxx.xxx.xxx.xxx","app":"DeleteOrphanedItems","message":"0 orphaned comment read marks deleted","level":0,"time":"2016-08-31T09:05:51+00:00","method":"GET","url":"\/cron.php","user":"--"}
{"reqId":"V8ad-tn@ZWWqGLY2LJ8@qQAAAAg","remoteAddr":"xxx.xxx.xxx.xxx","app":"core","message":"Generating preview for \"updater.png\" with \"OC\Preview\PNG\"","level":0,"time":"2016-08-31T09:06:06+00:00","method":"GET","url":"\/index.php\/apps\/gallery\/thumbnails?ids=141&scale=1&square=0&requesttoken=IwNjACBkBwJccmYuNidHMz0PAU4aLT8%2BBSIDMyxCQSQ%3D%3Azp3Fm3OueASccR%2BPYkQemUkgBilXG33ArLJCowmnAew%3D","user":"user1"}
{"reqId":"V8ad-tn@ZWWqGLY2LJ8@qQAAAAg","remoteAddr":"xxx.xxx.xxx.xxx","app":"core","message":"OC_Image->fixOrientation() Image is not a JPEG.","level":0,"time":"2016-08-31T09:06:06+00:00","method":"GET","url":"\/index.php\/apps\/gallery\/thumbnails?ids=141&scale=1&square=0&requesttoken=IwNjACBkBwJccmYuNidHMz0PAU4aLT8%2BBSIDMyxCQSQ%3D%3Azp3Fm3OueASccR%2BPYkQemUkgBilXG33ArLJCowmnAew%3D","user":"user1"}
{"reqId":"V8ad-tn@ZWWqGLY2LJ8@qQAAAAg","remoteAddr":"xxx.xxx.xxx.xxx","app":"core","message":"OC_Image->fixOrientation() Orientation: -1","level":0,"time":"2016-08-31T09:06:06+00:00","method":"GET","url":"\/index.php\/apps\/gallery\/thumbnails?ids=141&scale=1&square=0&requesttoken=IwNjACBkBwJccmYuNidHMz0PAU4aLT8%2BBSIDMyxCQSQ%3D%3Azp3Fm3OueASccR%2BPYkQemUkgBilXG33ArLJCowmnAew%3D","user":"user1"}
{"reqId":"V8afmsZcLTB6gd32RZxPwQAAAAI","remoteAddr":"xxx.xxx.xxx.xxx","app":"no app in context","message":"Invalidating tokens older than 2016-08-30T09:12:58+00:00","level":1,"time":"2016-08-31T09:12:58+00:00","method":"GET","url":"\/cron.php","user":"--"}
{"reqId":"V8aghNn@ZWWqGLY2LJ8@tgAAAAg","remoteAddr":"xxx.xxx.xxx.xxx","app":"DeleteOrphanedSharesJob","message":"0 orphaned share(s) deleted","level":0,"time":"2016-08-31T09:16:52+00:00","method":"GET","url":"\/cron.php","user":"--"}
{"reqId":"V8ahiQxRNbDTFQ1-uv4SSQAAAAA","remoteAddr":"xxx.xxx.xxx.xxx","app":"no app in context","message":"Logged in user must be an admin","level":0,"time":"2016-08-31T09:21:14+00:00","method":"GET","url":"\/index.php\/settings\/integrity\/failed","user":"user1"}
{"reqId":"V8ahvOPseOdGO965Oqp5NQAAAAQ","remoteAddr":"xxx.xxx.xxx.xxx","app":"files","message":"Exception: {\"Exception\":\"BadMethodCallException\",\"Message\":\"Not in batch\",\"Code\":0,\"Trace\":\"#0 \\/opt\\/rh\\/httpd24\\/root\\/var\\/www\\/html\\/owncloud\\/lib\\/private\\/Files\\/Utils\\/Scanner.php(143): OC\\Files\\Cache\\Propagator->commitBatch()\n#1 \\/opt\\/rh\\/httpd24\\/root\\/var\\/www\\/html\\/owncloud\\/apps\\/files\\/lib\\/BackgroundJob\\/ScanFiles.php(87): OC\\Files\\Utils\\Scanner->backgroundScan('')\n#2 \\/opt\\/rh\\/httpd24\\/root\\/var\\/www\\/html\\/owncloud\\/apps\\/files\\/lib\\/BackgroundJob\\/ScanFiles.php(111): OCA\\Files\\BackgroundJob\\ScanFiles->runScanner(Object(OC\\User\\User))\n#3 \\/opt\\/rh\\/httpd24\\/root\\/var\\/www\\/html\\/owncloud\\/lib\\/private\\/BackgroundJob\\/Job.php(52): OCA\\Files\\BackgroundJob\\ScanFiles->run(NULL)\n#4 \\/opt\\/rh\\/httpd24\\/root\\/var\\/www\\/html\\/owncloud\\/lib\\/private\\/BackgroundJob\\/TimedJob.php(53): OC\\BackgroundJob\\Job->execute(Object(OC\\BackgroundJob\\JobList), Object(OC\\Log))\n#5 \\/opt\\/rh\\/httpd24\\/root\\/var\\/www\\/html\\/owncloud\\/cron.php(144): OC\\BackgroundJob\\TimedJob->execute(Object(OC\\BackgroundJob\\JobList), Object(OC\\Log))\n#6 {main}\",\"File\":\"\\/opt\\/rh\\/httpd24\\/root\\/var\\/www\\/html\\/owncloud\\/lib\\/private\\/Files\\/Cache\\/Propagator.php\",\"Line\":145}","level":3,"time":"2016-08-31T09:22:04+00:00","method":"GET","url":"\/cron.php","user":"--"}
{"reqId":"V8ajAkBpvl4mwg3IeW2qxgAAAAM","remoteAddr":"xxx.xxx.xxx.xxx","app":"no app in context","message":"Invalidating tokens older than 2016-08-30T09:27:31+00:00","level":1,"time":"2016-08-31T09:27:31+00:00","method":"GET","url":"\/cron.php","user":"--"}
{"reqId":"V8a9q6UyM8zDQP0XjSfJbAAAAAE","remoteAddr":"xxx.xxx.xxx.xxx","app":"DeleteOrphanedSharesJob","message":"0 orphaned share(s) deleted","level":0,"time":"2016-08-31T11:21:16+00:00","method":"GET","url":"\/cron.php","user":"--"}

#####################################

**This is checked/done already:**
- php -v
PHP 5.5.21 (cli) (built: Jun 10 2015 05:26:44) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies

- req. PHP Modules => yes
- permissions set https://doc.owncloud.org/server/9.1/admin_manual/installation/installation_wizard.html#strong-perms-label
- list directories with sudo -u apache => yes
- test chmod 777 => yes

- sudo -u apache php occ files:cleanup 
0 orphaned file cache entries deleted

- sudo -u apache php occ files:scan --all
Scanning files for 8 users
Starting scan for user 1 out of 8 (User1)
Starting scan for user 2 out of 8 (User2)
Home storage for user User2 not writable
Make sure you're running the scan command only as the user the web server runs as
Starting scan for user 3 out of 8 (User3)
Starting scan for user 4 out of 8 (User4)
Starting scan for user 5 out of 8 (User-admin)
Starting scan for user 6 out of 8 (User5)
Starting scan for user 7 out of 8 (User6)
Starting scan for user 8 out of 8 (User7)
+---------+-------+--------------+
| Folders | Files | Elapsed time |
+---------+-------+--------------+
| 41      | 21    | 00:00:01     |
+---------+-------+--------------+

- sudo -u apache php occ maintenance:mode --on
  sudo -u apache php occ maintenance:repair

  ownCloud is in maintenance mode - no app have been loaded
 Failed to load repair step for dav: Repair step 'OCA\DAV\Migration\Classification' is unknown
 - Repair mime types
 - Repair legacy storages
 - Clear asset cache after upgrade
     - Asset pipeline disabled -> nothing to do
 - Generate ETags for file where no ETag is present.
     - ETags have been fixed for 0 files/folders.
 - Clean tags and favorites
     - 0 tags of deleted users have been removed.
     - 0 tags for delete files have been removed.
     - 0 tag entries for deleted tags have been removed.
     - 0 tags with no entries have been removed.
 - Drop old database tables
 28/28 [============================] 100%
 - Drop old background jobs
 - Remove getetag entries in properties table
     - Removed 0 unneeded "{DAV:}getetag" entries from properties table.
 - Repair outdated OCS IDs
 - Repair invalid shares
 - Remove old share propagation app entries
 - Remove old (< 9.0) calendar/contact shares
 4/4 [============================] 100%  
 - Fix permissions so avatars can be stored again
 2/2 [============================] 100%  
 - Remove shares of a users root folder

 
 What is working:
 
 - Login & upload via webdavs (Dolphin KDE-Filemanager)
 - Uploading Pictures via Web-Gallery

There is a large bug report about this failed CSRF checked:

If you can do snapshots or you have a test environment, you could use the 9.1.1RC1 which contains the patch.

Hi,

this is also a wrong upgrade procedure. A correct one would be:

7.0.x → 7.0.15 → 8.0.14 → 8.1.9 → 8.2.7 → 9.0.4 → 9.1.0