Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uploadfield doesn't save into inherited Image Classes #341

Merged
merged 4 commits into from Apr 19, 2012

Conversation

mateusz
Copy link
Contributor

@mateusz mateusz commented Apr 18, 2012

Ref: http://open.silverstripe.org/ticket/7140

Fixes the original issue, plus adds support to relationAutoSetting, adds comments, removes one unnecessary write.


if ($this->relationAutoSetting) {
// Search for classes that can hold the uploaded files by reflecting on the relations. Has one has priority.
$foundClasses = array_filter(array($record->has_one($name), $record->has_many($name), $record->many_many($name)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting the object on the relationship should probably be done somewhere else, like in DataObject, rather than UploadField doing the discovery itself.
I can't recall if we already have something that does this or not. @sminnee?

@mateusz
Copy link
Contributor Author

mateusz commented Apr 18, 2012

Yeah, now that I look at it, maybe better to call $record->$name, and then try to get the relationship class from there. Will look into it tomorrow.

DataObject::get_one returns false if not found, so better check for
object. Also, the directory would not be cleaned, so on the subsequent
run the files could end up having suffixes.

missed this one
UploadField was relying entirely on the File::get_class_for_file_extension to
select a class, so it could only create File or Image objects. This
would break the relationships based on derived objects. Also make it
respect the FileField::relationAutoSetting.
@mateusz
Copy link
Contributor Author

mateusz commented Apr 19, 2012

Fixed for many-many relationships: now will just traverse the relationship and make out the class from the received object.

halkyon pushed a commit that referenced this pull request Apr 19, 2012
Uploadfield doesn't save into inherited Image Classes
@halkyon halkyon merged commit b8faa41 into silverstripe:master Apr 19, 2012
sabina-talipova pushed a commit to creative-commoners/silverstripe-framework that referenced this pull request Oct 18, 2022
…te-supermax-filesize

ADD Upload_Validator::getLargestAllowedMaxFileSize method
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants