Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand All @@ -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
{
Expand All @@ -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
{
Expand All @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down