- Issue created by @eelkeblok
- Assigned to sourabhjain
- Issue was unassigned.
- Status changed to Needs work
about 1 year ago 11:49am 21 December 2023 - 🇮🇳India sourabhjain
I have updated the changes but when I am trying to test the feature before and after the changes, I am getting below error in logs.
The file temporary://path_redirect_import/export_1703158296.csv was not deleted because it does not exist.
Can someone help me on it.
Attaching the updated patch. - 🇩🇪Germany Anybody Porta Westfalica
I agree the current description is a bit unclear and might be misleading. But before implementing any changes, someone please has to check the code, what it exactly does and then describe that in detail.
I agree that in many cases you may want to overwrite potentially existing redirects, let's tackle this with a separate option in ✨ Add option to overwrite existing source path redirects Active
I think delete option may also make sense to other cases to keep.
- 🇩🇪Germany Anybody Porta Westfalica
Please see 🐛 "Delete redirects defined in the spreadsheet" option without functionality? Active
- 🇩🇪Germany Anybody Porta Westfalica
This is the method that returns the redirect entities to be deleted when using the option:
/** * Iterates over the CSV file to load the list of redirects to delete. * * @return \Drupal\redirect\Entity\Redirect[] * Array containing the Redirect entities to delete. * * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException * @throws \Drupal\migrate\MigrateException * @throws \League\Csv\Exception */ protected function redirectsToDelete() { $redirects_to_delete = []; $storage = $this->entityTypeManager->getStorage('redirect'); $header = $this->getReader()->getHeader(); $records = $this->getReader()->getRecords($header); foreach ($records as $record) { $parsed_url = UrlHelper::parse(urldecode($record['source'])); $path = $parsed_url['path'] ?? NULL; $query = $parsed_url['query'] ?? NULL; $hash = Redirect::generateHash($path, $query, $record['language']); // Search for redirects by hash. $redirects = $storage->loadByProperties(['hash' => $hash]); $redirects_to_delete = array_merge($redirects_to_delete, $redirects); } return $redirects_to_delete; }