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

Undefined index dirname in RenameUpload filter #11

Closed
weierophinney opened this issue Dec 31, 2019 · 1 comment
Closed

Undefined index dirname in RenameUpload filter #11

weierophinney opened this issue Dec 31, 2019 · 1 comment
Assignees

Comments

@weierophinney
Copy link
Member

This issue has been moved from the zendframework repository as part of the bug migration program as outlined here - http://framework.zend.com/blog/2016-04-11-issue-closures.html


Original Issue: zendframework/zendframework#7274
User: @denchik63
Created On: 2015-02-27T19:21:43Z
Updated At: 2015-11-06T20:46:42Z
Body
Hi everyone.

Form:

/**
 * @return Form
 */
private function getPhotoGalleryForm() {
    $photoGallery = new ObjectFieldset();
    $photoGallery->setObject(new ClientPhotoGallery());
    $photoGallery->setHydrator(new DoctrineOrmHydrator($this->getEntityManager(), 'Admin\Entity\ClientPhotoGallery'));
    $photoGallery->add([
        'name' => 'title',
        'type' => 'AbstractAdmin\Element\ExtendedText',
        'required' => false,
        'options' => array(
            'label' => 'Заголовок',
        ),
    ]);

    $image = new ObjectFieldset();
    $image->setObject(new Image());
    $image->setHydrator(new DoctrineOrmHydrator($this->getEntityManager(), 'Admin\Entity\Image'));
    $image->add([
        'name' => 'id',
        'type' => 'AbstractAdmin\Element\ExtendedHidden',
        'required' => true,
    ]);
    $image->add([
        'name' => 'image',
        'type' => 'AbstractAdmin\Element\ExtendedFile',
        'required' => false,
    ]);

    $images = new ObjectCollection('images', [
        'count' => 16,
        'target_element' => $image,
    ]);

    $photoGallery->add($images);
    $photoGalleries = new ObjectCollection('photoGalleries', [
        'count' => 6,
        'target_element' => $photoGallery,
    ]);

    $data = $this->getDataFieldset();
    $data->setHydrator(new DoctrineOrmHydrator($this->getEntityManager(), 'Admin\Entity\ClientData'));
    $data->add($photoGalleries);

    $form = $this->getSubmitForm('photoGalleryForm', 'photoGallerySubmit');

    $form->add($data);
    $form->setInputFilter($this->getPhotoGalleryInputFilter());

    $form->prepare();

    return $form;
}

InputFilter:

/**
 * @return InputFilter
 */
private function getPhotoGalleryInputFilter() {
    $factory = new Factory();
    $formFilter = new InputFilter();
    $dataFilter = new InputFilter();

    $photoGalleriesFilter = new ApplicationCollectionInputFilter();
    $photoGalleriesFilter->setCount(6);
    $photoGalleryInputFilter = new InputFilter();

    $photoGalleryInputFilter->add($factory->createInput(array(
        'name' => 'id',
        'required' => false,
    )));

    $photoGalleryInputFilter->add($factory->createInput(array(
        'name' => 'title',
        'required' => false,
        'filters' => array(
            array(
                'name' => 'StringTrim',
            ),
            array(
                'name' => 'HtmlEntities',
            ),
        ),
    )));

    $imagesFilter = new ApplicationCollectionInputFilter();
    $imagesFilter->setCount(16);
    $imageInputFilter = new InputFilter();

    $imageInputFilter->add($factory->createInput(array(
        'name' => 'id',
        'required' => false,
    )));

    $imageInputFilter->add($factory->createInput(array(
        'name' => 'image',
        'required' => false,
        'filters' => array(
            array(
                'name' => 'Zend\Filter\File\RenameUpload',
                'options' => array(
                    'target' => '*',
                    'randomize' => true,
                ),
            ),
        ),
        'type' => 'Zend\InputFilter\FileInput',
    )));

    $imagesFilter->setInputFilter($imageInputFilter);

    $photoGalleryInputFilter->add($imagesFilter, 'images');

    $photoGalleriesFilter->setInputFilter($photoGalleryInputFilter);

    $dataFilter->add($photoGalleriesFilter, 'photoGalleries');
    $formFilter->add($dataFilter, 'data');

    return $formFilter;
}

When i tried to save the form i got error - Notice: Undefined index: dirname in Z:\home\findservice\vendor\zendframework\zendframework\library\Zend\Filter\File\RenameUpload.php on line 267

I think it happend because in RenameValidator::getFinalTarget($uploadData) array has empty "tmp_name" element (or elements).


Originally posted by @GeeH at zendframework/zend-filter#30

@gsteel
Copy link
Member

gsteel commented Aug 14, 2024

This issue stretches back nearly 10 years to zendframework/zendframework#7274 - There have been no other issue reports - I think we can consider this as not a bug…

@gsteel gsteel closed this as not planned Won't fix, can't repro, duplicate, stale Aug 14, 2024
@gsteel gsteel self-assigned this Aug 14, 2024
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

No branches or pull requests

2 participants