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

TypeError: Argument 2 passed to OC\Streamer::__construct() must be of the type integer, float given, called in /config/www/nextcloud/lib/private/legacy/files.php on line 166 #15117

Closed
theincredibleman opened this issue Apr 15, 2019 · 19 comments
Labels
2. developing Work in progress bug

Comments

@theincredibleman
Copy link

Steps to reproduce

  1. Try to download 2 files (file 1 is 2,8GB, file 2 just a few KB) at the same time via share link or logged in as admin.
  2. Throws error right away.
  3. Does not throw error when 1 file is downloaded at a time. System does not zip the file.
  4. Problem does not occur when downloading a smaller (1GB) file together with another file, system creates a ZIP and files are downloaded.

I am wondering if it is possible to turn off the ZIP function when multiple files are downloaded, and whether that would resolve the issue.

Expected behaviour

Files should both be downloaded

Actual behaviour

Error is thrown.

Server configuration

Alpine 3.9 in Docker

Web server:
NGINX

Database:
MariaDB

PHP version:
7.2.13

Nextcloud version: (see Nextcloud admin page)
15.0.6

Updated from an older Nextcloud/ownCloud or fresh install:
Fresh install

Where did you install Nextcloud from:
https://hub.docker.com/r/linuxserver/nextcloud/

@theincredibleman theincredibleman added 0. Needs triage Pending check for reproducibility or if it fits our roadmap bug labels Apr 15, 2019
@RailsViceRoads
Copy link

Same behaviour on my system. Try download a directory greater then (approx) 1GB will result in an error.

System
server version 16.0.5.1
php version 7.3.6
database type mysql
app files version 1.11.0
app files_rightclick version 0.15.1

Log

[index] Error: TypeError: Argument 2 passed to OC\Streamer::__construct() must be of the type int, float given, called in /rootdir/www/cloud.webspace.de/lib/private/legacy/files.php on line 166 at <>

  1. /rootdir/www/cloud.webspace.de/lib/private/legacy/files.php line 166
    OC\Streamer->__construct(OC\AppFramework\Http\Request {}, 2636124555, 2677)
  2. /rootdir/www/cloud.webspace.de/apps/files/ajax/download.php line 64
    OC_Files::get("/DirOne", "DirTwo", {head: false})
  3. /rootdir/www/cloud.webspace.de/lib/private/Route/Route.php line 155
    undefinedundefinedrequire_once("/rootdir ... p")
  4. <>
    OC\Route\Route->OC\Route{closure}("*** sensitive parameters replaced ***")
  5. /rootdir/www/cloud.webspace.de/lib/private/Route/Router.php line 297
    undefinedundefinedcall_user_func(Closure {}, {_route: "files_ajax_download"})
  6. /rootdir/www/cloud.webspace.de/lib/base.php line 975
    OC\Route\Router->match("/apps/files/ajax/download.php")
  7. /rootdir/www/cloud.webspace.de/index.php line 42
    OC::handleRequest()

GET /index.php/apps/files/ajax/download.php?dir=%2FPr%C3%A4sident&files=Alt-1.%20Vorsitzender&downloadStartSecret=tfh2iarlrgm
from 79.245.161.234 by user at 2019-10-09T19:07:05+00:00

@saschabrockel
Copy link

saschabrockel commented Oct 23, 2019

Same behaviour on my system too. Happens if I want to download more than 2 GB per download with multiple files. Download a single file with a big size is no problem. I tried it with 42 GB.

System
docker version of NextCloud
server version 16.0.5.1
php version 7.3.9
database type mysql 10.3.17

Log
[index] Error: TypeError: Argument 2 passed to OC\Streamer::__construct() must be of the type int, float given, called in /data/nextcloud/lib/private/legacy/files.php on line 166 at <>

  1. /data/nextcloud/lib/private/legacy/files.php line 166
    OC\Streamer->__construct(OC\AppFramework\Http\Request {}, 5831685788, 329)
  2. /data/nextcloud/apps/files/ajax/download.php line 64
    OC_Files::get("/Universität/Ba ... )", "IT-Management", {head: false})
  3. /data/nextcloud/lib/private/Route/Route.php line 155
    undefinedundefinedrequire_once("/data/nextcloud ... p")
  4. <>
    OC\Route\Route->OC\Route{closure}("*** sensitive parameters replaced ***")
  5. /data/nextcloud/lib/private/Route/Router.php line 297
    undefinedundefinedcall_user_func(Closure {}, {_route: "files_ajax_download"})
  6. /data/nextcloud/lib/base.php line 975
    OC\Route\Router->match("/apps/files/ajax/download.php")
  7. /data/nextcloud/index.php line 42
    OC::handleRequest()

GET /index.php/apps/files/ajax/download.php?dir=%2FUniversit%C3%A4t%2FBachelor%2F5.%20Semester%20(WS%202018-19)&files=IT-Management%20(Ahlemann)&downloadStartSecret=he6g716gbob
from 132.252.197.182 by user at 2019-10-23T10:50:41+00:00

@nfp0
Copy link

nfp0 commented Dec 28, 2019

Exact same thing happens to me too.

Nextcloud 16.0.5 SNAP
Apache 2.4
PHP 7.2
MySQL 5.7
Redis 4.0

@dpertin
Copy link

dpertin commented Mar 1, 2020

Same issue observed.

System

Nextcloud 18.0.1
PHP:

Version: 7.4.3
Memory Limit: 512 MB
Max Execution Time: 3600
Upload max size: 2 MB

Database :

Type: pgsql
Version: PostgreSQL 12.1 on armv7l-unknown-linux-gnueabihf, compiled by armv7l-unknown-linux-gnueabihf-gcc (GCC) 8.3.0, 32-bit
Size: 33 MB

Log

{"reqId":"mFHQwBnn4doFZXwCb9bC","level":3,"time":"2020-03-01T10:36:46+00:00","remoteAddr":"192.168.1.100","user":"dim","app":"index","method":"GET","url":"/index.php/apps/files/ajax/download.php?dir=%2FInstantUpload%2FCamera&files=%5B%2220200131_125453.jpg%22%2C%2220200131_105724.mp4%22%2C%2220200131_110441.jpg%22%2C%2220200131_104941.mp4%22%2C%2220200130_122239.mp4%22%2C%2220200131_105842.mp4%22%2C%2220200131_104313.mp4%22%2C%2220200130_121830.mp4%22%2C%2220200128_150025.mp4%22%2C%2220200130_121323.mp4%22%2C%2220200131_125816.jpg%22%2C%2220200131_112309.jpg%22%2C%2220200131_112313.jpg%22%2C%2220200130_121401.mp4%22%2C%2220200129_132052.jpg%22%2C%2220200131_105141.mp4%22%2C%2220200131_112257.jpg%22%2C%2220200131_105600.mp4%22%2C%2220200130_122311.mp4%22%2C%2220200131_104439.mp4%22%2C%2220200131_110519.jpg%22%2C%2220200131_110515.jpg%22%5D&downloadStartSecret=t1h1q2z32z","message":{"Exception":"TypeError","Message":"Argument 2 passed to OC\\Streamer::__construct() must be of the type int, float given, called in /usr/share/webapps/nextcloud/lib/private/legacy/files.php on line 167","Code":0,"Trace":[{"file":"/usr/share/webapps/nextcloud/lib/private/legacy/files.php","line":167,"function":"__construct","class":"OC\\Streamer","type":"->"},{"file":"/usr/share/webapps/nextcloud/apps/files/ajax/download.php","line":64,"function":"get","class":"OC_Files","type":"::"},{"file":"/usr/share/webapps/nextcloud/lib/private/Route/Route.php","line":155,"args":["/usr/share/webapps/nextcloud/apps/files/ajax/download.php"],"function":"require_once"},{"function":"OC\\Route\\{closure}","class":"OC\\Route\\Route","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/usr/share/webapps/nextcloud/lib/private/Route/Router.php","line":299,"function":"call_user_func"},{"file":"/usr/share/webapps/nextcloud/lib/base.php","line":1008,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"/usr/share/webapps/nextcloud/index.php","line":38,"function":"handleRequest","class":"OC","type":"::"}],"File":"/usr/share/webapps/nextcloud/lib/private/Streamer.php","Line":55,"CustomMessage":"--"},"userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:73.0) Gecko/20100101 Firefox/73.0","version":"18.0.1.3","id":"5e5b9053a9d72"}

@atoav
Copy link

atoav commented Mar 7, 2020

I have a similar error when sharing a folder that contains eight 2 GB files and one 882 MB files. Nextcloud: 16.0.5

Error Log

(paths and adresses censored for privacy reasons)

[index] Error: TypeError: Argument 2 passed to OC\Streamer::__construct() must be of the type integer, float given, called in █████████████/lib/private/legacy/files.php on line 166 at <<closure>>

0. █████████████/lib/private/legacy/files.php line 166
   OC\Streamer->__construct(OC\AppFramework\Http\Request {}, 17680871125, 10)
1. █████████████/apps/files_sharing/lib/Controller/ShareController.php line 605
   OC_Files::get("/HR3", "AE", {head: false})
2. █████████████/lib/private/AppFramework/Http/Dispatcher.php line 166
   OCA\Files_Sharing\Controller\ShareController->downloadShare("wCqm29mARgn4TTz", null, "", "")
3. █████████████/lib/private/AppFramework/Http/Dispatcher.php line 99
   OC\AppFramework\Http\Dispatcher->executeController(OCA\Files_Sharin ... {}, "downloadShare")
4. █████████████/lib/private/AppFramework/App.php line 126
   OC\AppFramework\Http\Dispatcher->dispatch(OCA\Files_Sharin ... {}, "downloadShare")
5. █████████████/lib/private/AppFramework/Routing/RouteActionHandler.php line 47
   OC\AppFramework\App::main("OCA\\Files_Shar ... r", "downloadShare", OC\AppFramework\ ... {}, {token: "wCqm29m ... "})
6. <<closure>>
   OC\AppFramework\Routing\RouteActionHandler->__invoke({token: "wCqm29m ... "})
7. █████████████/lib/private/Route/Router.php line 297
   undefinedundefinedcall_user_func(OC\AppFramework\ ... {}, {token: "wCqm29m ... "})
8. █████████████/lib/base.php line 975
   OC\Route\Router->match("/s/wCqm29mARgn4TTz/download")
9. █████████████/index.php line 42
   OC::handleRequest()

GET /index.php/s/wCqm29mARgn4TTz/download
from ████:██:███:████:████:████:████:████ at 2020-03-07T11:24:41+00:00

@manches
Copy link

manches commented Apr 6, 2020

Same occured:
{"reqId":"HrbLX7O275Q5yJmqjccC","level":3,"time":"April 06, 2020 15:44:31","remoteAddr":"XXXXXXXXXX","user":"--","app":"index","method":"GET","url":"/index.php/s/XXXXX/download","message":{"Exception":"Exception","Message":"Argument 2 passed to OC\\Streamer::__construct() must be of the type int, float given, called in /var/www/nextcloud/lib/private/legacy/files.php on line 167","Code":0,"Trace":[{"file":"/var/www/nextcloud/lib/private/AppFramework/App.php","line":125,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Files_Sharing\\Controller\\ShareController"},"downloadShare"]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Routing/RouteActionHandler.php","line":47,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\Files_Sharing\\Controller\\ShareController","downloadShare",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"token":"XXXXXXX","_route":"files_sharing.sharecontroller.downloadShare"}]},{"function":"__invoke","class":"OC\\AppFramework\\Routing\\RouteActionHandler","type":"->","args":[{"token":"XXXXXXXXXX","_route":"files_sharing.sharecontroller.downloadShare"}]},{"file":"/var/www/nextcloud/lib/private/Route/Router.php","line":299,"function":"call_user_func","args":[{"__class__":"OC\\AppFramework\\Routing\\RouteActionHandler"},{"token":"XXXXXXX","_route":"files_sharing.sharecontroller.downloadShare"}]},{"file":"/var/www/nextcloud/lib/base.php","line":1008,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/s/XXXXXXXXXX/download"]},{"file":"/var/www/nextcloud/index.php","line":38,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","Line":109,"Previous":{"Exception":"TypeError","Message":"Argument 2 passed to OC\\Streamer::__construct() must be of the type int, float given, called in /var/www/nextcloud/lib/private/legacy/files.php on line 167","Code":0,"Trace":[{"file":"/var/www/nextcloud/lib/private/legacy/files.php","line":167,"function":"__construct","class":"OC\\Streamer","type":"->","args":[{"__class__":"OC\\AppFramework\\Http\\Request"},15653449121,14074]},{"file":"/var/www/nextcloud/apps/files_sharing/lib/Controller/ShareController.php","line":626,"function":"get","class":"OC_Files","type":"::","args":["/PENS/Ventin","PEN 1",{"head":false}]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":170,"function":"downloadShare","class":"OCA\\Files_Sharing\\Controller\\ShareController","type":"->","args":["XXXXXXXX",null,"",""]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":99,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Files_Sharing\\Controller\\ShareController"},"downloadShare"]},{"file":"/var/www/nextcloud/lib/private/AppFramework/App.php","line":125,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Files_Sharing\\Controller\\ShareController"},"downloadShare"]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Routing/RouteActionHandler.php","line":47,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\Files_Sharing\\Controller\\ShareController","downloadShare",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"token":"XXXXXXXX","_route":"files_sharing.sharecontroller.downloadShare"}]},{"function":"__invoke","class":"OC\\AppFramework\\Routing\\RouteActionHandler","type":"->","args":[{"token":"XXXXXXXXXXXXX","_route":"files_sharing.sharecontroller.downloadShare"}]},{"file":"/var/www/nextcloud/lib/private/Route/Router.php","line":299,"function":"call_user_func","args":[{"__class__":"OC\\AppFramework\\Routing\\RouteActionHandler"},{"token":"XXXXXXXXXXX","_route":"files_sharing.sharecontroller.downloadShare"}]},{"file":"/var/www/nextcloud/lib/base.php","line":1008,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/s/XXXXXXXXXX/download"]},{"file":"/var/www/nextcloud/index.php","line":38,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/nextcloud/lib/private/Streamer.php","Line":55},"CustomMessage":"--"},"userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36","version":"18.0.1.3"}

System
server version 18.0.1.3
php version 7.3.11
database type mysql Ver 15.1 Distrib 10.3.18-MariaDB

@RomainTT
Copy link

I have the same issue. Is there any workaround or patch for this yet ?

System
server version 18.0.3
php version 7.3.13
database sqlite3

@trev-dev
Copy link

File uploading/downloading is broken in both directions for me and generally always has been for anything over a GB.

Running nextcloud on a Pi 4, on a docker with PHP limits set to 20Gb and 4Gb of RAM and swap.
Argument 2 passed to OC\Streamer::__construct() must be of the type int, float given, called in /data/nextcloud/lib/private/legacy/files.php on line 167

The user experience for anyone receiving the file:
The User Experience

@PStewardYUL
Copy link

Same issue:
Exception: Argument 2 passed to OC\Streamer::__construct() must be of the type int, float given, called in /var/www/nextcloud/lib/private/legacy/files.php on line 167

NextCloudPi version | v1.28.1

@JonasDaWi
Copy link

Same issue when trying to download >2GB folders with .zip generation

@Wolfgang1966
Copy link

Wolfgang1966 commented Sep 30, 2020

The fix seems to be a one-liner basically:

In lib/private/Streamer.php

exchange
public function __construct(IRequest $request, int $size, int $numberOfFiles)

public function __construct(IRequest $request, float $size, int $numberOfFiles)

(line 56 in Nextcloud 19.0.3).

Didn't test that in depth, but at least got rid of the error message. The reason most likely is that PHP implicitely converts int to float as soon as a number overflow is about to occur. See https://www.php.net/manual/de/language.types.integer.php

@j-be
Copy link

j-be commented Dec 7, 2020

Hit by the same issue on Nextcloud 20.0.2.2 and PHP 7.4 (Ubuntu 20.04).

@Wolfgang1966 your fix works on my side, thank you very much for sharing that.

@Wolfgang1966
Copy link

Please be aware that the fix improves the situation for sizes between 2GB and 4 GB. Above that it will result in corrupted ZIPs.

So now I patched the constructor this way:

            if ($size > 0 && $size < 4 * 1000 * 1000 * 1000 && $numberOfFiles < 65536) {
                    $this->streamerInstance = new ZipStreamer(['zip64' => false]);
            } else {
                    $this->streamerInstance = new TarStreamer();
            }

Above 4GB it will always create a tar archive. It may be less comfortable on Windows, but at least the archive is valid and there are enough tools out there which are able to handle them.

@j-be
Copy link

j-be commented Dec 10, 2020

@Wolfgang1966 Thanks again!

I had closer look at the constructor as implemented (https://github.com/nextcloud/server/blob/master/lib/private/Streamer.php#L84) and I'm having a hard time understanding the train of thought there. It has been a while since I used PHP, but I read this as:

  • if below 4GB use Zip32
  • if above 4GB and $request->isUserAgent($this->preferTarFor) (for whatever that means) use TAR
  • if above 4GB and not $request->isUserAgent($this->preferTarFor) do not use Zip64 on 32Bit architectutres (which I guess leads to the mentioned corrupted archives) and Zip64 on anything else

I see the point of using Zip32 as default whenever possible, as it is most likely the most widely supported among the three contenders here. What I don't understand is:

  • Why is $request->isUserAgent($this->preferTarFor) only respected if the file is larger then 4GB? Why can't I always have TAR if I explicitly request it?
  • Why doesn't it use Zip64 on 32Bit Architectures? I for one still use an ARMv7 32Bit board as Server for Nextcloud, which is plenty for personal use.

Shouldn't it be something like (do NOT use the code below as is unless you want to break your Nextcloud!):

// Give me TAR no matter what if I say I want that
if ($request->isUserAgent($this->preferTarFor)) {
    $this->streamerInstance = new TarStreamer();
// Zip32 as default if size and numberOfFiles allow it
} elseif ($size > 0 && $size < 4 * 1000 * 1000 * 1000 && $numberOfFiles < 65536) {
    $this->streamerInstance = new ZipStreamer(['zip64' => false]);
// Depending on Zip64 support - not sure how one would determine that
} else {
    if (isZip64Supported) {
        $this->streamerInstance = new ZipStreamer(['zip64' => true]);
    } else {
        $this->streamerInstance = new TarStreamer();
    }
}

@szaimen
Copy link
Contributor

szaimen commented Jun 18, 2021

Hi, do you mind creating a PR with your patch for further discussion?
Thank you!

@j-be
Copy link

j-be commented Jun 18, 2021

@szaimen Assuming your comment was referring to my suggestion above: Done, see #27562.

I'd like to add that I'm still successfully running the fix proposed by @Wolfgang1966. I am using only Linux machines, and my Nextcloud is for personal use only. So TAR is no issue for me, I assume that is not true for most Windows users.

@szaimen szaimen added 2. developing Work in progress and removed 0. Needs triage Pending check for reproducibility or if it fits our roadmap needs info labels Jun 24, 2021
@MichaIng MichaIng linked a pull request Feb 26, 2022 that will close this issue
@lorenzo9uerra
Copy link

This issue is still relevant, I'm still getting this error when trying to download multiple GB of data and setting float instead of int in size seems to completely fix the problem

@Hightmar
Copy link

The fix seems to be a one-liner basically:

In lib/private/Streamer.php

exchange public function __construct(IRequest $request, int $size, int $numberOfFiles)

public function __construct(IRequest $request, float $size, int $numberOfFiles)

(line 56 in Nextcloud 19.0.3).

Didn't test that in depth, but at least got rid of the error message. The reason most likely is that PHP implicitely converts int to float as soon as a number overflow is about to occur. See https://www.php.net/manual/de/language.types.integer.php

Your answer is still valid with Nextcloud Hub II (23.0.3).
Thank you!

fwsmit added a commit to fwsmit/server that referenced this issue Jul 11, 2022
When a folder larger than ~2GB is downloaded, zip32 doesn't cut it.
Since zip64 doesn't work on 32-bit clients, fall back to generating a
tarball.

Fixes nextcloud#12422 and nextcloud#15117
fwsmit added a commit to fwsmit/server that referenced this issue Jul 11, 2022
When a folder larger than ~2GB is downloaded, zip32 doesn't cut it.
Since zip64 doesn't work on 32-bit clients, fall back to generating a
tarball.

Fixes nextcloud#12422 and nextcloud#15117

Signed-off-by: fwsmit <fw.smit01@gmail.com>
@szaimen
Copy link
Contributor

szaimen commented Jul 13, 2022

Closing due to nextcloud/documentation#9071

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2. developing Work in progress bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.