Problem/Motivation

I'm not entirely sure why this is, so this might be a bug or it might not.

DbLogTest fails consistently locally, but doesn't show up as failing in branch tests.

It fails because it generates this error:

[20-Mar-2017 09:19:36 Australia/Sydney] Uncaught PHP Exception InvalidArgumentException: "The URI 'http://localhost:8888user' is malformed." at /Users/paul/pj2/drupal/core/lib/Drupal/Core/Url.php line 274

This comes down to the way DbLogTest::generateLogEntries() uses $request->getRequestUri() to build the URI, which doesn't add a slash into the path. However, this test passes in the tesbot, which is why it's not obvious what to do about it.

There are a number of issues in this meta dealing with changing the tests for DbLog: #2847428: [Meta] Modernize dblog module

Proposed resolution

I'm able to fix it with this patch:

--- a/core/modules/dblog/src/Tests/DbLogTest.php
+++ b/core/modules/dblog/src/Tests/DbLogTest.php
@@ -220,7 +220,7 @@ private function generateLogEntries($count, $options = []) {
       'link'        => $link,
       'user'        => $this->adminUser,
       'uid'         => $this->adminUser->id(),
-      'request_uri' => $base_root . \Drupal::request()->getRequestUri(),
+      'request_uri' => $base_root . '/' . \Drupal::request()->getRequestUri(),
       'referer'     => \Drupal::request()->server->get('HTTP_REFERER'),
       'ip'          => '127.0.0.1',
       'timestamp'   => REQUEST_TIME,

However, this may end up breaking it in the testbot. Let's find out.

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#2 2861973_2.patch739 bytesMile23
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Mile23 created an issue. See original summary.

Mile23’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
739 bytes

Here's a patch.

Also, this issue is set for 8.4.x, but I realize in hindsight it should be for 8.3.x because it's a test improvement (if it's an improvement).

dagmar’s picture

Status: Needs review » Postponed (maintainer needs more info)

Thanks @Mile23. I never experienced this in the past. Actually I have this simple php file

global $base_root;
$request_uri = \Drupal::request()->getRequestUri();

echo '$base_root: ' . $base_root . "\n";
echo '$request_uri: ' . $request_uri . "\n";

When I run this with drush src file.php I get this:

$base_root: http://default
$request_uri: /

It seems this is the expected behavior, so, maybe is something related to your local environment.

Can you describe what Os/Webserver are you using? Thanks

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

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.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.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.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.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.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.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.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.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

larowlan’s picture

Issue tags: +Bug Smash Initiative

Triaged this as part of bug-smash, will reach out to @Mile23 on slack to ask if this is still valid.

Mile23’s picture

Status: Postponed (maintainer needs more info) » Needs work

MAMP 5.6, using PHP 7.3.9 and MySQL 5.7.26.

Here are two logs. Note that different, overlapping sets of tests fail depending on which tool you use to run them.

$ php ./core/scripts/run-tests.sh --sqlite foo.sqlite --concurrency 5 dblog

Drupal test run
---------------

Tests to be run:
  - Drupal\Tests\dblog\Functional\DbLogResourceTest
  - Drupal\Tests\dblog\Functional\DbLogTest
  - Drupal\Tests\dblog\Functional\DbLogViewsTest
  - Drupal\Tests\dblog\Kernel\ConnectionFailureTest
  - Drupal\Tests\dblog\Kernel\DbLogControllerTest
  - Drupal\Tests\dblog\Kernel\DbLogFormInjectionTest
  - Drupal\Tests\dblog\Kernel\DbLogTest
  - Drupal\Tests\dblog\Kernel\Views\ViewsIntegrationTest

Test run started:
  Monday, June 15, 2020 - 03:41

Test summary
------------

Drupal\Tests\dblog\Kernel\ConnectionFailureTest                1 passes                                      
Drupal\Tests\dblog\Kernel\DbLogControllerTest                  2 passes                                      
Drupal\Tests\dblog\Kernel\DbLogFormInjectionTest               1 passes                                      
Drupal\Tests\dblog\Kernel\DbLogTest                            1 passes                                      
Drupal\Tests\dblog\Functional\DbLogResourceTest                0 passes             1 exceptions             
FATAL Drupal\Tests\dblog\Functional\DbLogResourceTest: test runner returned a non-zero error code (2).
Drupal\Tests\dblog\Functional\DbLogResourceTest                0 passes   1 fails                            
Drupal\Tests\dblog\Kernel\Views\ViewsIntegrationTest           3 passes                                      
Drupal\Tests\dblog\Functional\DbLogTest                        0 passes             1 exceptions             
FATAL Drupal\Tests\dblog\Functional\DbLogTest: test runner returned a non-zero error code (2).
Drupal\Tests\dblog\Functional\DbLogTest                        0 passes   1 fails                            
Drupal\Tests\dblog\Functional\DbLogViewsTest                   0 passes             1 exceptions             
FATAL Drupal\Tests\dblog\Functional\DbLogViewsTest: test runner returned a non-zero error code (2).
Drupal\Tests\dblog\Functional\DbLogViewsTest                   0 passes   1 fails                          
$ ./vendor/bin/phpunit -c core/ --testsuite functional --group dblog
PHPUnit 8.5.5 by Sebastian Bergmann and contributors.

Testing 
............E........F..                                          24 / 24 (100%)

Time: 9.45 minutes, Memory: 204.50 MB

There was 1 error:

1) Drupal\Tests\dblog\Functional\DbLogViewsTest::testDbLog
Behat\Mink\Exception\ExpectationException: Link with label New user: aYrbOPMT <aYrbOPMT@example.com>. found.

/Users/paulmitchum/projects/drupal8/core/tests/Drupal/Tests/WebAssert.php:462
/Users/paulmitchum/projects/drupal8/core/tests/Drupal/Tests/WebAssert.php:232
/Users/paulmitchum/projects/drupal8/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php:411
/Users/paulmitchum/projects/drupal8/core/modules/dblog/tests/src/Functional/DbLogTest.php:785
/Users/paulmitchum/projects/drupal8/core/modules/dblog/tests/src/Functional/DbLogTest.php:437
/Users/paulmitchum/projects/drupal8/core/modules/dblog/tests/src/Functional/DbLogTest.php:344
/Users/paulmitchum/projects/drupal8/core/modules/dblog/tests/src/Functional/DbLogTest.php:84
/Users/paulmitchum/projects/drupal8/vendor/phpunit/phpunit/src/Framework/TestResult.php:691

--

There was 1 failure:

1) Drupal\Tests\dblog\Functional\DbLogViewsTest::testSameTimestampEntries
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-''
+'Third Entry #0'

/Users/paulmitchum/projects/drupal8/vendor/phpunit/phpunit/src/Framework/Constraint/IsEqual.php:96
/Users/paulmitchum/projects/drupal8/vendor/phpunit/phpunit/src/Framework/Assert.php:2887
/Users/paulmitchum/projects/drupal8/vendor/phpunit/phpunit/src/Framework/Assert.php:602
/Users/paulmitchum/projects/drupal8/core/modules/dblog/tests/src/Functional/DbLogTest.php:850
/Users/paulmitchum/projects/drupal8/vendor/phpunit/phpunit/src/Framework/TestResult.php:691

ERRORS!
Tests: 24, Assertions: 553, Errors: 1, Failures: 1.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

quietone’s picture

Tested on 9.2.x and cannot reproduce.

ddev version v1.16.0 PHP 7.3.24 MariaDB 10.3.25

$ php ./core/scripts/run-tests.sh --sqlite foo.sqlite --concurrency 5 dblog

Drupal test run
---------------

Tests to be run:
- Drupal\Tests\dblog\Functional\DbLogResourceTest
- Drupal\Tests\dblog\Functional\DbLogTest
- Drupal\Tests\dblog\Functional\DbLogViewsTest
- Drupal\Tests\dblog\Kernel\ConnectionFailureTest
- Drupal\Tests\dblog\Kernel\DbLogControllerTest
- Drupal\Tests\dblog\Kernel\DbLogFormInjectionTest
- Drupal\Tests\dblog\Kernel\DbLogTest
- Drupal\Tests\dblog\Kernel\Views\ViewsIntegrationTest

Test run started:
Saturday, January 9, 2021 - 05:49

Test summary
------------

Drupal\Tests\dblog\Kernel\ConnectionFailureTest 1 passes
Drupal\Tests\dblog\Kernel\DbLogControllerTest 2 passes
Drupal\Tests\dblog\Kernel\DbLogFormInjectionTest 1 passes
Drupal\Tests\dblog\Kernel\DbLogTest 1 passes
Drupal\Tests\dblog\Functional\DbLogResourceTest 1 passes
Drupal\Tests\dblog\Kernel\Views\ViewsIntegrationTest 3 passes
Drupal\Tests\dblog\Functional\DbLogTest 11 passes
Drupal\Tests\dblog\Functional\DbLogViewsTest 12 passes

Test run duration: 3 min 55 sec

$ ./vendor/bin/phpunit -c core/ --testsuite functional --group dblog
PHPUnit 8.5.13 by Sebastian Bergmann and contributors.

Testing
........................ 24 / 24 (100%)

Time: 6.31 minutes, Memory: 174.00 MB

OK (24 tests, 679 assertions)

HTML output was generated

quietone’s picture

And same result for 9.1.x, cannot reproduce.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Needs work » Closed (cannot reproduce)

I'm on ddev v1.19.2
Drupal core 9.5.x
and cannot reproduce.

Seems @quietone couldn't either in #13 + 14. Closing as can't reproduce

If you're still experiencing this please reopen with an update issue summary and testing steps (most importantly local setup)