summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2023-01-12 16:05:03 +0100
committerCôme Chilliet <come.chilliet@nextcloud.com>2023-02-07 11:23:28 +0100
commite156f8339cec0ae97ed62344ce1f186600b6b909 (patch)
treedd874b1ccc2079184ace112445f235d33669f8b3
parent3885818ab67f941a54d8b186945399e55c9ac6fe (diff)
downloadnextcloud-server-e156f8339cec0ae97ed62344ce1f186600b6b909.tar.gz
nextcloud-server-e156f8339cec0ae97ed62344ce1f186600b6b909.zip
Revert "remove 32-bit workarounds"
This reverts commit dd8774389e21b59c07882580356d51de018fe867. Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
-rw-r--r--lib/private/Files/Storage/Local.php13
-rw-r--r--lib/private/Setup.php7
-rw-r--r--lib/private/Streamer.php2
-rw-r--r--lib/private/legacy/OC_Response.php13
4 files changed, 31 insertions, 4 deletions
diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php
index b021d40d335..4b5154b207a 100644
--- a/lib/private/Files/Storage/Local.php
+++ b/lib/private/Files/Storage/Local.php
@@ -171,6 +171,11 @@ class Local extends \OC\Files\Storage\Common {
return false;
}
$statResult = @stat($fullPath);
+ if (PHP_INT_SIZE === 4 && $statResult && !$this->is_dir($path)) {
+ $filesize = $this->filesize($path);
+ $statResult['size'] = $filesize;
+ $statResult[7] = $filesize;
+ }
if (is_array($statResult)) {
$statResult['full_path'] = $fullPath;
}
@@ -242,6 +247,10 @@ class Local extends \OC\Files\Storage\Common {
return 0;
}
$fullPath = $this->getSourcePath($path);
+ if (PHP_INT_SIZE === 4) {
+ $helper = new \OC\LargeFileHelper;
+ return $helper->getFileSize($fullPath);
+ }
return filesize($fullPath);
}
@@ -263,6 +272,10 @@ class Local extends \OC\Files\Storage\Common {
if (!$this->file_exists($path)) {
return false;
}
+ if (PHP_INT_SIZE === 4) {
+ $helper = new \OC\LargeFileHelper();
+ return $helper->getFileMtime($fullPath);
+ }
return filemtime($fullPath);
}
diff --git a/lib/private/Setup.php b/lib/private/Setup.php
index e84a5e4987a..dc59eacbf57 100644
--- a/lib/private/Setup.php
+++ b/lib/private/Setup.php
@@ -247,13 +247,14 @@ class Setup {
];
}
- if (PHP_INT_SIZE < 8) {
+ if ($this->iniWrapper->getString('open_basedir') !== '' && PHP_INT_SIZE === 4) {
$errors[] = [
'error' => $this->l10n->t(
- 'It seems that this %s instance is running on a 32-bit PHP environment. 64-bit is required for 26 and higher.',
+ 'It seems that this %s instance is running on a 32-bit PHP environment and the open_basedir has been configured in php.ini. ' .
+ 'This will lead to problems with files over 4 GB and is highly discouraged.',
[$this->defaults->getProductName()]
),
- 'hint' => $this->l10n->t('Please switch to 64-bit PHP.'),
+ 'hint' => $this->l10n->t('Please remove the open_basedir setting within your php.ini or switch to 64-bit PHP.'),
];
}
diff --git a/lib/private/Streamer.php b/lib/private/Streamer.php
index f96646e3365..1375489d360 100644
--- a/lib/private/Streamer.php
+++ b/lib/private/Streamer.php
@@ -85,7 +85,7 @@ class Streamer {
} elseif ($request->isUserAgent($this->preferTarFor)) {
$this->streamerInstance = new TarStreamer();
} else {
- $this->streamerInstance = new ZipStreamer(['zip64' => true]);
+ $this->streamerInstance = new ZipStreamer(['zip64' => PHP_INT_SIZE !== 4]);
}
}
diff --git a/lib/private/legacy/OC_Response.php b/lib/private/legacy/OC_Response.php
index b849710e90b..e4525fe9e10 100644
--- a/lib/private/legacy/OC_Response.php
+++ b/lib/private/legacy/OC_Response.php
@@ -52,6 +52,19 @@ class OC_Response {
* @param string|int|float $length Length to be sent
*/
public static function setContentLengthHeader($length) {
+ if (PHP_INT_SIZE === 4) {
+ if ($length > PHP_INT_MAX && stripos(PHP_SAPI, 'apache') === 0) {
+ // Apache PHP SAPI casts Content-Length headers to PHP integers.
+ // This enforces a limit of PHP_INT_MAX (2147483647 on 32-bit
+ // platforms). So, if the length is greater than PHP_INT_MAX,
+ // we just do not send a Content-Length header to prevent
+ // bodies from being received incompletely.
+ return;
+ }
+ // Convert signed integer or float to unsigned base-10 string.
+ $lfh = new \OC\LargeFileHelper;
+ $length = $lfh->formatUnsignedInteger($length);
+ }
header('Content-Length: '.$length);
}