milesj / uploader

[Deprecated] A CakePHP plugin for file uploading and validating.
MIT License
193 stars 73 forks source link

Ignore virtualFields in find or find only specified fields #174

Closed geskill closed 10 years ago

geskill commented 10 years ago

Had a problem with a special virtual field that uses a foreign model. I fixed thisremoving the virtualFields temporary. However i'm not as familiar with the internals but maybe (also for performance) its better to define the needed fields exactly (i.e. id, image_url via fields-param)?

my workaround:

    public function deleteFiles(Model $model, $id, array $filter = array(), $isDelete = false) {
    // ...
    $tmp = $model->virtualFields;
    $model->virtualFields = array();
    $data = $model->find('first', array(
        'conditions' => array($model->alias . '.' . $model->primaryKey => $id),
        'contain' => false,
        'recursive' => -1
    ));
    $model->virtualFields = $tmp;

and

    protected function _cleanupOldFiles(Model $model, array $fields) {
    // ...
    $tmp = $model->virtualFields;
    $model->virtualFields = array();
    $data = $model->find('first', array(
        'conditions' => array($model->alias . '.' . $model->primaryKey => $model->id),
        'contain' => false,
        'recursive' => -1
    ));
    $model->virtualFields = $tmp;
milesj commented 10 years ago

Fixed.