There are plenty of nightclubs that do this, and police frequently mandate that they do so as a requirement of operating their alcohol license in the UK. It's completely legal.
It would be very unusual for a restaurant to do so, but I'm wondering if it might have been a restaurant with a nightclub attached (if we're talking central London here maybe Tiger Tiger?). That's quite plausible.
This is extremely common at major bars in most states in the US, especially if you're anywhere near a college. It's there to detect fakes. I'd imagine fake IDs are a much larger problem in the US, however, given that the drinking age is 21.
That said, at least years ago, the ID scanners would operate on data stored on the card and not make any network connection to a database. So then more expensive fake IDs began to exist that could scan fine. Then, I think some bars started getting more expensive ID scanners which actually do talk to some database.
Some bars and nightclubs use ID scanners for verification purposes. A machine vision system is much better than a bouncer at spotting fake IDs or knowing what a Latvian driving license is supposed to look like. The scanner can also check names against a list of banned patrons, which may be shared between venues.
This isn't quite true. Since the licenses can be valid for a long time (e.g. ten years) there are still europeans with valid old-style licenses. Until I renewed mine last month I had a ridiculous paper booklet with a photo glued on.
Free credit checks - make sure you didn't get an unknown credit card / loan / mortgage opened. You could also be cautious and report that passport as stolen, so it gets reissued with different numbers.
It would be very unusual for a restaurant to do so, but I'm wondering if it might have been a restaurant with a nightclub attached (if we're talking central London here maybe Tiger Tiger?). That's quite plausible.