8

Stack Exchange staff has a tool which can search and replace strings in the URLs, see Shog9's answer here: How to find and/or change a set of hyperlinks on a site? This tool is sometimes used when some domain which is often linked from some Stack Exchange site changes their structure.

I think it would be nice if this tool could also:

  • Check whether some of the new URLs (after the modification) returns 404 error.
  • Return the list of original and modified URLs.
  • Return the list of the posts that were influenced.

If many posts are changed at once, it is possible that there might be some mistakes or that some of the pages from the old domain were transformed in a different way. Checking whether the new links work correctly would be useful. Having the list of the links could also be helpful in verifying whether the mass replacement did not cause some mistakes. (From what I understood, this bulk replacement tool was modified not too long ago in such a way that it is possible to run it networkwide rather than per site - although I have only seen this mentioned in comments. If the tool is used on multiple sites, this just increases the possibility that there might be some mistake and increases the importance of checking the new links.)

This can be considered as a follow-up to this question: Does the bulk replacement tool also check if the new link is working? There I asked whether this is already available; the answer was that it currently is not, so I made this into a feature request.


So far when suggesting such a replacement, I did my best to verify whether the links work already before the replacement. Typically what I did was:

  • Getting the bodies of posts with matching URLs using SEDE.
  • Downloaded the results of the query.
  • Manipulated the results so that I isolated URLs. (I have used sed+grep, but I am sure there are more suitable tools for that.)
  • After getting the list of links, I have modified them in the suggested ways.
  • Then I tested the new links. (I did it using wget - there are certainly many tools for that.)

Although I only did this on one site (or a few sites) - if the replacement was done networkwide, this is getting a bit more complicated.

I suppose that something similar could be done even after the replacement. Moreover, I could also look (in SEDE or in the profile) on the activity of the Community user around the time when the links were being replaced. For example, here is a (single-site) query based on Glorfindel's suggestions.

The main point probably is that if the list of posts (or links) is created when this tool is run anyway - or if the tool can be easily modified to create such list - then getting the list directly from the bulk replacement tool would be more reliable (and much easier).

2
  • 1
    Checking the URLs would need to be done carefully, otherwise we're just DOSing the site.
    – Laurel
    Commented Apr 24, 2022 at 11:25
  • 1
    @Laurel That's certainly a fair objection. Still, if there is at least a list of URLs, it can be provided by SE to the user(s) who requested the change. And they can use the tool of they choice to check the URLs in some way. (Carefully enough to leave some space between any two requests.)
    – Martin
    Commented Apr 24, 2022 at 11:28

1 Answer 1

3

AFAIK it's just a simple find and replace tool (probably based on SQL queries). That means your first request isn't possible.

The third one can be done with SEDE, if you're patient enough until next Sunday. For the example you linked to, note down the date (2018-08-14) (you can also find it by searching for the replacement URL and checking the revision list). Use that date as the parameter of this SEDE query and you'll get a list of edited posts:

enter image description here

The second column contains links that take you directly to the created revision, from where you can check if the new link is working:

enter image description here

It should be possible to do some SQL string manipulation on the Markdown to retrieve the actual links (new and old), but that is not my forte.

3
  • Well, the tool can be upgraded to be something with UI used inside the site, e.g. some admin panel devs and CM's already have. And it will be based, behind the scenes, on what they're using these days. :) Commented Apr 25, 2022 at 7:05
  • Thanks for the response. I have added into the question what I actually did when I recently suggested such a replacement. Using SEDE for these purposes becomes a bit more complicated if the tool is run networkwide (and not only on one site). But still, I suppose the URL search should work. even networkwide. (Although one has to be a bit careful when using the networkwide search.)
    – Martin
    Commented Apr 25, 2022 at 9:08
  • BTW I did not think of using the Comment field in the PostHistory table for this purpose - that is quite clever. :-)
    – Martin
    Commented Apr 25, 2022 at 9:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .