Mautic Community Forums

Problem with filemanager and $kernel->boot();

Following a server migration and shortly after a move to https, I am having trouble getting the filemanager to work correctly. The rest of the admin seems to be working just fine. A colleague says that it was working before the move to https but I am not entirely certain of that but it might be of some help.



When accessing the file manager it says “You are not authorized to use filemanager.”



I have looked at the called script:

https://[mydomain.com]/app/bundles/CoreBundle/Assets/js/libraries/ckeditor/filemanager/connectors/php/filemanager.php?path=%2F&mode=getfolder&showThumbs=true&time=557&type=Images



which returns: {“Error”:“You are not authorized to use filemanager.”,“Code”:"-1",“Properties”:{“Date Created”:null,“Date Modified”:null,“Height”:null,“Width”:null,“Size”:null}}



However, with some analysis I see that the problem occurs because the try-catch fails in the connectors/php/user.config.php file, specifically at the point of



$kernel->boot();



If I do a a die(“KIA”) before that point we get there. After and the page errors before the die().



I have taken the latest code from github.

Code:
<?php /* ... */ use SymfonyComponentHttpFoundationRequest; use SymfonyComponentHttpKernelEventGetResponseEvent; use SymfonyComponentHttpKernelHttpKernelInterface; use SymfonyComponentHttpKernelKernelEvents; use SymfonyComponentSecurityCoreAuthenticationTokenTokenInterface; // Boot Symfony try { require_once __DIR__.'/../../../../../../../../../autoload.php'; require_once __DIR__.'/../../../../../../../../../bootstrap.php.cache'; require_once __DIR__.'/../../../../../../../../../AppKernel.php'; MauticCoreBundleErrorHandlerErrorHandler::register('prod'); $kernel = new AppKernel('prod', false);
$kernel->boot();  //    <---------------    ERROR HAPPENS AT THIS POINT

$container = $kernel->getContainer();
$request   = Request::createFromGlobals();
$container->enterScope('request');
$container->set('request', $request, 'request');
// Dispatch REQUEST event to setup authentication
$httpKernel = $container->get('http_kernel');
$event      = new GetResponseEvent($httpKernel, $request, HttpKernelInterface::MASTER_REQUEST);
$container->get('event_dispatcher')->dispatch(KernelEvents::REQUEST, $event);
$session       = $container->get('session');
$securityToken = $container->get('security.token_storage');
$token         = $securityToken->getToken();
$authenticated = ($token instanceof TokenInterface) ? count($token->getRoles()) : false;

} catch (Exception $exception) {
error_log($exception);
$authenticated = false;
}

//...
?>

I am web developer but have never used mautic or symfony before so could so with some pointers. Any help would be appreciated - been struggling with this for a while. Thanks in advance.

Following a server migration and shortly after a move to https, I am having trouble getting the filemanager to work correctly. The rest of the admin seems to be working just fine. A colleague says that it was working before the move to https but I am not entirely certain of that but it might be of some help.

When accessing the file manager it says “You are not authorized to use filemanager.”

I have looked at the called script:
https://[mydomain.com]/app/bundles/CoreBundle/Assets/js/libraries/ckeditor/filemanager/connectors/php/filemanager.php?path=%2F&mode=getfolder&showThumbs=true&time=557&type=Images

which returns: {“Error”:“You are not authorized to use filemanager.”,“Code”:"-1",“Properties”:{“Date Created”:null,“Date Modified”:null,“Height”:null,“Width”:null,“Size”:null}}

However, with some analysis I see that the problem occurs because the try-catch fails in the connectors/php/user.config.php file, specifically at the point of

$kernel->boot();

If I do a a die(“KIA”) before that point we get there. After and the page errors before the die().

I have taken the latest code from github.

[code]<?php
/*

*/
use SymfonyComponentHttpFoundationRequest;
use SymfonyComponentHttpKernelEventGetResponseEvent;
use SymfonyComponentHttpKernelHttpKernelInterface;
use SymfonyComponentHttpKernelKernelEvents;
use SymfonyComponentSecurityCoreAuthenticationTokenTokenInterface;
// Boot Symfony
try {
require_once DIR.’/…/…/…/…/…/…/…/…/…/autoload.php’;
require_once DIR.’/…/…/…/…/…/…/…/…/…/bootstrap.php.cache’;
require_once DIR.’/…/…/…/…/…/…/…/…/…/AppKernel.php’;
MauticCoreBundleErrorHandlerErrorHandler::register(‘prod’);
$kernel = new AppKernel(‘prod’, false);

$kernel->boot();  //    <---------------    ERROR HAPPENS AT THIS POINT

$container = $kernel->getContainer();
$request   = Request::createFromGlobals();
$container->enterScope('request');
$container->set('request', $request, 'request');
// Dispatch REQUEST event to setup authentication
$httpKernel = $container->get('http_kernel');
$event      = new GetResponseEvent($httpKernel, $request, HttpKernelInterface::MASTER_REQUEST);
$container->get('event_dispatcher')->dispatch(KernelEvents::REQUEST, $event);
$session       = $container->get('session');
$securityToken = $container->get('security.token_storage');
$token         = $securityToken->getToken();
$authenticated = ($token instanceof TokenInterface) ? count($token->getRoles()) : false;

} catch (Exception $exception) {
error_log($exception);
$authenticated = false;
}[/code]
//…
?>

I am web developer but have never used mautic or symfony before so could so with some pointers. Any help would be appreciated - been struggling with this for a while. Thanks in advance.

Oh I have done this by the way:

Edit:
etc/php.ini

Add:
extension=pdo.so
date.timezone=“America/New_York”

pdo.so was already enabled. The date.timezones matches that set on the server.

Looking into the AppKernel.php boot() function it is here that the error occurs:

    $registeredPluginBundles = $this->container->getParameter('mautic.plugin.bundles');

    foreach ($this->getBundles() as $name => $bundle) {   
        $bundle->setContainer($this->container);        
        $bundle->boot();  // <------ ERRORS OCCURS HERE IN THIS LOOP
    }

I have added an echo to the $name in the loop and found it dies on the MauticCitrixBundle. The new server is a centos 7 server.

When the main mautic app starts it gets through all the plugins ok, however, when in the scope of the filemananger it bombs at the citrix plugin. Might this be a pathing issue?

OK - seems (somehow) the timezone conflict was causing that initial problem as the server timezone reset after a reboot. However the next problem is a “no way” message.

I am checking out the function is_valid_path() in the filemanager_class and have seen that the path being checked is

var/www/html/[mautic]/media/images/

It looks like it really needs a / at the front of that to be valid, but for the life of me I cannot make that happen with the

“serverRoot”: false,
“fileRoot”: “/”.

or whatever combo I set in the filemanager.config.js file

As I could not get it to work with the available configs I added some code into the filemanager.class.php file, getFullPath() function which adds the preceding forward slash if it is missing (and it is on this server): e.g.

if(substr($full_path,0,4)==“var/”){
$full_path = “/”.$full_path;
}

This is on Centos, in case this helps anyone else.