Server: Error: Invalid argument supplied for foreach() at <NextCloud_Path>/lib/private/Installer.php#388

Created on 7 Oct 2018  路  13Comments  路  Source: nextcloud/server

Error: Invalid argument supplied for foreach() at /lib/private/Installer.php#388

Steps to reproduce

  1. None. This happens without any user interaction.

Expected behaviour

The error should not occur and the error message should not appear in the logs.

Actual behaviour

At seemingly random intervals, the message "Invalid argument supplied for foreach() at [removed]/lib/private/Installer.php#388" appears in the logs view of the admin area, where [removed] is the folder from which NextCloud is running (under /var/www). There does not seem to be a pattern in which the message is repeated. Some timestamps: 2018-10-07T11:44:44+0200, 2018-10-07T11:44:43+0200, 2018-10-07T11:39:42+0200, 2018-10-07T04:39:19+0200, 2018-10-07T04:34:19+0200, 2018-10-07T04:14:18+0200, 2018-10-07T04:04:17+0200, 2018-10-07T03:59:15+0200.

Additional information

Cron is set to run every 1 minute. The issue may have something to do with something going wrong with the automatic update checker.

Server configuration

Operating system: Linux [hostname removed] 4.9.0-8-amd64 #1 SMP Debian 4.9.110-3+deb9u5 (2018-09-30) x86_64 GNU/Linux

Web server: Server version: Apache/2.4.25 (Debian)

Database: Server version: 10.1.26-MariaDB-0+deb9u1 Debian 9.1

PHP version: PHP 7.0.30-0+deb9u1 (cli) (built: Jun 14 2018 13:50:25) ( NTS )

Nextcloud version: Version: 14.0.1.1

Updated from an older Nextcloud or fresh install: Fresh install.

Where did you install Nextcloud from: https://download.nextcloud.com/server/releases/nextcloud-14.0.1.zip

Signing status:


Signing status
No errors have been found.

List of activated apps:


Enabled:

  • accessibility: 1.0.1
  • activity: 2.7.0
  • cloud_federation_api: 0.0.1
  • comments: 1.4.0
  • contacts: 2.1.6
  • dav: 1.6.0
  • federatedfilesharing: 1.4.0
  • files: 1.9.0
  • files_pdfviewer: 1.3.2
  • files_rightclick: 0.8.4
  • files_sharing: 1.6.2
  • files_texteditor: 2.6.0
  • files_trashbin: 1.4.1
  • files_versions: 1.7.1
  • files_videoplayer: 1.3.0
  • gallery: 18.1.0
  • logreader: 2.0.0
  • lookup_server_connector: 1.2.0
  • music: 0.9.2
  • nextcloud_announcements: 1.3.0
  • notifications: 2.2.1
  • oauth2: 1.2.1
  • password_policy: 1.4.0
  • provisioning_api: 1.4.0
  • serverinfo: 1.4.0
  • sharebymail: 1.4.0
  • theming: 1.5.0
  • twofactor_backupcodes: 1.3.1
  • updatenotification: 1.4.1
  • workflowengine: 1.4.0
    Disabled:
  • admin_audit
  • encryption
  • federation
  • files_external
  • firstrunwizard
  • support
  • survey_client
  • systemtags
  • user_external
  • user_ldap
    App list

Nextcloud configuration:


Config report
{
"system": {
"instanceid": "REMOVED SENSITIVE VALUE",
"memcache.locking": "\OC\Memcache\Redis",
"memcache.local": "\OC\Memcache\APCu",
"redis": {
"host": "REMOVED SENSITIVE VALUE",
"port": 0,
"timeout": 0,
"password": "REMOVED SENSITIVE VALUE"
},
"overwrite.cli.url": "REMOVED SENSITIVE VALUE",
"htaccess.RewriteBase": "\/",
"passwordsalt": "REMOVED SENSITIVE VALUE",
"secret": "REMOVED SENSITIVE VALUE",
"trusted_domains": [
"REMOVED SENSITIVE VALUE"
],
"datadirectory": "REMOVED SENSITIVE VALUE",
"dbtype": "mysql",
"version": "14.0.1.1",
"dbname": "REMOVED SENSITIVE VALUE",
"dbhost": "REMOVED SENSITIVE VALUE",
"dbport": "",
"dbtableprefix": "oc_",
"dbuser": "REMOVED SENSITIVE VALUE",
"dbpassword": "REMOVED SENSITIVE VALUE",
"installed": true,
"mail_smtpmode": "smtp",
"mail_smtpsecure": "tls",
"mail_smtpauthtype": "LOGIN",
"mail_from_address": "REMOVED SENSITIVE VALUE",
"mail_domain": "REMOVED SENSITIVE VALUE",
"mail_smtphost": "REMOVED SENSITIVE VALUE"
}
}

Are you using external storage, if yes which one: No.

Are you using encryption: No.

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

Client configuration

Browser: Issue occurs even with no browser open. (Firefox 62.0.3.)

Operating system: Windows 10 Pro (version 1803)

Logs

Web server error log


Web server error log
Nothing relevant in error.log. Just informational messages about the server starting up.

Nextcloud log (data/nextcloud.log)


Nothing relevant. Some warnings about using a 'fallback implementation of the intl extension', which is several days old and has been fixed since.
{"reqId":"x1fAdNqS1muDBFDHrqh4","level":3,"time":"2018-09-30T20:55:57+00:00","remoteAddr":"[redacted]","user":"--","app":"PHP","method":"GET","url":"\/index.php\/csrftoken","message":"You are using a fallback implementation of the intl extension. Installing the native one is highly recommended instead. at \/var\/www\/html\/3rdparty\/patchwork\/utf8\/src\/Patchwork\/Utf8\/Bootup\/intl.php#18","userAgent":"Mozilla\/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko\/20100101 Firefox\/60.0","version":""}
{"reqId":"SQbiNxXUFWEFUXMq17aY","level":3,"time":"2018-10-01T18:40:21+00:00","remoteAddr":"[redacted]","user":"--","app":"PHP","method":"GET","url":"\/ocs\/v2.php\/apps\/notifications\/api\/v2\/notifications","message":"You are using a fallback implementation of the intl extension. Installing the native one is highly recommended instead. at \/var\/www\/html\/3rdparty\/patchwork\/utf8\/src\/Patchwork\/Utf8\/Bootup\/intl.php#18","userAgent":"Mozilla\/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko\/20100101 Firefox\/60.0","version":""}
{"reqId":"SSR9JrMcUelT9FkQPEoc","level":3,"time":"2018-10-01T18:40:21+00:00","remoteAddr":"[redacted]","user":"--","app":"PHP","method":"GET","url":"\/index.php","message":"You are using a fallback implementation of the intl extension. Installing the native one is highly recommended instead. at \/var\/www\/html\/3rdparty\/patchwork\/utf8\/src\/Patchwork\/Utf8\/Bootup\/intl.php#18","userAgent":"Mozilla\/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko\/20100101 Firefox\/60.0","version":""}
{"reqId":"I23TTaYi0zcxuo4du9pM","level":3,"time":"2018-10-01T18:40:24+00:00","remoteAddr":"[redacted]","user":"--","app":"PHP","method":"GET","url":"\/ocs\/v2.php\/apps\/notifications\/api\/v2\/notifications","message":"You are using a fallback implementation of the intl extension. Installing the native one is highly recommended instead. at \/var\/www\/html\/3rdparty\/patchwork\/utf8\/src\/Patchwork\/Utf8\/Bootup\/intl.php#18","userAgent":"Mozilla\/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko\/20100101 Firefox\/60.0","version":""}
{"reqId":"ni6dWlGDCtgg6SRwSuXH","level":3,"time":"2018-10-01T18:40:24+00:00","remoteAddr":"[redacted]","user":"--","app":"PHP","method":"GET","url":"\/index.php","message":"You are using a fallback implementation of the intl extension. Installing the native one is highly recommended instead. at \/var\/www\/html\/3rdparty\/patchwork\/utf8\/src\/Patchwork\/Utf8\/Bootup\/intl.php#18","userAgent":"Mozilla\/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko\/20100101 Firefox\/60.0","version":""}
{"reqId":"an0EHnboo7rEylXx16zk","level":3,"time":"2018-10-01T18:40:51+00:00","remoteAddr":"[redacted]","user":"--","app":"PHP","method":"GET","url":"\/ocs\/v2.php\/apps\/notifications\/api\/v2\/notifications","message":"You are using a fallback implementation of the intl extension. Installing the native one is highly recommended instead. at \/var\/www\/html\/3rdparty\/patchwork\/utf8\/src\/Patchwork\/Utf8\/Bootup\/intl.php#18","userAgent":"Mozilla\/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko\/20100101 Firefox\/60.0","version":""}
{"reqId":"zOvmLOJyiCa7wzWRQb4t","level":3,"time":"2018-10-01T18:40:51+00:00","remoteAddr":"[redacted]","user":"--","app":"PHP","method":"GET","url":"\/index.php","message":"You are using a fallback implementation of the intl extension. Installing the native one is highly recommended instead. at \/var\/www\/html\/3rdparty\/patchwork\/utf8\/src\/Patchwork\/Utf8\/Bootup\/intl.php#18","userAgent":"Mozilla\/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko\/20100101 Firefox\/60.0","version":""}

Browser log


Browser log
Nothing. The browser does not have to be open for this issue to occur.

bug

Most helpful comment

Taking a look at my old logs, the messages stopped appearing after 2018-10-09. Whatever this was, it might have been (inadvertently?) fixed in an app or Nextcloud update.

I do not currently have a mimetypemapping.json file, nor is there one in any of the backup folders. However, I'm 100% sure I've never created one manually. So unless it's possible that at one point, one app (or Nextcloud itself) added/edited this file, and then later deleted it, my errors must have been caused by something else.

Either way, for now, for me, the issue appears to be gone. If noone else has had this problem since then, I don't mind if this gets closed. (I'll reopen the issue should it occur again.)

All 13 comments

GitMate.io thinks possibly related issues are https://github.com/nextcloud/server/issues/6898 (Invalid argument supplied for foreach() JSCombiner.php#107), https://github.com/nextcloud/server/issues/7677 (error: Invalid argument supplied for foreach() (ver:12.0.4.3)), https://github.com/nextcloud/server/issues/10432 (Invalid argument supplied for foreach() at /apps/files/lib/Controller/ViewController.php), https://github.com/nextcloud/server/issues/9403 (Dozens of Amazon S3 Errors in Log: PHP Invalid argument foreach() at AmazonS3.php#295 ), and https://github.com/nextcloud/server/issues/7156 (LDAP Invalid private key after password reset).

I see the same message, except it ends with "/lib/private/Installer.php#404". NC version 13.0.7 with Redis configured as cache, and updater set to Production channel.

Only recently in view "logging" I see the similar message at irregular intervals:
Error PHP Invalid argument supplied for foreach() at /var/www/nextcloud/lib/private/Installer.php#388

NC Version: 14.0.4.2
Apache/2.4.25-3+deb9u6 amd64
PHP Version: 7.0.30
mysql MariaDB Version: 10.1.37

As a qualifier, I don't really know what I'm talking about, but I can try to read and perform pattern recognition.

I'm looking around for my perennial log jamming/filling error messages and I have the same pattern. I seem to have had this for the last 3 or more upgrades to my Nextcloud instance. It could be longer but I was too busy with other things to look at my log reports back then.
Invalid argument supplied for foreach() at <NextCloud_path>/lib/private/Files/Type/Detection.php#
the numbers after the final hash are 104, 107, and 149. Theirs soooo many repeats of this every second that I wonder what performance I'm losing at all times to this weird error.

I'm in a Ubuntu 18.04 LTS server fully maintained, my Nextcloud is 15.0.4 (stable), I'm in Apache 2.4.29, PHP 7.2.15, MySQL 5.7.25.

I see it was raised long ago in #6898 and maybe solved by @MorrisJobke @rullzer and @skjnldsv in #7109 or #7118? ...but it seems unsolved again.

I forgot to add a log file... _so rude_

shortened & cleaned Log File

nextcloud.log

You have an mimetypemapping.json file with invalid syntax.

You have an mimetypemapping.json file with invalid syntax.

Good lord! @kesselb Is there a medical solution for that ailment?

My current config/ folder and the 15.0.2.0 backups mimetypemapping.json files has this in it:

{
    "dcm": [
        "application/dicom"
    ],
    "km": [
        "application/km"
    ]
    "gpx": [
        "application/gpx+xml"
    ]
}

My 14.0.4.2 and 14.0.6.0 backups had this:

{
    "dcm": [
        "application/dicom"
    ],
    "km": [
        "application/km"
    ]
}

None of that means anything to me.

You have two options:

  1. Delete the file
  2. Fix the syntax (json is very strict. you are missing a ,)
{
  "dcm":[
    "application/dicom"
  ],
  "km":[
    "application/km"
  ],
  "gpx":[
    "application/gpx+xml"
  ]
}

@kesselb I added the comma and wow, such a difference! Thanks, you fixed my problem!

Shall we close then?

I dont think so. The mimetypemapping.json issue is not related to the initial issue here. Sure Invalid argument supplied for foreach() is the same but mimetype has nothing todo with Installer.php.

Taking a look at my old logs, the messages stopped appearing after 2018-10-09. Whatever this was, it might have been (inadvertently?) fixed in an app or Nextcloud update.

I do not currently have a mimetypemapping.json file, nor is there one in any of the backup folders. However, I'm 100% sure I've never created one manually. So unless it's possible that at one point, one app (or Nextcloud itself) added/edited this file, and then later deleted it, my errors must have been caused by something else.

Either way, for now, for me, the issue appears to be gone. If noone else has had this problem since then, I don't mind if this gets closed. (I'll reopen the issue should it occur again.)

That's good news! Keep us updated! :+1:

I just saw this when logged into my admin account. It only seems to have appeared once and last appeared 16 days ago according to the log timestamp. I don't notice any issues with data or service so I guess things are "ok".

Was this page helpful?
0 / 5 - 0 ratings