helios-ag / FMElfinderBundle

:file_folder: ElFinderBundle provides ElFinder integration with TinyMCE, CKEditor, Summernote editors
MIT License
274 stars 127 forks source link

The ElfinderController::loadAction never return a Symfony Response #352

Closed erichard closed 4 years ago

erichard commented 5 years ago
Issue Type:

Please pick one and delete the rest:

Bundle Version:

9.2

Summary:

The ElfinderController::loadAction() should return a Symfony Response object instead of doing the output itself.

Expected Results:

Elfinder commands should appear in the Symfony profiler. The POST_EXECUTION event should be dispatched.

Actual Results:

Elfinder commands do not appear in the Symfony profiler. The POST_EXECUTION event is never dispatched.

The loadAction() call $loader->load($request) method. This method call either $connector->execute() ou $connector->run() depending of the cors_support configuration.

Both execute() and run() handle the command, output the json and call the exit() function.

So the following code in ElfinderController::loadAction() never seems to be called.

$postExecutionEvent = new ElFinderPostExecutionEvent($request, $httpKernel, $instance, $homeFolder, $result);
$this->get('event_dispatcher')->dispatch(ElFinderEvents::POST_EXECUTION, $postExecutionEvent);

// returning result (who may have been modified by a post execution event listener)
return new JsonResponse($postExecutionEvent->getResult());
zorn-v commented 5 years ago

https://github.com/helios-ag/FMElfinderBundle/pull/349 You should also enable cors_support

shadydealer commented 1 year ago

Could someone explain why does cors support need to be enabled in order for this to not just use exit()? Why is the exit required at all here? What are the benefits of there being an exit at all compared to just returning the result and in the end returning a standard Symfony Response? Using exit causes this code to be untestable.