Skip to content
This repository was archived by the owner on Mar 20, 2024. It is now read-only.
This repository was archived by the owner on Mar 20, 2024. It is now read-only.

File upload fails to upload file #389

@sboden

Description

@sboden

Uploading a file with 'When I attach the file "pdf-sample.pdf" to "edit-field-document-0-upload"' doesn't work anymore.

I'm using Drupal 9/10, I had behats which were all green (some of them were uploading files). The only thing I changed was upgrading our ddev development environment to the latest version, so I assume the apache version in use inside of ddev is now newer than before.

The code of the step being used in behat is this (from mink-extension, hence the issue here):

    /**
     * Attaches file to field with specified id|name|label|value
     * Example: When I attach the file "bwayne_profile.png" to "profileImageUpload"
     * Example: And I attach the file "bwayne_profile.png" to "profileImageUpload"
     *
     * @When /^(?:|I )attach the file "(?P<path>[^"]*)" to "(?P<field>(?:[^"]|\\")*)"$/
     */
    public function attachFileToField($field, $path)
    {
        $field = $this->fixStepArgument($field);

        if ($this->getMinkParameter('files_path')) {
            $fullPath = rtrim(realpath($this->getMinkParameter('files_path')), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$path;
            if (is_file($fullPath)) {
                $path = $fullPath;
            }
        }

        $this->getSession()->getPage()->attachFileToField($field, $path);
    }

Before we had problems with this step which we worked around:
What we saw before is that when a file is uploaded a refresh of the page would be done, so anything filled in on a form before the upload of a file would disappear. The workaround in behat was then:

  • Upload a file
  • Press submit (which would fail, but keep the file in the form)
  • Fill in the rest of the fields
  • Press submit

Since the ddev upgrade, this workaround is also not working anymore. I (x)debugged the step, but I don't see anything strange happening that could explain the behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions