silverstripe-cms
silverstripe-cms copied to clipboard
CMS Reauthentication doesn't work with react components / sections
Sometimes even the image is jpg format ( I am sure ). I don't know why, but I can't upload the image with the uploader.
But I can upload the image from files section :=)
ERROR [UNKNOWN TYPE, ERRNO 400]:
Trace
SilverStripe\Dev\CliDebugView->renderTrace() DetailedErrorFormatter.php:117
SilverStripe\Logging\DetailedErrorFormatter->output(400, , , , ) DetailedErrorFormatter.php:52
SilverStripe\Logging\DetailedErrorFormatter->format(Array) HTTPResponse.php:355
SilverStripe\Control\HTTPResponse->outputBody() HTTPResponse.php:283
SilverStripe\Control\HTTPResponse->output() index.php:18
Would you mind please providing a bit more context, for example how you're uploading the image?
@robbieaverill I usually can upload image but sometimes it gives me this error. I can upload the image from files section..
private static $has_one = [
'Photo' => Image::class,
];
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->addFieldToTab(
'Root.Main', $uploader = UploadField::create('Photo', 'Profil Photo'),'Content'
);
$uploader->setFolderName('profile');
$uploader->getValidator()->setAllowedExtensions(['png','gif','jpeg','jpg']);
return $fields;
}
Does a file already exist with the same filename as the one you are trying to upload? If so, maybe related to an issue I raised - https://github.com/silverstripe/silverstripe-framework/issues/7541
@christopherdarling No it is new .. The image that I have tried to upload is https://ibb.co/kpih5G
I think it is related with $uploader->getValidator()->setAllowedExtensions(['png','gif','jpeg','jpg']);
The image is jpg but it triggers an error -- ERROR [UNKNOWN TYPE, ERRNO 400]:
@cansozeri can you find the exact file and line number this error appears on? The stack trace for errors is currently broken (it shows the stacktrace of the error reporting subsystem; Our fault not yours :) ).
E.g.
Can you please show me the entire Page.php file? It's possible the Image::class
doesn't have a use
namespace at the top; Could that cause an unknown type
error?
@tractorcow this is the entire class :=) As I told before, I usually can upload an image without error, but sometimes I get this error..
class Artist extends Page
{
private static $db = [
];
private static $has_many = array (
'PortfolioAlbums' => PortfolioAlbum::class,
);
private static $has_one = [
'Photo' => Image::class,
];
private static $owns = [
'PortfolioAlbums',
'Photo'
];
private static $versioned_gridfield_extensions = true;
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->addFieldToTab(
'Root.Main', $uploader = UploadField::create('Photo'),'Content'
);
$uploader->setFolderName('profile');
$uploader->getValidator()->setAllowedExtensions(['png','gif','jpeg','jpg']);
$fields->addFieldsToTab('Root.Portfolio', array (
GridField::create(
'PortfolioAlbums',
'Portfolyo',
$this->PortfolioAlbums()->sort('SortID'),
GridFieldConfig_RecordEditor::create(500)
->addComponent($sortable = new GridFieldSortableRows('SortID'))
)
));
$sortable->setUpdateVersionedStage('Live');
return $fields;
}
}
@tractorcow Interesting, I can upload the same image now :=) If I faced again I am gonna write you the error line :=)
@tractorcow I think I have found the problem. If you leave admin page after some period a pop up appears and ask you password to stay at the page, after that action I couldn't upload an image I get the error ERROR [UNKNOWN TYPE, ERRNO 400]:
But logout and login again - then I could upload my image...
But the interesting thing is - I can upload from files section - can not upload from page uploader ..
Oh, so it's actually a permission issue; If your session times out the upload
action will become a 400 error. :) Makes sense!
Perhaps we need to bake in the session-reauthentication logic into react components a bit more intelligently?
Renaming to better reflect the issue at hand. :)
Hi,
Now if you add photo from gridfield and after that delete it. For example delete the photo item and the gallery with delete button from cms. It deletes from gallery and gallery item tables but not delete from live tables. I do not know the issue is related with this but then if you try to add the same photo with the same name you got error {"message":{"type":"error","value":"Extension is not allowed"}}
If you change the name of the photo, then you can upload it again :=)