saveData in FeedsFileSystemBase does not return the file path

Created on 7 December 2023, 7 months ago
Updated 14 December 2023, 6 months ago

Problem/Motivation

In FeedsFileSystemBase::saveData the return value is declared as on the interface:

The file uri the data was saved to. This includes the uri to the feeds directory.

But in fact this method only returns the destination, the file should be saved to. It uses drupal cores file_system service which eventually renames the file if another file with the same name already exists. This can result in a wrong return since the saveData does just return the destination.

  /**
   * {@inheritdoc}
   */
  public function saveData($data, string $filename): string {
    $destination = $this->getFeedsDirectory() . '/' . $filename;
    $directory = $this->fileSystem->dirname($destination);
    $this->prepareDirectory($directory);

    $this->fileSystem->saveData($data, $destination);
    return $destination;
  }

The file_system service does return the real url.
$this->fileSystem->saveData($data, $destination);

Steps to reproduce

- Process a feed which uses a file as ressource
- cancel the process
- change something in the feed
- start it again with that changed file

In my case the old file is still present and the new one with the changes is not getting used, since the saveData method returns the wrong file.

Proposed resolution

Return the url the file_system returns.

πŸ› Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany Hydra

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.69.0 2024