Go to file
Nick e456de11b0
Fix clobbering of the upload size validation (#10059)
* Fix clobbering of the upload size validation

When the validation is set here like this, it overrides validation which has already been setup with a simple '*' rule for the size based on PHP.

If you've defined in the sites yml config something like

    SilverStripe\Assets\Upload_Validator:
      default_max_file_size:
        '[image]': '2m'
        '*' : '1m'

then it will not be respected.

If you review SilverStripe\Assets\Upload_Validator and check the getAllowedMaxFileSize method, you'll see the sizing will be populated (if it hasn't been done before).

You can see it fail by;
- Setup a new SilverStripe site.
- Set your PHP to allow max post / max upload size of 10mb.
- Add the above config to your sites yml file and flush.
- In the CMS you'll be able to upload a 5MB file, when you shouldn't.

* Test that FileField will use size validation if defined

Couple of tests which prove a fix so the FileField and others will use the default_max_file_size setting

* Fix variable name in last commit

This is what happens when you refactor in the github window.
Fix the variable names. This will get squashed once merged.

* Updates the pr - white space and non deprecated method for byte conversion

Remove extra white space to appease the CS. Use the non deprecated method for memstring2bytes

* White space fixes for the phpcs

White space fixes for the phpcs

* Ensure that "memstring2bytes" can handle if an empty or value with no number is passed in

* DEP Bump assets constraint to ensure that change is also pulled in

---------

Co-authored-by: Guy Sartorelli <guy.sartorelli@silverstripe.com>
2024-01-08 15:49:41 +13:00
_config NEW Allow a single has_one to manage multiple reciprocal has_many (#11084) 2023-12-12 10:18:25 +13:00
.github MNT Run module-standardiser (#11102) 2023-12-21 16:18:42 +13:00
.tx ENH Update translations 2023-03-06 18:17:45 +13:00
client ENH Update logo (#10922) 2023-08-29 15:53:07 +12:00
lang Merge branch '5.1' into 5 2023-12-18 15:20:02 +13:00
src Fix clobbering of the upload size validation (#10059) 2024-01-08 15:49:41 +13:00
templates API Stop using deprecated API 2022-11-15 18:20:54 +13:00
tests Fix clobbering of the upload size validation (#10059) 2024-01-08 15:49:41 +13:00
thirdparty API Throw deprecation warnings for bad configuration (#10702) 2023-03-01 11:36:08 +13:00
_config.php API Stop using deprecated API 2022-11-15 18:20:54 +13:00
_register_database.php MNT Remove legacy upgrader config 2023-01-20 17:05:41 +13:00
.editorconfig Update composer.json 2017-10-12 11:53:12 +13:00
.gitattributes MNT Move docs to new repository (#10394) 2022-07-12 12:46:13 +12:00
.gitignore Ignore assets dir that can be created on dev/build 2018-09-29 22:52:08 +01:00
cli-script.php NEW NullDatabase (#10016) 2022-02-04 10:07:27 +13:00
composer.json Fix clobbering of the upload size validation (#10059) 2024-01-08 15:49:41 +13:00
CONTRIBUTING.md MNT Move docs to new repository (#10394) 2022-07-12 12:46:13 +12:00
LICENSE MNT Run module-standardiser 2023-08-14 15:45:26 +12:00
phpcs.xml.dist MNT Travis shared config 2020-12-22 11:43:54 +13:00
phpunit.xml.dist MNT Run ORM tests in parallel to other tests (#10901) 2023-08-07 11:57:23 +12:00
README.md DOC Update README.md for CMS 5 2023-04-19 17:39:47 +12:00
sake MNT Remove TODO comments 2023-10-30 13:21:09 +13:00
silverstripe_version API CHANGE silverstripe_version file now contains the plain version number, rather than an SVN path 2012-02-01 18:42:21 +01:00
SUPPORT.md MNT Move docs to new repository (#10394) 2022-07-12 12:46:13 +12:00

Silverstripe Framework

CI Silverstripe supported module

PHP framework forming the base for the Silverstripe CMS (https://silverstripe.org). Requires a silverstripe-installer base project. Typically used alongside the cms module.

Installation

See getting started for instructions on how to start the installation process.

Bugtracker

Bugs are tracked on github.com. Please read our issue reporting guidelines.

Development and Contribution

If you would like to make changes to the Silverstripe core codebase, we have an extensive guide to contributing code.

Attribution