Selected page in pages field after changing url

I have a block with a pages field inside of it. The site is huge. The client changed some urls and now many of those blocks became useless because the selected pages are no longer there. In order for the site not to break into debug mode I had to implement if(page exists) etc, but this still leaves us with empty content that was there previously.

Why does this function like this? Isn’t it supposed to grab a page by id or something and not by url? This is an enormous pain to deal with.