/** * @param SpecialPage $page * @param string $subPage * * @throws Exception * @return string HTML */ private function getHTMLFromSpecialPage(SpecialPage $page, $subPage) { ob_start(); try { $page->execute($subPage); $output = $page->getOutput(); if ($output->getRedirect() !== '') { $output->output(); $html = ob_get_contents(); } elseif ($output->isDisabled()) { $html = ob_get_contents(); } else { $html = $output->getHTML(); } } catch (Exception $ex) { ob_end_clean(); // Re-throw exception after "finally" handling because PHP 5.3 doesn't have "finally". throw $ex; } ob_end_clean(); return $html; }