PHP Error: ZipArchive::getStream(): Invalid or uninitialized Zip object at /var/www/nextcloud/lib/private/Archive/ZIP.php#154

Hi everybody,

Looking at the Administration Logging utility I’m encountering the following error triggered by PHP:

Error: ZipArchive::getStream(): Invalid or uninitialized Zip object at /var/www/nextcloud/lib/private/Archive/ZIP.php#154

Unfortunately I cannot say how to reproduce it but it happens rather often.
Please, can anybody tell me to what it’s due and if I should worry about it?

Thanks in advance for any help!

Nextcloud version: 22.2.3
Operating_system: Debian GNU/Linux 11 (bullseye)
Server version: Apache/2.4.51
PHP version: PHP 7.4.25 (cli)

Hi,

Same here, on this :

~  httpd -v
Server version: Apache/2.4.37 (centos)
Server built:   Nov 12 2021 04:57:27
 ~  php -v
PHP 7.4.26 (cli) (built: Nov 16 2021 15:31:30) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.26, Copyright (c), by Zend Technologies

Errors :

{"reqId":"YZitekrQ-LjU1XKBj9bMVAAA1xM","level":3,"time":"2021-11-20T08:10:34+00:00","remoteAddr":"xx.xx.xx.xx","user":"Aleks05","app":"PHP","method":"GET","url":"/index.php/core/preview?fileId=3602&x=32&y=32","message":"ZipArchive::getStream(): Invalid or uninitialized Zip object at /var/www/html/nextcloud/lib/private/Archive/ZIP.php#154","userAgent":"Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0","version":"22.2.3.0","exception":{"Exception":"Error","Message":"ZipArchive::getStream(): Invalid or uninitialized Zip object at /var/www/html/nextcloud/lib/private/Archive/ZIP.php#154","Code":0,"Trace":[{"function":"onError","class":"OC\\Log\\ErrorHandler","type":"::"},{"file":"/var/www/html/nextcloud/lib/private/Archive/ZIP.php","line":154,"function":"getStream","class":"ZipArchive","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Preview/Bundled.php","line":42,"function":"extractFile","class":"OC\\Archive\\ZIP","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Preview/OpenDocument.php","line":44,"function":"extractThumbnail","class":"OC\\Preview\\Bundled","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Preview/GeneratorHelper.php","line":62,"function":"getThumbnail","class":"OC\\Preview\\OpenDocument","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Preview/Generator.php","line":245,"function":"getThumbnail","class":"OC\\Preview\\GeneratorHelper","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Preview/Generator.php","line":140,"function":"getMaxPreview","class":"OC\\Preview\\Generator","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Preview/Generator.php","line":109,"function":"generatePreviews","class":"OC\\Preview\\Generator","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/PreviewManager.php","line":189,"function":"getPreview","class":"OC\\Preview\\Generator","type":"->"},{"file":"/var/www/html/nextcloud/core/Controller/PreviewController.php","line":169,"function":"getPreview","class":"OC\\PreviewManager","type":"->"},{"file":"/var/www/html/nextcloud/core/Controller/PreviewController.php","line":142,"function":"fetchPreview","class":"OC\\Core\\Controller\\PreviewController","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":217,"function":"getPreviewByFileId","class":"OC\\Core\\Controller\\PreviewController","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":126,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/App.php","line":156,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Route/Router.php","line":302,"function":"main","class":"OC\\AppFramework\\App","type":"::"},{"file":"/var/www/html/nextcloud/lib/base.php","line":1006,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"/var/www/html/nextcloud/index.php","line":36,"function":"handleRequest","class":"OC","type":"::"}],"File":"/var/www/html/nextcloud/lib/private/Log/ErrorHandler.php","Line":92,"CustomMessage":"--"},"id":"6198adc5f0a14"}
[PHP] Error: ZipArchive::getStream(): Invalid or uninitialized Zip object at /var/www/html/nextcloud/lib/private/Archive/ZIP.php#154

GET /index.php/core/preview?fileId=3602&x=32&y=32
from xx.xx.xx.xx by maystor at 2021-11-20T08:10:34+00:00

Does anyone know what this error is due to?

I’m getting the same problem with 23.0.2. I’m including the full information below. Could you help me debug it? Apparently something’s wrong with file with id=12061, but I don’t know how to investigate further.

{
  "reqId": "NaFBBcn3XLmcYTO9XL76",
  "level": 3,
  "time": "2022-02-22T09:23:11+00:00",
  "remoteAddr": "xxxxxxxxxxxx",
  "user": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "app": "PHP",
  "method": "GET",
  "url": "/core/preview?fileId=12061&x=32&y=32",
  "message": "ZipArchive::getStream(): Invalid or uninitialized Zip object at /var/www/nextcloud.digigov.grnet.gr/nextcloud/lib/private/Archive/ZIP.php#154",
  "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36",
  "version": "23.0.2.1",
  "exception": {
    "Exception": "Error",
    "Message": "ZipArchive::getStream(): Invalid or uninitialized Zip object at /var/www/nextcloud.digigov.grnet.gr/nextcloud/lib/private/Archive/ZIP.php#154",
    "Code": 0,
    "Trace": [
      {
        "function": "onError",
        "class": "OC\\Log\\ErrorHandler",
        "type": "::"
      },
      {
        "file": "/var/www/nextcloud.digigov.grnet.gr/nextcloud/lib/private/Archive/ZIP.php",
        "line": 154,
        "function": "getStream",
        "class": "ZipArchive",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud.digigov.grnet.gr/nextcloud/lib/private/Preview/Bundled.php",
        "line": 42,
        "function": "extractFile",
        "class": "OC\\Archive\\ZIP",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud.digigov.grnet.gr/nextcloud/lib/private/Preview/OpenDocument.php",
        "line": 44,
        "function": "extractThumbnail",
        "class": "OC\\Preview\\Bundled",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud.digigov.grnet.gr/nextcloud/lib/private/Preview/GeneratorHelper.php",
        "line": 62,
        "function": "getThumbnail",
        "class": "OC\\Preview\\OpenDocument",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud.digigov.grnet.gr/nextcloud/lib/private/Preview/Generator.php",
        "line": 245,
        "function": "getThumbnail",
        "class": "OC\\Preview\\GeneratorHelper",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud.digigov.grnet.gr/nextcloud/lib/private/Preview/Generator.php",
        "line": 140,
        "function": "getMaxPreview",
        "class": "OC\\Preview\\Generator",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud.digigov.grnet.gr/nextcloud/lib/private/Preview/Generator.php",
        "line": 109,
        "function": "generatePreviews",
        "class": "OC\\Preview\\Generator",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud.digigov.grnet.gr/nextcloud/lib/private/PreviewManager.php",
        "line": 212,
        "function": "getPreview",
        "class": "OC\\Preview\\Generator",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud.digigov.grnet.gr/nextcloud/core/Controller/PreviewController.php",
        "line": 169,
        "function": "getPreview",
        "class": "OC\\PreviewManager",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud.digigov.grnet.gr/nextcloud/core/Controller/PreviewController.php",
        "line": 142,
        "function": "fetchPreview",
        "class": "OC\\Core\\Controller\\PreviewController",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud.digigov.grnet.gr/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 217,
        "function": "getPreviewByFileId",
        "class": "OC\\Core\\Controller\\PreviewController",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud.digigov.grnet.gr/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 126,
        "function": "executeController",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud.digigov.grnet.gr/nextcloud/lib/private/AppFramework/App.php",
        "line": 157,
        "function": "dispatch",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud.digigov.grnet.gr/nextcloud/lib/private/Route/Router.php",
        "line": 302,
        "function": "main",
        "class": "OC\\AppFramework\\App",
        "type": "::"
      },
      {
        "file": "/var/www/nextcloud.digigov.grnet.gr/nextcloud/lib/base.php",
        "line": 1006,
        "function": "match",
        "class": "OC\\Route\\Router",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud.digigov.grnet.gr/nextcloud/index.php",
        "line": 36,
        "function": "handleRequest",
        "class": "OC",
        "type": "::"
      }
    ],
    "File": "/var/www/nextcloud.digigov.grnet.gr/nextcloud/lib/private/Log/ErrorHandler.php",
    "Line": 92,
    "CustomMessage": "--"
  },
  "id": "6214ac0e92052"
}

Actually I have the same error for many fileIds and for many users.

I think it is a bug. Read this issue.