Don't update the entire table in one query to avoid melting servers

Adds a wfWaitForSlaves() call in between batches which isn't
ideal for web requests, but necessary. It should only wait
for 10ish seconds if PHP_SAPI isn't "cli".

Bug: 70376
Change-Id: I3b9e0678759b06310979e8c68a79ac5653d9bdbd