Problem/Motivation
It'd be useful to have a Drush command to purge circular redirects.
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | Screenshot from 2024-10-21 18-28-11.png | 236.62 KB | sourav_paul |
| #7 | Screenshot from 2024-08-29 14-33-19.png | 419.92 KB | sourav_paul |
| #5 | Screenshare - 2024-07-18 7_12_12 PM (online-video-cutter.com).mp4 | 3.31 MB | uttam |
| #5 | Screenshot from 2024-07-18 19-06-13.png | 43.75 KB | uttam |
Issue fork redirect-3419718
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
damienmckennaThis logic works for me, it could be turned into a command.
Comment #5
uttam commentedHello everyone, I have created this Drupal Drush command which facilitates the management of circular redirects using Drush as mentioned in the issue. Firstly, It retrieves all redirect entities from the database using
EntityTypeManagerInterface, constructs a map linking source URLs to their corresponding destinations, identifies circular redirect relationships where a redirect points back to its own source. I have also logged each detected circular redirect usingPsr\Log\LoggerInterfaceand provides a user prompt to confirm the delete operation. Upon confirmation, it deletes all identified circular redirect records.Drush command for the purging circular redirects:
drush redirect:purge-circular-redirectsPlease review this.
Comment #6
sourav_paulComment #7
sourav_paulMR was applied successfully but got a fatal error on running the command

drush redirect:purge-circular-redirectsUsing redirect 8.x-1.10 & D10.3
Sharing ss:
Please fix the logger issue...
Comment #8
uttam commented@sourav_paul Hello I have resolved the fatal error and tested the same in d10 and d11, the circular redirects are successfully purging. Please review this once.
Moving this to Needs Review
Comment #9
sourav_paulThanks @uttam for your contribution. I've retested the MR, which was applied cleanly.
Drush command working as expected.
Attaching ss:

Hence Moving it to RTBC.
Comment #10
uttam commentedHello @maintainers
Could you please test and review this feature request implemented on MR 103.
Comment #11
berdirSorry for ignoring this for so long, this should be adjusted to more recent drush versions, drush no longer uses drush.services.yml I think.