Skip to content


BUG CMSFileAddController: get page id for action fileexists #961

wants to merge 1 commit into from

2 participants


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/").

$this->currentPageID() = 123
$folder->getFilename() = 'assets/Uploads/foo/bar/'

$this->currentPageID() = 0
$folder->getFilename() = 'assets/NewFolder/'



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


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
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.