This is completely broken with modern transactions. It should also be rewritten to match Phabricator's coding style.