Skip to content

Increase max upload size #171

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

Merged
merged 1 commit into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test_buildx_and_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
-e PHP_INI-apc.enabled=0 \
-e PHP_INI-apc.enable_cli=0 \
-e PHP_INI-pcov.enabled=1 \
-e PHP_INI-upload_max_filesize=20M \
moodle-php-apache
docker exec test0 php /var/www/html/test.php
docker exec test0 php /var/www/html/check-ini.php
Expand Down
2 changes: 1 addition & 1 deletion root/usr/local/bin/moodle-docker-php-ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e

echo "Checking for php configuration in environment"

localinifile="/usr/local/etc/php/conf.d/10-local.ini"
localinifile="/usr/local/etc/php/conf.d/20-local.ini"

cat <<'EOF' > $localinifile
; --
Expand Down
7 changes: 7 additions & 0 deletions root/usr/local/etc/php/conf.d/10-docker-php-moodle.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@
; See MDL-71390 for more info. This is the recommended / required
; value to support sites having 1000 courses, activities, users....
max_input_vars = 5000

; Increase the maximum filesize to 200M, which is a more realistic figure.
upload_max_filesize = 200M

; Increase the maximum post size to accomodate the increased upload_max_filesize.
; The default value is 6MB more than the default upload_max_filesize.
post_max_size = 206M
19 changes: 16 additions & 3 deletions tests/fixtures/check-ini.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?php

$fileuploads = ini_get('file_uploads');
$apcenabled = ini_get('apc.enabled');
$memorylimit = ini_get('memory_limit');

$allokay = true;
$message = [];

$fileuploads = ini_get('file_uploads');
if (!empty($fileuploads)) {
$allokay = false;
$message[] = "Uploads are enabled and should be disabled.";
$message[] = var_export($fileuploads, true);
}

$apcenabled = ini_get('apc.enabled');
if (!empty($apcenabled)) {
$allokay = false;
$message[] = "apc.enabled is not Off (0): ({$apcenabled})";
Expand All @@ -23,6 +23,7 @@
$message[] = "apc.enabled_cli is not Off (0): ({$apcenabledcli})";
}

$memorylimit = ini_get('memory_limit');
if ($memorylimit !== '256M') {
$allokay = false;
$message[] = "Memory limit not set to 256M: ({$memorylimit})";
Expand All @@ -34,6 +35,18 @@
$message[] = "pcov.enabled is not On (1): ({$pcovenabled})";
}

$maxuploadsize = ini_get('upload_max_filesize');
if ($maxuploadsize !== '20M') {
$allokay = false;
$message[] = "Maximum upload size not set to 20M: ({$maxuploadsize})";
}

$postmaxsize = ini_get('post_max_size');
if ($postmaxsize !== '206M') {
$allokay = false;
$message[] = "Maximum post size not set to 206M: ({$postmaxsize})";
}

if (php_sapi_name() === 'cli') {
if ($allokay) {
echo "OK\n";
Expand Down