Commit Graph

26 Commits

Author SHA1 Message Date
Ingo Schommer
d220ca3f67 API Use symfony/cache (fixes #6252) 2017-02-26 13:07:59 +13:00
Daniel Hensby
873fd8c5bc
NEW replace _ss_environment.php with .env and environment vars 2017-01-31 20:40:17 +00:00
Loz Calver
d3c24769ac Merge pull request #6469 from dhensby/pulls/4/image-backend-interface
FIX Make sure image backends implement method getImageResource
2017-01-27 16:59:46 +00:00
Damian Mooyman
5d6c90361c
BUG Ensure root path of any local adapter is safely created and mapped from symlink
Fixes https://github.com/silverstripe/silverstripe-asset-admin/issues/362
2017-01-25 13:55:02 +13:00
Damian Mooyman
d192a4f86f BUG Fix root folder getFilename() returning incorrect path (#6510) 2017-01-17 17:49:42 +13:00
Damian Mooyman
7d67c5b9bd
API Allow users to act-as another 2017-01-16 09:04:20 +13:00
Ingo Schommer
3b06e30558 Don’t add extension dot in FileNameFilter
File names are generally valid without an extension (although they might be disallowed by upload constraints),
so the filter should deal gracefully with them (“myfile” should return “myfile”, not “myfile.”)
2017-01-13 11:11:40 +13:00
Ingo Schommer
b1d5e97a3d Enforce unique Folder names, use AssetNameGenerator 2017-01-13 11:11:37 +13:00
Daniel Hensby
8badad90df
FIX Make sure image backends implement method getImageResource 2017-01-10 15:15:51 +00:00
Ingo Schommer
3b50506aa0 Fail manipulateImage() without image resource
Sometimes a manipulation can’t be carried out, either because the backend isn’t available,
or because there isn’t enough PHP memory available. In these cases, $backend->getImageResource()
will be set to NULL. This should be picked up by manipulateImage(), to avoid passing an invalid
backend into the $callback provided.

The specific case this solves is calling Image->FitMax() on large images:
$resizedImage = $originalImage->FitMax(<width>, <height>)
This will have $resizedImage==$originalImage if the image is smaller than the targeted dimensions,
but with this fix $resizedImage==NULL if the image is too large to be resized.
Which gives custom code the ability to determine which of the two should be used,
for example choosing not to pass the original large image URL to the client
since it wouldn’t be considered a “thumbnail” size.
2017-01-06 18:45:56 +13:00
Ingo Schommer
fcb511b1c0 Reinstated GDBackend->checkAvailableMemory()
This was removed as part of the SS4 assets refactor:
be239896d3
Presumably @tractorcow didn’t feel it’s possible to retain this,
because we don’t have local file handles required for getimagesize().
Since there’s getimagesizefromstring() as well (added in PHP 5.4),
we just needed a different logic branch.

Also makes the logic more resilient against missing GD resources on a backend.
Lack of available memory for a resize is only one (new) reason,
other edge cases were already causing these missing resources (e.g. an invalid file string).

Original discussion: https://groups.google.com/forum/m/#!topic/silverstripe-dev/B57a3KYeAVQ
Pull request for 3.x: https://github.com/silverstripe/silverstripe-framework/pull/2859
More context: https://github.com/silverstripe/silverstripe-framework/pull/2569
2017-01-06 18:45:56 +13:00
Ingo Schommer
6e561f00bd Force GC in GDBackend
This has been discussed previously, and was assumed to be handled by PHP automatically:
https://github.com/silverstripe/silverstripe-framework/issues/2739#issuecomment-32603005
It’s unclear if its a regression in SS4.

Tested with PHP 5.6.29, by setting xdebug breakpoints
and inspecting memory_get_usage() before and after GDBackend->manipulateImage().
Even a single 7MB JPEG straight from my DSLR (6000x300) can chomp bring the system from 30MB to >128MB memory use.
That’s in addition to the 7MB of PHP memory required for the $content variable.
Note that the image manipulations likely happen on the raw bitmap, which is much larger than the 7MB compressed JPEG.

Checked ImagickBackend, which doesn’t have this issue (and only uses about half the memory for the same set of images).
2017-01-06 18:45:56 +13:00
Robbie Averill
37a009289c Consolidate temporary file creation and deletion logic. 2016-12-29 22:32:04 +13:00
Robbie Averill
7448622a1a FIX Replace ini casting to int with explicit split and cast for PHP 7.1. Add tests. 2016-12-29 21:55:52 +13:00
Daniel Hensby
ba39e552a2
Merge branch '3' 2016-12-15 12:20:29 +00:00
Damian Mooyman
6e589aac75
API Updates to Form, ValidationResponse, ValidationException
API Implement form schema "errors" handling
2016-12-09 14:24:11 +13:00
Sam Minnee
6650561dac Don't use session and FormSchema to manage server-side React validation responses 2016-12-09 10:27:23 +13:00
Damian Mooyman
bc19b2a491
PSR2 cleanup 2016-11-29 16:18:48 +13:00
Damian Mooyman
7cba50e3a5 API Refactor UploadField, FileField and AssetField into traits Uploadable and FileUploadable 2016-11-29 16:15:59 +13:00
Damian Mooyman
4b7d31377b
PSR2: Automatic fixes 2016-11-29 12:33:28 +13:00
Damian Mooyman
1b1e921e3d
PSR2: Whitespace-only changes 2016-11-29 12:31:16 +13:00
Damian Mooyman
38a63ad73f Merge pull request #6327 from open-sausages/pulls/4.0/file-icon-update
Update doc icons for files area
2016-11-24 10:34:55 +13:00
Damian Mooyman
6e8304ff2f API Namespace framework tests 2016-11-23 19:25:12 +13:00
Paul Clarke
f5923cf433 Update doc icons 2016-11-23 11:26:38 +13:00
Christopher Joe
0901de2995 BUG Fix php schema generation 2016-11-03 10:26:39 +13:00
Sam Minnee
7a10c194bd NEW: Move code files into src/ folder.
This updates framework to be more in keeping with PHP conventions.
2016-11-01 13:37:24 +13:00