Skip to content
Snippets Groups Projects
Unverified Commit b775bf71 authored by Eileen McNaughton's avatar Eileen McNaughton Committed by GitHub
Browse files

Merge pull request #19382 from totten/master-maxfile

"Admin => Misc" - Fix validation of "Maximum File Size"
parents 6fea2a85 daebb75b
Branches
Tags
No related merge requests found
......@@ -44,13 +44,10 @@ class CRM_Admin_Form_Setting_Miscellaneous extends CRM_Admin_Form_Setting {
'prevNextBackend' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
];
public $_uploadMaxSize;
/**
* Basic setup.
*/
public function preProcess() {
$this->_uploadMaxSize = (int) ini_get('upload_max_filesize');
// check for post max size
CRM_Utils_Number::formatUnitSize(ini_get('post_max_size'), TRUE);
// This is a temp hack for the fact we really don't need to hard-code each setting in the tpl but
......@@ -101,8 +98,13 @@ class CRM_Admin_Form_Setting_Miscellaneous extends CRM_Admin_Form_Setting {
$errors = [];
// validate max file size
if ($fields['maxFileSize'] > $options->_uploadMaxSize) {
$errors['maxFileSize'] = ts("Maximum file size cannot exceed Upload max size ('upload_max_filesize') as defined in PHP.ini.");
$iniBytes = CRM_Utils_Number::formatUnitSize(ini_get('upload_max_filesize'), FALSE);
$inputBytes = CRM_Utils_Number::formatUnitSize($fields['maxFileSize'] . 'M', FALSE);
if ($inputBytes > $iniBytes) {
$errors['maxFileSize'] = ts("Maximum file size cannot exceed limit defined in \"php.ini\" (\"upload_max_filesize=%1\").", [
1 => ini_get('upload_max_filesize'),
]);
}
// validate recent items stack size
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment