// Get the latest revision ID from the master
$dbw = wfGetDB( DB_MASTER );
$latest = $dbw->selectField( 'page', 'page_latest', $conds, __METHOD__ );
+ if ( $latest === false ) {
+ // Page does not exist
+ return null;
+ }
$conds['rev_id'] = $latest;
} else {
// Use a join to get the latest revision