Occ error after update 14

Hy,
in admin apper this:

The database is missing some indexes. Due to the fact that adding indexes on big tables could take some time they were not added automatically. By running “occ db:add-missing-indices” those missing indexes could be added manually while the instance keeps running. Once the indexes are added queries to those tables are usually much faster.

  • Missing index “share_with_index” in table “oc_share”.
  • Missing index “parent_index” in table “oc_share”.
  • Missing index “fs_mtime” in table “oc_filecache”.

Ok say run … noproblem but after ssh command:

sudo -u myuser php occ db:add-missing-indices
Content-type: text/html; charset=UTF-8

An unhandled exception has been thrown:
TypeError: Return value of OC\AppFramework\Http\Request::getScriptName() must be of the type string, null returned in /home/***/public_html/lib/private/AppFramework/Http/Request.php:796
Stack trace:
#0 /home/***/public_html/lib/base.php(154): OC\AppFramework\Http\Request->getScriptName()
#1 /home/***/public_html/lib/base.php(591): OC::initPaths()
#2 /home/***/public_html/lib/base.php(1068): OC::init()
#3 /home/***/public_html/console.php(46): require_once('/home/***/p...')
#4 /home/***/public_html/occ(10): require_once('/home/***/p...')

Solution?
Thx!

Update>

For my this solution work perfect:

I not use tablename
"__nextcloud__"

simple add directley in myadmin

ALTER TABLE oc_share ADD INDEX share_with_index (share_with) USING BTREE;
ALTER TABLE oc_share ADD INDEX parent_index (parent) USING BTREE;
i added this:
ALTER TABLE oc_filecache ADD INDEX fs_mtime (mtime) USING BTREE;

the rest Warning and error resolve in cPanel WHM

So far, the first line was sloppy
Add lines 2 and 3 to the apache setting

Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" env=HTTPS

Header always set Referrer-Policy "no-referrer-when-downgrade"
Header always set X-Permitted-Cross-Domain-Policies "none"

Edit apache config:

Final result:

If anyone knows the solution to the occ command line error I would thank you! …

Hi,

Can you just try:

sudo -u myuser php /home/***/public_html/occ db:add-missing-indices

What PHP version are you using?
Can you check your folder and file permissions again?

It does not work and 7.1 php is used in the cpanel because it is not work with 7.2 … while it is allegedly compatible and if I switch to 72, the whole thing dies.
And os centos latest v.

Is the first question @all solved?
If so - please do me a favour and list your steps!

If not … I’ve got the same problem!

./occ db:add-missing-indices
X-Powered-By: PHP/7.1.22
Content-type: text/html

An unhandled exception has been thrown:
TypeError: Return value of OC\AppFramework\Http\Request::getScriptName() must be of the type string, null returned in /mnt/web004/e2/90/5395790/htdocs/nextcloud/lib/private/AppFramework/Http/Request.php:796
Stack trace:
#0 /mnt/web004/e2/90/5395790/htdocs/nextcloud/lib/base.php(154): OC\AppFramework\Http\Request->getScriptName()
#1 /mnt/web004/e2/90/5395790/htdocs/nextcloud/lib/base.php(591): OC::initPaths()
#2 /mnt/web004/e2/90/5395790/htdocs/nextcloud/lib/base.php(1068): OC::init()
#3 /mnt/web004/e2/90/5395790/htdocs/nextcloud/console.php(46): require_once(‘/mnt/web004/e2/…’)
#4 /mnt/web004/e2/90/5395790/htdocs/nextcloud/occ(10): require_once(‘/mnt/web004/e2/…’)

Rufio

hey @schmu
i ran into the same problems with my update.
here are some details of my setup

Steps to reproduce

did upgrade from nc 13.0.7. to 14.0.4. and ran into several problems—
could solve some myself by disabling some apps manually (first and foremost files_external_gdrive (or such)

Expected behaviour

should run smoothly

Actual behaviour

it shows some errors…

Server configuration detail

Operating system: Linux 4.9.35-v7+ #1014 SMP Fri Jun 30 14:47:43 BST 2017 armv7l

Webserver: Apache/2.4.25 (Raspbian) (fpm-fcgi)

Database: mysql 10.1.37

PHP version:

7.2.13-1+0~20181207100540.13+stretch~1.gbpf57305
Modules loaded: Core, date, libxml, openssl, pcre, zlib, filter, hash, Reflection, SPL, sodium, session, standard, cgi-fcgi, mysqlnd, PDO, xml, bz2, calendar, ctype, curl, dom, mbstring, fileinfo, ftp, gd, gettext, iconv, igbinary, imagick, intl, json, ldap, exif, mysqli, pdo_mysql, Phar, posix, readline, redis, shmop, SimpleXML, smbclient, sockets, sysvmsg, sysvsem, sysvshm, tokenizer, wddx, xmlreader, xmlwriter, xsl, zip, libsmbclient, Zend OPcache

Nextcloud version: 14.0.4 - 14.0.4.2

Updated from an older Nextcloud/ownCloud or fresh install: updated from 13.0.7.

Where did you install Nextcloud from: back then at ownyourbits

Signing status

Array
(
)

List of activated apps
Enabled:
 - accessibility: 1.0.1
 - cloud_federation_api: 0.0.1
 - dav: 1.6.0
 - federatedfilesharing: 1.4.0
 - federation: 1.4.0
 - files: 1.9.0
 - files_external: 1.5.0
 - files_pdfviewer: 1.3.2
 - files_rightclick: 0.8.4
 - files_sharing: 1.6.2
 - files_texteditor: 2.6.0
 - files_trackdownloads: 1.3.1
 - files_trashbin: 1.4.1
 - files_videoplayer: 1.3.0
 - firstrunwizard: 2.3.0
 - flowupload: 0.0.8
 - gallery: 18.1.0
 - groupfolders: 2.0.0
 - issuetemplate: 0.4.0
 - logreader: 2.0.0
 - lookup_server_connector: 1.2.0
 - mail: 0.11.0
 - nextcloud_announcements: 1.3.0
 - notifications: 2.2.1
 - oauth2: 1.2.1
 - password_policy: 1.4.0
 - passwords: 2018.12.0
 - phonetrack: 0.3.9
 - previewgenerator: 2.0.0
 - provisioning_api: 1.4.0
 - registration: 0.4.5
 - serverinfo: 1.4.0
 - sharebymail: 1.4.0
 - socialsharing_email: 1.0.4
 - socialsharing_facebook: 1.0.3
 - socialsharing_twitter: 1.0.3
 - support: 1.0.0
 - tasks: 0.9.8
 - theming: 1.5.0
 - twofactor_backupcodes: 1.3.1
 - updatenotification: 1.4.1
 - workflowengine: 1.4.0
Disabled:
 - activity
 - admin_audit
 - admin_notifications
 - announcementcenter
 - apporder
 - audioplayer
 - auto_mail_accounts
 - bookmarks
 - bruteforcesettings
 - calendar
 - caniupdate
 - circles
 - cms_pico
 - comments
 - contacts
 - dashboard
 - data_request
 - drop_account
 - dropit
 - encryption
 - external
 - files_accesscontrol
 - files_downloadactivity
 - files_external_gdrive
 - files_snapshots
 - files_versions
 - impersonate
 - metadata
 - ownbackup
 - quota_warning
 - radio
 - rainloop
 - ransomware_protection
 - sharerenamer
 - spreed
 - survey_client
 - systemtags
 - user_external
 - user_ldap

Configuration (config/config.php)
{
    "passwordsalt": "***REMOVED SENSITIVE VALUE***",
    "secret": "***REMOVED SENSITIVE VALUE***",
    "trusted_domains": {
        "0": "localhost",
        "1": "192.168.192.250",
        "2": "nextcloud.local",
        "4": "ya.ya.ya",
        "5": "abc.de",
        "7": "nextcloudpi",
        "8": "nextcloudpi.lan"
    },
    "datadirectory": "***REMOVED SENSITIVE VALUE***",
    "overwrite.cli.url": "https:\/\/removed\/",
    "dbtype": "mysql",
    "version": "14.0.4.2",
    "dbname": "***REMOVED SENSITIVE VALUE***",
    "dbhost": "***REMOVED SENSITIVE VALUE***",
    "dbport": "",
    "dbtableprefix": "oc_",
    "mysql.utf8mb4": true,
    "dbuser": "***REMOVED SENSITIVE VALUE***",
    "dbpassword": "***REMOVED SENSITIVE VALUE***",
    "installed": true,
    "instanceid": "***REMOVED SENSITIVE VALUE***",
    "mail_smtpmode": "smtp",
    "mail_smtpauthtype": "LOGIN",
    "mail_smtpsecure": "ssl",
    "mail_from_address": "***REMOVED SENSITIVE VALUE***",
    "mail_domain": "***REMOVED SENSITIVE VALUE***",
    "mail_smtpauth": 1,
    "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
    "mail_smtpport": "465",
    "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
    "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
    "loglevel": 0,
    "maintenance": false,
    "theme": "",
    "updater.release.channel": "production",
    "memcache.local": "\\OC\\Memcache\\Redis",
    "memcache.locking": "\\OC\\Memcache\\Redis",
    "redis": {
        "host": "***REMOVED SENSITIVE VALUE***",
        "port": 0,
        "timeout": 0,
        "password": "***REMOVED SENSITIVE VALUE***"
    },
    "log_type": "file",
    "defaultapp": "apporder",
    "updater.secret": "***REMOVED SENSITIVE VALUE***"
}

Are you using external storage, if yes which one: local/smb/sftp/…

Are you using encryption:

Are you using an external user-backend, if yes which one:

Client configuration

Browser: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:63.0) Gecko/20100101 Firefox/63.0

Operating system: Windows 7 and 10 pro (64)

i didn’t play around with file permissions - but if you’d be so nice and give me the command i’d tell you it’s outcome :wink:

looking forward and thanks in advance

Hi @JimmyKater

Can you post your error messages again? What’s written in the nextcloud log?

OK :slight_smile:
Change directory to your NC installation folder (probably /var/www/nextcloud). Then run:

ls -lR | grep -E "^dr|^-r" | grep -v "`ps -ef | grep apache | grep -v root | awk '{print $1}' | sort | uniq`"

Not a nice command, but I don’t know your web server user :stuck_out_tongue:

1 Like
  1. The database is missing some indexes. Due to the fact that adding indexes on big tables could take some time they were not added automatically. By running “occ db:add-missing-indices” those missing indexes could be added manually while the instance keeps running. Once the indexes are added queries to those tables are usually much faster.
    
     Missing index “share_with_index” in table “oc_share”.
     Missing index “parent_index” in table “oc_share”.
     Missing index “fs_mtime” in table “oc_filecache”.
    

2. The “Referrer-Policy” HTTP header is not set to “no-referrer”, “no-referrer-when-downgrade”, “strict-origin” or “strict-origin-when-cross-origin”. This can leak referer information.

i guess this could be solved by this thread (haven’t tried it yet, though)

Error PHP Undefined index: parent at /var/www/nextcloud/lib/private/Files/Cache/Cache.php#168 2018-12-10T22:17:57+0100

yes. user is www-data… too bad that your command showed no result on the screen :frowning:

does this help?

root@nextcloud:/var/log# ls -la /var/www/nextcloud
total 164
drwxr-xr-x 15 www-data www-data 4096 Dec 10 19:44 .
drwxr-xr-x 7 root root 4096 Dec 10 15:28 …
-rw-r–r-- 1 www-data www-data 2850 Dec 10 20:26 .htaccess
-rw-r–r-- 1 www-data www-data 163 Dec 10 19:42 .user.ini
drwxr-xr-x 33 www-data www-data 4096 Dec 10 19:42 3rdparty
-rw-r–r-- 1 www-data www-data 12063 Dec 10 19:42 AUTHORS
-rw-r–r-- 1 www-data www-data 34520 Dec 10 19:42 COPYING
drwxr-xr-x 82 www-data www-data 4096 Dec 10 21:59 apps
drwxr-xr-x 2 www-data www-data 4096 Dec 10 19:44 config
-rw-r–r-- 1 www-data www-data 3650 Dec 10 19:42 console.php
drwxr-xr-x 18 www-data www-data 4096 Dec 10 19:45 core
-rw-r–r-- 1 www-data www-data 4979 Dec 10 19:44 cron.php
drwxr-x— 6 www-data www-data 4096 Aug 7 2017 data
-rw-r–r-- 1 www-data www-data 179 Dec 10 19:42 index.html
-rw-r–r-- 1 www-data www-data 3171 Dec 10 19:45 index.php
drwxr-xr-x 6 www-data www-data 4096 Dec 10 19:42 lib
-rw-r–r-- 1 www-data www-data 283 Dec 10 19:44 occ
drwxr-xr-x 2 www-data www-data 4096 Dec 10 19:42 ocm-provider
drwxr-xr-x 2 www-data www-data 4096 Dec 10 19:44 ocs
drwxr-xr-x 2 www-data www-data 4096 Dec 10 19:44 ocs-provider
-rw-r–r-- 1 www-data www-data 2971 Dec 10 19:45 public.php
-rw-r–r-- 1 www-data www-data 5139 Dec 10 19:45 remote.php
drwxr-xr-x 4 www-data www-data 4096 Dec 10 19:42 resources
-rw-r–r-- 1 www-data www-data 26 Dec 10 19:42 robots.txt
drwxr-xr-x 12 www-data www-data 4096 Dec 10 19:42 settings
-rw-r–r-- 1 www-data www-data 2232 Dec 10 19:45 status.php
drwxr-xr-x 3 www-data www-data 4096 Dec 10 19:42 themes
drwxr-xr-x 2 www-data www-data 4096 Aug 6 2017 updater
-rw-r–r-- 1 www-data www-data 362 Dec 10 19:42 version.php

Then your permission should be set correctly.

That’s probably not the right thread. In the earlier versions the header needed to be added manually, but with NC 14.0.4 the header was added already. Usually, the check fails, if the header is set twice.

Please check here if that’s the case and the header is really set twice:
https://securityheaders.io/

If it’s set twice, this might probably help:

Or removing the header from one of the locations. I’m currently trying to find the many threads that were opened recently. If I find them, I’ll post them here.

For the DB part, run:
sudo -u www-data php /var/www/nextcloud/occ db:add-missing-indices

1 Like

it won’t run
with the following errors

root@nextcloud:/var/log# sudo -u www-data php /var/www/nextcloud/occ db:add-missing-indices
An unhandled exception has been thrown:
ArgumentCountError: Too few arguments to function OCA\GroupFolders\Command\ExpireGroupVersions::__construct(), 0 passed in /var/www/nextcloud/lib/private/Console/Application.php on line 222 and exactly 1 expected in /var/www/nextcloud/apps/groupfolders/lib/Command/ExpireGroupVersions.php:34
Stack trace:
#0 /var/www/nextcloud/lib/private/Console/Application.php(222): OCA\GroupFolders\Command\ExpireGroupVersions->__construct()
#1 /var/www/nextcloud/lib/private/Console/Application.php(134): OC\Console\Application->loadCommandsFromInfoXml(Array)
#2 /var/www/nextcloud/console.php(95): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /var/www/nextcloud/occ(11): require_once(‘/var/www/nextcl…’)

Here we go:
the other solution is, to remove or comment the header setting from the apache config file (/etc/apache2/apache2.conf):

To remove it from the .htaccess now, doesn’t make any sense to me, because it will be added by nextcloud with every update. Removing Header always set Referrer-Policy "no referrer" from apache config should be more future-proof.

1 Like

Did you update the app groupfolders to the latest version right before?
When I wanted to run occ to find out the correct commands for the DB index I noticed that occ didn’t run on my server as well. For me this issue occured with the last groupfolders update.

I “solved” that issue by moving the “groupfolders” folder out of /var/www/nextcloud/apps/; i.e.
mv /var/www/nextcloud/apps/groupfolders ~/

Edit: Issue with groupfolders confirmed:

1 Like

at least now the add-command runs through.
so that solved MY problem with the db as well. thanks.

how do i mv it back? or would a new installation of it be better?

i need to check the other error on like tomorrow. i’m sure there’s a solution as well.

thank you very much for your help!!! i really appreciate it

1 Like

I don’t suggest moving version 2.0 back in. On github the users are reporting heavy server load and log file flooding.
Best is probably to wait for the next version and install the new and fixed version from the app store. I’ll do that this way.

And yeah, the other message will probably disappear as soon as you comment out one content-policy-header setting.

1 Like

i commented that out like this:

#<IfModule mod_headers.c>
#  Header always set Referrer-Policy "no-referrer"
#</IfModule>

but somehow it seems that it didn’t work out the way we expected it because the error didnt vanish

Hi Jimmy,

can you run your site through securityheaders.com and see whether it says something along the lines in the “Warning box”

There was a duplicate.....

If there is, this is causing the message Header always set Referrer-Policy "no referrer" to appear in your admin panel.

I had the same issue and checked in the apache configs as well as in the nginx configs and the .htaccess. I agree with Schmu, I would leave it in the .htaccess since NC is always adding it there with each update you do.

thanks @CFelix for joining in here :slight_smile:

i ran my site through the link you provided and it came up with the following warnings

Warnings

Content-Security-Policy This policy contains ‘unsafe-eval’ which is dangerous in the script-src directive.
Referrer-Policy There was a duplicate Referrer-Policy header.

and this missing thing

Missing Headers

Feature-Policy Feature Policy is a new header that allows a site to control which features and APIs can be used in the browser.

ummm. noob-question: where do i find the ngix.conf, usually?