0

Pages are not shwoing up. They display the follwoing error:

InvalidArgumentException: Cannot redirect to an empty URL. in Symfony\Component\HttpFoundation\RedirectResponse->setTargetUrl() (line 86 of /home/../public_html/domain.com/vendor/symfony/http-foundation/RedirectResponse.php).

On page: The website encountered an unexpected error. Please try again later.InvalidArgumentException: Cannot redirect to an empty URL. in Symfony\Component\HttpFoundation\RedirectResponse->setTargetUrl() (line 86 of vendor/symfony/http-foundation/RedirectResponse.php).

I also noticed that the LOGO and HOME in the main menu do not redirect to the front page but instead they redirect to the current page, which is not correct.

Any help or insight will be greatly appreciated.

  • Does this have to do with Drupal or Symfony? – Kevin May 11 '18 at 18:08
  • Enable verbose error logging with backtrace, what's the backtrace of this, who is calling it? What is the frontpage configuration set to? – Berdir May 11 '18 at 18:18
  • I haven't messed with Symfony other than using composer to install quicktabs – Progonat May 11 '18 at 18:35
  • Uninstalled quicktabs but the problem still remains. I have tried changing the home page configuration page, but it still does not work. it seems that the base_url is not being detected by Drupal. – Progonat May 11 '18 at 18:37
  • There’s definitely something you’re doing in a theme or otherwise – Kevin May 11 '18 at 21:27
0

This solution is working when

Successfully Logout with empty blank page website encounter error.

You need to override the core logout function available in user module by creating your custom module

that is UserController::logout function

Create a Route subscriber

/module/src/Route/RouteSubcriber.php

<?php

namespace Drupal\modulename\Routing;
use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;
/**
* Listens to the dynamic route events.
*/
 class RouteSubscriber extends RouteSubscriberBase {
 /**
  * {@inheritdoc}
  */
  public function alterRoutes(RouteCollection $collection) {

    if ($route = $collection->get('user.logout')) {
      $route->setDefaults(array(
       '_controller' => 
       '\Drupal\modulename\Controller\RouteController::logout',
      ));
    }
  }
 }

Create Services file

module/modulename.services.yml

services:
 modulename.route_subscriber:
  class: Drupal\modulename\Routing\RouteSubscriber
  tags:
  - { name: event_subscriber }

Create Controller File module/src/Controller/RouteController.php

<?php
/**
 * @file
 * Contains \Drupal\modulename\Controller\RouteController.
 */
namespace Drupal\modulename\Controller;

use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Url;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;

class RouteController extends ControllerBase
{

  public function logout() {
    //redirecting to home page if you want you can 
    // redirect to some other page. by concating path with it.
    $value = \Drupal::request();
    user_logout(); 
    return new RedirectResponse($value->getBaseUrl()); 
    //return new RedirectResponse($value->getBaseUrl().'/somepath');
  }

}   

that is it.enable the module and try logout will work with out blank page error

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.