Skip to content

Loading…

BUG CMSFileAddController: get page id for action fileexists #961

Closed
wants to merge 1 commit into from

2 participants

@JayDevlin

UploadField->fileexists() fails to check if a file exists in a certain folder (and fallsback to "assets/"), if CMSFileAddController doesn't provide a valid folder (-- and fallsback to "assets/newFolder/").

admin/assets/add/?ID=123:
$this->currentPageID() = 123
$folder->getFilename() = 'assets/Uploads/foo/bar/'

admin/assets/add/EditForm/field/AssetUploadField/fileexists?filename=test.jpg:
$this->currentPageID() = 0
$folder->getFilename() = 'assets/NewFolder/'

silverstripe/silverstripe-framework#2904

@JayDevlin

For "PHP Fatal error: Call to a member function getFilename() on a non-object"
see silverstripe/silverstripe-framework#2903

@simonwelsh

Fixed with dc86539

@simonwelsh simonwelsh closed this
@JayDevlin JayDevlin deleted the JayDevlin:2904-page-id-for-fileexists branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Showing with 1 addition and 0 deletions.
  1. +1 −0 code/controllers/CMSFileAddController.php
View
1 code/controllers/CMSFileAddController.php
@@ -26,6 +26,7 @@ public function currentPage() {
if($id && is_numeric($id) && $id > 0) {
$folder = DataObject::get_by_id('Folder', $id);
if($folder && $folder->exists()) {
+ Session::set("{$this->class}.currentPage", $id);
return $folder;
}
}
Something went wrong with that request. Please try again.