When installing Drupal using drupal console, a number of log entries appear in dblog:

system	06/25/2016 - 10:51	update module installed.	Anonymous (not verified)	
locale	06/25/2016 - 10:51	1 disallowed HTML string(s) in files: translations:/…	Anonymous (not verified)	
locale	06/25/2016 - 10:51	Translations imported: 6735 added, 0 updated, 0 removed.	Anonymous (not verified)	
locale	06/25/2016 - 10:51	Import of string "Boeken hebben een hiërarchische…	Anonymous (not verified)

When clicking any of these links, the following error occurs:

The website encountered an unexpected error. Please try again later.

InvalidArgumentException: The URI 'http://:/' is malformed. in Drupal\Core\Url::fromUri() (line 273 of core/lib/Drupal/Core/Url.php).
Drupal\dblog\Controller\DbLogController->eventDetails('43')
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array) (Line: 139)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 62)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 98)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 77)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 628)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

SELECT location FROM `watchdog` where wid=1 LIMIT 1 returns http://:/.

$request->getUri() on line 113 in LoggerChannel.php returns 'http://:/' during installation.

CommentFileSizeAuthor
#20 2755497-20.patch2.27 KByogeshmpawar
#12 2755497-12.patch2.29 KBmpp
#8 2755497.patch777 bytesmpp

Comments

mpp created an issue. See original summary.

mpp’s picture

Title: InvalidArgumentException in dblog for anonymous users » InvalidArgumentException in dblog for entries from anonymous users
mpp’s picture

Status: Active » Closed (works as designed)

installed Drupal with Drupal console

mpp’s picture

Status: Closed (works as designed) » Needs work
mpp’s picture

Issue summary: View changes
mpp’s picture

Title: InvalidArgumentException in dblog for entries from anonymous users » InvalidArgumentException in dblog entries due to invalid location
Issue summary: View changes
mpp’s picture

Issue summary: View changes
mpp’s picture

StatusFileSize
new777 bytes
mpp’s picture

Status: Needs work » Needs review
mpp’s picture

Version: 8.1.x-dev » 8.2.x-dev
dagmar’s picture

Status: Needs review » Needs work
Issue tags: +Need tests

Thanks. So this is triggered in some specific scenario.

Could we have some test to ensure this is a bug and the provided patch fixes it?

mpp’s picture

StatusFileSize
new2.29 KB

@dagmar, added tests.

FYI, when running requests using drush/drupal console there is no hostname available.
Symfony\Component\HttpFoundation\Request::getUri returns an invalid uri if there's no hostname/port/baseurl/path/query, namely "http(s)://:/".

    public function getUri()
    {
        if (null !== $qs = $this->getQueryString()) {
            $qs = '?'.$qs;
        }

        return $this->getSchemeAndHttpHost().$this->getBaseUrl().$this->getPathInfo().$qs;
    }

    public function getSchemeAndHttpHost()
    {
        return $this->getScheme().'://'.$this->getHttpHost();
    }

    public function getScheme()
    {
        return $this->isSecure() ? 'https' : 'http';
    }

    public function getHttpHost()
    {
        $scheme = $this->getScheme();
        $port = $this->getPort();

        if (('http' == $scheme && $port == 80) || ('https' == $scheme && $port == 443)) {
            return $this->getHost();
        }

        return $this->getHost().':'.$port;
    }
mpp’s picture

Status: Needs work » Needs review

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

dagmar’s picture

Status: Needs review » Needs work

Sorry for the delay. Inspecting the patch it seems it prevent this problem to occur in the future. But what about pre-existing broken links? If a user already installed the site with drupal console, this will not prevent to see the same errors.

mpp’s picture

Status: Needs work » Needs review

The issue was logged and solved 7 months ago. Logs are not permanent so how about committing this as an improvement for future sites so they are able to see what's in the logs?
Then perhaps open another issue if you feel like patching old logs.

ericpugh’s picture

I've successfully tested patch #12 on 8.2.6, logging some errors from a boilerplate Drupal Console command without the "Malformed URI" error. Thank you!

dagmar’s picture

Status: Needs review » Needs work
Issue tags: -Need tests

Ok. This looks good, but needs a re-roll after the array > [] conversion.

yogeshmpawar’s picture

Status: Needs work » Needs review
StatusFileSize
new2.27 KB

Rerolled patch against the #19.

dagmar’s picture

dagmar’s picture

dagmar’s picture

Status: Needs review » Closed (duplicate)

I'm marking this as a duplicate of #2868725: Refactor how dblog module is rendering links in event details. We should work in a generic solution for several issues we have related the way dblog render links.