This is a potential fix for the bug that causes several miner nodes to crash a few days ago.
The problem: when a block is disconnected, the transactions in it are attempted to be moved to the mempool; if some of these are non-standard, this will fail. If there were transactions in the mempool already that depended one or more of those, they become orphan transactions - which breaks the mempool's consistency assumption.
In addition, this pull request adds a CTxMempool::check() method which runs an extensive consistency check on the mempool, and is called from several places when -checkmempool is passed (a non-documented flag).