mirror of
https://github.com/projectsend/projectsend.git
synced 2026-09-12 06:48:55 +00:00
d6fd5a917d
Uploads live outside the web root, so PHP authorizes every download and then hands the file to the web server with a header naming it. Four routes decided that for themselves and all four hard-coded nginx's spelling. On Apache or LiteSpeed nothing acts on the header, so the empty body PHP sent goes to the visitor: files upload fine, thumbnails are broken images, and downloads arrive as 0 bytes, with every other page working. Reported as #1765 from an Apache 2.4 install, and before that as #1266, #1215, #870 and #1271. It is also a regression from v1, which had a download_method setting -- php, apache_xsendfile, litespeed, nginx_xaccel -- defaulting to php. v1 therefore worked on any server out of the box and v2 did not, and a v1 Apache user migrating lost every download with nothing to tell them why. So the four sites now go through one FileDelivery, and it picks: auto (default) nginx when SERVER_SOFTWARE says nginx, else php nginx X-Accel-Redirect, a URL path via the internal location xsendfile X-Sendfile, an absolute path (Apache mod_xsendfile, LiteSpeed) php BinaryFileResponse Defaulting to auto rather than nginx is the point of the change: a default that assumes nginx leaves an Apache install exactly as broken as it is today until somebody reads INSTALL.md. Slow beats empty. Auto never picks xsendfile, even where the module is loaded. mod_xsendfile also needs XSendFilePath to allow the storage directory, which cannot be seen from here, and choosing it on the strength of the module being present would trade a silent failure an administrator can diagnose from the dashboard for one nobody can. BinaryFileResponse rather than a readfile loop because it answers Range requests. nginx does that itself on the fast path, so hand-rolling it would have broken seeking through a video on exactly the installations this fallback exists for. Verified end to end: 206 with the right Content-Range through the live stack. Two guards. Every method checks the path cannot climb out of the storage area -- nginx resolves `..` in the URL it is handed as happily as PHP would -- and the two methods that hand over a filesystem path resolve it and prove it lands inside the root. Callers pass paths from rows they just authorized, so this is a backstop; it is here because the cost of being wrong once is handing over any file the web server can read. The dashboard's System panel names the method, with a warning icon and a dialog when PHP is doing the sending: what is happening, what it costs (one worker held for the whole of each download, so a few large simultaneous ones can occupy every worker while the processor sits idle), why it is set that way, and the three ways out. Written to be accurate rather than reassuring -- nothing is broken, it does not scale -- and the notice stays even when php was chosen deliberately, because the trade-off is the same either way. /system/settings/downloads repeats it, which is where somebody coming from v1 goes looking for the dropdown. An environment variable rather than a stored setting: it describes the server this installation runs on, not a preference, and a value in the database travels to a different server in a restore and is wrong there. Read only in config/projectsend.php, so config:cache cannot blank it. The suite pins itself to nginx. Left at auto it would detect no server at all, fall back to php, and quietly retire the coverage of the mechanism most installations actually use.
42 lines
1.7 KiB
XML
42 lines
1.7 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
|
|
bootstrap="vendor/autoload.php"
|
|
colors="true"
|
|
>
|
|
<testsuites>
|
|
<testsuite name="Unit">
|
|
<directory>tests/Unit</directory>
|
|
</testsuite>
|
|
<testsuite name="Feature">
|
|
<directory>tests/Feature</directory>
|
|
</testsuite>
|
|
</testsuites>
|
|
<source>
|
|
<include>
|
|
<directory>app</directory>
|
|
</include>
|
|
</source>
|
|
<php>
|
|
<env name="APP_ENV" value="testing"/>
|
|
<env name="APP_MAINTENANCE_DRIVER" value="file"/>
|
|
<env name="BCRYPT_ROUNDS" value="4"/>
|
|
<env name="CACHE_STORE" value="array"/>
|
|
<env name="DB_CONNECTION" value="sqlite"/>
|
|
<env name="DB_DATABASE" value=":memory:"/>
|
|
<env name="MAIL_MAILER" value="array"/>
|
|
<env name="PROJECTSEND_EDITION" value="community"/>
|
|
<!-- The suite describes the nginx fast path, which is what Docker
|
|
and every documented install runs. Left at "auto" the tests
|
|
would detect no web server at all and fall back to PHP
|
|
streaming, quietly retiring the coverage of the mechanism
|
|
most installations actually use. Tests for the other methods
|
|
set the config themselves. -->
|
|
<env name="PROJECTSEND_FILE_DELIVERY" value="nginx"/>
|
|
<env name="PULSE_ENABLED" value="false"/>
|
|
<env name="QUEUE_CONNECTION" value="sync"/>
|
|
<env name="SESSION_DRIVER" value="array"/>
|
|
<env name="TELESCOPE_ENABLED" value="false"/>
|
|
</php>
|
|
</phpunit>
|