diff --git a/administrator/components/com_finder/src/Controller/IndexerController.php b/administrator/components/com_finder/src/Controller/IndexerController.php index 6a49518ee69cc..5e323b0e7ae94 100644 --- a/administrator/components/com_finder/src/Controller/IndexerController.php +++ b/administrator/components/com_finder/src/Controller/IndexerController.php @@ -11,9 +11,7 @@ \defined('_JEXEC') or die; -use Joomla\CMS\Application\SiteApplication; use Joomla\CMS\Component\ComponentHelper; -use Joomla\CMS\Document\FactoryInterface; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; use Joomla\CMS\Log\Log; @@ -155,7 +153,6 @@ public function batch() * in order to work around some plugins that don't do proper environment * checks before trying to use HTML document functions. */ - $raw = clone Factory::getDocument(); $lang = Factory::getLanguage(); // Get the document properties. @@ -167,27 +164,6 @@ public function batch() 'direction' => $lang->isRtl() ? 'rtl' : 'ltr' ); - // Get the HTML document. - $html = Factory::getContainer()->get(FactoryInterface::class)->createDocument('html', $attributes); - - // TODO: Why is this document fetched and immediately overwritten? - $doc = Factory::getDocument(); - - // Swap the documents. - $doc = $html; - - // Get the admin application. - $admin = clone Factory::getApplication(); - - // Get the site app. - $site = Factory::getContainer()->get(SiteApplication::class); - - // Swap the app. - $app = Factory::getApplication(); - - // TODO: Why is the app fetched and immediately overwritten? - $app = $site; - // Start the indexer. try { @@ -202,12 +178,6 @@ public function batch() $state->start = 0; $state->complete = 0; - // Swap the documents back. - $doc = $raw; - - // Swap the applications back. - $app = $admin; - // Log batch completion and memory high-water mark. try { @@ -225,9 +195,6 @@ public function batch() // Catch an exception and return the response. catch (\Exception $e) { - // Swap the documents back. - $doc = $raw; - // Send the response. static::sendResponse($e); } @@ -318,8 +285,12 @@ public static function sendResponse($data = null) // Create the response object. $response = new Response($data); - // Add the buffer. - $response->buffer = \JDEBUG ? ob_get_contents() : ob_end_clean(); + if (\JDEBUG) + { + // Add the buffer and memory usage + $response->buffer = ob_get_contents(); + $response->memory = memory_get_usage(true); + } // Send the JSON response. echo json_encode($response);