How to check if links to related pages are still valid

Nice!
Here is why i would like to store two values:

If i use an md5 hash for several hundred pages, they need to be searched to appear as a relative page.
once the whole website goes live, it may show problems regarding speed, so i wanted to have a second option, in which i would use just the uri path, which would not require any searches at all, but has the disadvantage of being changeable (due to the nature of the templates i’m using)
so, this would be just a simple fallback in case my autoid solution becomes a problem.

Thanks a lot!

Another, very related question: would it be possible to have a panel plugin that checks for all related links and returns the ones that don’t work anymore?
say, you store relative paths as related pages, this plugin could check if they result in a proper url or point to the error page…
maybe this already exists…

Matthias

It shouldn’t be difficult to write a simple script that loops through all related pages and checks if the URIs still exist. You could then trigger this script from a dashboard widget. I don’t know of any such plugin, but if you do something that fits your special use case, then it doesn’t have to be complicated and try to cater for any possible options.

Another option would be using a link checker from time to time.

If you would like to go the “URI-way”, consider this: I would try to solve this with a panel.page.update hook that checks if a URL has been changed. If it has been changed, loop through the related fields searching for the $oldPage URL and replace the matches with the new $page URL. This way your data should always be in sync, and you aren’t dependent on somebody running a plugin once in a while.

Beware for a nasty bug in some cases with hooks though.

I wonder how performant this is when there are a lot of pages to loop through in the background. There’s also the problem of pages being modified while someone is working on them. Might not be a problem at all, but could be.

Hmmm, true.

Maybe saving this kind of information in a dedicated file somewhere instead of on the content itself?

-
uri: some/page/url
relatedpages:
  - another/page/url
  - yet/another/page
-
uri: some/other/page
relatedpages:
  - another/page/url

Performance wise this would be an improvement, but would need custom fields to manage this.

Yes, true. You could even store this stuff in a (sqlite) database.