Inherits beta evaluation from parent issue: #2367749: Remove usage of deprecated UrlGeneratorInterface::generateFromPath()

Problem/Motivation

UrlGeneratorInterface::generateFromPath() is deprecated for removal before Drupal 8.0.0 release.

All remaining usages in core/ should be removed. Those in system module were already handled in #2558189: Remove usage of deprecated UrlGeneratorInterface::generateFromPath() in system module

The only 2 pieces of non-test code that rely on this method are in the classes:

\Drupal\action\Plugin\Action\GotoAction
\Drupal\Core\EventSubscriber\RedirectResponseSubscriber

Those are both pretty trivial to remove. Everything else is just making tests happy.

Proposed resolution

Fix by changing the method call to generateFromRoute() with a route name and parameters, or using Url::fromUserInput() or Url::fromUri()

All the things to be fixed:

core/lib/Drupal/Core/EventSubscriber/RedirectResponseSubscriber.php
123:        // @todo As generateFromPath() is deprecated, remove this in
132:        $destination = $this->urlGenerator->generateFromPath($path, $options);

core/lib/Drupal/Core/Menu/menu.api.php
452: *     to either \Drupal\Core\Routing\UrlGenerator::generateFromPath() or
469: * @see \Drupal\Core\Routing\UrlGenerator::generateFromPath()

core/lib/Drupal/Core/PathProcessor/OutboundPathProcessorInterface.php
25:   *   generateFromPath() method.

core/lib/Drupal/Core/Render/MetadataBubblingUrlGenerator.php
120:  public function generateFromPath($path = NULL, $options = array(), $collect_bubbleable_metadata = FALSE) {
121:    $generated_url = $this->urlGenerator->generateFromPath($path, $options, TRUE);

core/lib/Drupal/Core/Routing/UrlGenerator.php
375:  public function generateFromPath($path = NULL, $options = array(), $collect_bubbleable_metadata = FALSE) {

core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php
95:  public function generateFromPath($path = NULL, $options = array(), $collect_bubbleable_metadata = FALSE);

core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php
181:    // mirrors code from UrlGenerator::generateFromPath().

core/modules/action/src/Plugin/Action/GotoAction.php
79:      ->generateFromPath($this->configuration['url'], array('absolute' => TRUE));

core/modules/help/tests/modules/help_test/src/SupernovaGenerator.php
42:  public function generateFromPath($path = NULL, $options = array(), $collect_bubbleable_metadata = FALSE) {

core/modules/simpletest/src/BrowserTestBase.php
407:      $url = $this->container->get('url_generator')->generateFromPath($path, $options);

core/modules/simpletest/src/WebTestBase.php
2691:      $url = $this->container->get('url_generator')->generateFromPath($path, $options);
2954:      return $this->container->get('url_generator')->generateFromPath($path, $options);

core/modules/views/src/Tests/Handler/FieldWebTest.php
265:      $expected_result = \Drupal::urlGenerator()->generateFromPath('node/123', array('query' => array('foo' => NULL), 'fragment' => 'bar', 'absolute' => $absolute));

Remaining tasks

Final review/commit

User interface changes

n/a

API changes

n/a

Contributor tasks needed
Task Novice task? Contributor instructions Complete?
CommentFileSizeAuthor
#67 2575869-increment.txt1.92 KBpwolanin
#67 2575869-66.patch45.91 KBpwolanin
#62 2575869-increment.txt18.11 KBpwolanin
#62 2575869-62.patch45.33 KBpwolanin
#58 2575869-increment.txt1.48 KBpwolanin
#58 2575869-58.patch57 KBpwolanin
#56 2575869-54.patch57.55 KBpwolanin
#54 2575869-increment.txt4.48 KBpwolanin
#54 2575869-54.patch4.48 KBpwolanin
#53 2575869-increment.txt676 bytespwolanin
#53 2575869-53.patch55.37 KBpwolanin
#46 2575869-increment-40-46.patch3.13 KBpwolanin
#46 2575869-46.patch54.71 KBpwolanin
#43 2575869-increment.txt11.43 KBpwolanin
#43 2575869-43.patch44.86 KBpwolanin
#40 increment.txt10.14 KBpwolanin
#40 2575869-38.patch52.95 KBpwolanin
#32 increment.txt2.05 KBpwolanin
#32 2575869-32.patch42.81 KBpwolanin
#27 increment.txt650 bytespwolanin
#27 2575869-26.patch42.15 KBpwolanin
#23 increment.txt1.01 KBpwolanin
#23 2575869-23.patch42.14 KBpwolanin
#22 interdiff.txt2.02 KBWim Leers
#22 2575869-22.patch42.04 KBWim Leers
#20 increment.txt1.64 KBpwolanin
#20 2575869-20.patch42.03 KBpwolanin
#18 interdiff.txt779 bytesWim Leers
#18 2575869-18.patch27.48 KBWim Leers
#16 increment.txt15.81 KBpwolanin
#16 2575869-16.patch42.01 KBpwolanin
#15 increment.txt12.47 KBpwolanin
#15 2575869-14.patch27.46 KBpwolanin
#12 increment.txt10.23 KBpwolanin
#12 2575869-12.patch16.56 KBpwolanin
#6 interdiff.txt594 bytesJeroenT
#6 remove_usage_of-2575869-6.patch7.34 KBJeroenT
#2 2575869-2.patch7.3 KBpwolanin
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pwolanin created an issue. See original summary.

pwolanin’s picture

Status: Needs work » Needs review
FileSize
7.3 KB

Most things except WebTestBase. Let's see if these pass.

pwolanin’s picture

Issue summary: View changes

Status: Needs review » Needs work

The last submitted patch, 2: 2575869-2.patch, failed testing.

The last submitted patch, 2: 2575869-2.patch, failed testing.

JeroenT’s picture

Status: Needs work » Needs review
FileSize
7.34 KB
594 bytes

This should fix a lot of the failing tests.

Status: Needs review » Needs work

The last submitted patch, 6: remove_usage_of-2575869-6.patch, failed testing.

pwolanin’s picture

Thanks, I think a couple places I forgot toString() but I got hung up trying to fix RedirectResponseSubscriberTest and didn't post the easy fix.

The last submitted patch, 6: remove_usage_of-2575869-6.patch, failed testing.

Wim Leers’s picture

Issue tags: +rc deadline
dawehner’s picture

@Wim Leers
Why should we not be able to replace more of those usages?

pwolanin’s picture

Status: Needs work » Needs review
FileSize
16.56 KB
10.23 KB

some more tweaks on the way, let's see how the bot feels

Wim Leers’s picture

#11: IIRC from the chat with xjm and pwolanin: because otherwise it'll be deprecated to D9, instead of deprecated sooner.

Status: Needs review » Needs work

The last submitted patch, 12: 2575869-12.patch, failed testing.

pwolanin’s picture

Status: Needs work » Needs review
FileSize
27.46 KB
12.47 KB

Fix RedirectResponseSubscriber to use an injected unrouted URL assembler

pwolanin’s picture

Almost there - let's see what still fails.

The last submitted patch, 15: 2575869-14.patch, failed testing.

Wim Leers’s picture

This fixes the first failure.

The last submitted patch, 16: 2575869-16.patch, failed testing.

pwolanin’s picture

apparently Url::fromUserInput() doesn't handle language prefixes (I think we knew that) so trying just base:

The last submitted patch, 12: 2575869-12.patch, failed testing.

Wim Leers’s picture

In reviewing, I only found nits, that I quickly fixed myself:

  1. +++ b/core/lib/Drupal/Core/EventSubscriber/RedirectResponseSubscriber.php
    @@ -25,22 +26,22 @@
    +   * The unrouted url assembler service.
    ...
    +   *   The unrouted url assembler service.
    

    s/url/URL/

  2. +++ b/core/lib/Drupal/Core/EventSubscriber/RedirectResponseSubscriber.php
    @@ -25,22 +26,22 @@
    +   * @param \Drupal\Core\Routing\UnroutedUrlAssemblerInterface $url_assembler
    

    Wrong FQCN.

  3. +++ b/core/modules/action/src/Plugin/Action/GotoAction.php
    @@ -75,8 +77,17 @@ public static function create(ContainerInterface $container, array $configuratio
    +    // Check for links internal to the site and make them into a URI.
    

    This sounds a bit strange.

pwolanin’s picture

Special case <front> since it's not actually a path

The last submitted patch, 20: 2575869-20.patch, failed testing.

The last submitted patch, 15: 2575869-14.patch, failed testing.

The last submitted patch, 22: 2575869-22.patch, failed testing.

pwolanin’s picture

Simple fix for several fails - some of the absolute URLs also have added options.

dawehner’s picture

  1. +++ b/core/modules/action/src/Plugin/Action/GotoAction.php
    @@ -75,8 +77,17 @@ public static function create(ContainerInterface $container, array $configuratio
    +    $uri = $this->configuration['url'];
    +    // Leave external URLs unchanged, convert internal URLsto internal: URIs.
    +    if (!UrlHelper::isExternal($uri)) {
    +      // @todo '<front>' is valid input for BC reasons, may be removed by
    +      //   https://www.drupal.org/node/2421941
    +      if ($uri === '<front>') {
    +        $uri = '';
    +      }
    +      $uri = 'internal:/' . ltrim($uri, '/');
    +    }
    +    $url = Url::fromUri($uri, array('absolute' => TRUE));
    

    Mh, its crazy that we have to do that. Can we at least add a follow up to maybe that such kind of logic accessible via the Url class?

  2. +++ b/core/modules/simpletest/src/BrowserTestBase.php
    @@ -617,7 +624,7 @@ protected function drupalLogin(AccountInterface $account) {
    -    $this->drupalGet('user');
    +    $this->drupalGet('/user');
         $this->assertSession()->statusCodeEquals(200);
         $this->submitForm(array(
           'name' => $account->getUsername(),
    @@ -642,7 +649,7 @@ protected function drupalLogout() {
    
    @@ -642,7 +649,7 @@ protected function drupalLogout() {
         // idea being if you were properly logged out you should be seeing a login
         // screen.
         $assert_session = $this->assertSession();
    -    $this->drupalGet('user/logout', array('query' => array('destination' => 'user')));
    +    $this->drupalGet('/user/logout', array('query' => array('destination' => Url::fromUri('base:user')->toString())));
         $assert_session->statusCodeEquals(200);
         $assert_session->fieldExists('name');
    

    Do we really need those changes?

The last submitted patch, 23: 2575869-23.patch, failed testing.

The last submitted patch, 16: 2575869-16.patch, failed testing.

pwolanin’s picture

Wow this problem is like a nightmare that keeps recurring in Drupal\toolbar\Tests\ToolbarAdminMenuTest

Pass      Other      ToolbarAdminMenuT  370 Drupal\toolbar\Tests\ToolbarAdminMe
    A valid hash value for the admin menu subtrees was created.
Fail      Other      ToolbarAdminMenuT  371 Drupal\toolbar\Tests\ToolbarAdminMe
    The user-specific subtree menu hash has been updated.
    Value 'J3SPGqH0y9fWMuVv9hG1FVFViUoK8r1t3jZXTtkIJ08' is not equal to value
    'J3SPGqH0y9fWMuVv9hG1FVFViUoK8r1t3jZXTtkIJ08'.
pwolanin’s picture

@dawehner - yeah, seems like we don't really support <front> well, but neither did we remove it.

Also, since unrouted URLs using base don't handle the outbound path processor to add a langcode, we need to use routes when a langcode option is specified it seems.

The last submitted patch, 27: 2575869-26.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 32: 2575869-32.patch, failed testing.

The last submitted patch, 20: 2575869-20.patch, failed testing.

The last submitted patch, 22: 2575869-22.patch, failed testing.

The last submitted patch, 23: 2575869-23.patch, failed testing.

The last submitted patch, 32: 2575869-32.patch, failed testing.

The last submitted patch, 27: 2575869-26.patch, failed testing.

pwolanin’s picture

Status: Needs work » Needs review
FileSize
52.95 KB
10.14 KB

Some more test fixes.

Status: Needs review » Needs work

The last submitted patch, 40: 2575869-38.patch, failed testing.

The last submitted patch, 40: 2575869-38.patch, failed testing.

pwolanin’s picture

Title: Remove usage of deprecated UrlGeneratorInterface::generateFromPath() other than in system module » Remove all remaning usage of deprecated UrlGeneratorInterface::generateFromPath() and kill it with fire
Status: Needs work » Needs review
FileSize
44.86 KB
11.43 KB

Using internal:/ instead of base: actually does what we want I think with many fewer changes needed.

Let's see if that causes any other failure.

Status: Needs review » Needs work

The last submitted patch, 43: 2575869-43.patch, failed testing.

The last submitted patch, 43: 2575869-43.patch, failed testing.

pwolanin’s picture

Title: Remove all remaning usage of deprecated UrlGeneratorInterface::generateFromPath() and kill it with fire » Remove all remaining usage of deprecated UrlGeneratorInterface::generateFromPath() and delete it
Status: Needs work » Needs review
FileSize
54.71 KB
3.13 KB

oops, that's causing lots of other fails. Let's just go back to the almost-passing version plus small fixes.

Here the increment is relative to #40

Status: Needs review » Needs work

The last submitted patch, 46: 2575869-increment-40-46.patch, failed testing.

pwolanin’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 46: 2575869-increment-40-46.patch, failed testing.

Wim Leers’s picture

Status: Needs work » Needs review

The last submitted patch, 46: 2575869-46.patch, failed testing.

The last submitted patch, 46: 2575869-46.patch, failed testing.

pwolanin’s picture

oops forgot to put back one last fix.

pwolanin’s picture

Issue summary: View changes
FileSize
4.48 KB
4.48 KB

The GotoAction should actually just work the same as the redirect code - using the unrouted assembler so we deliver just what the user typed in.

Coupling in the Url class also beings a lot of implicit dependencies.

Status: Needs review » Needs work

The last submitted patch, 54: 2575869-54.patch, failed testing.

pwolanin’s picture

Status: Needs work » Needs review
FileSize
57.55 KB

Uh, wow - need more sleep. I made the patch as the interdiff.

The last submitted patch, 54: 2575869-54.patch, failed testing.

pwolanin’s picture

A couple small cleanups.

pwolanin’s picture

Issue summary: View changes

The last submitted patch, 56: 2575869-54.patch, failed testing.

Wim Leers’s picture

  1. +++ b/core/lib/Drupal/Core/EventSubscriber/RedirectResponseSubscriber.php
    @@ -120,16 +120,16 @@ protected function getDestinationAsAbsoluteUrl($destination, $scheme_and_host) {
             // Legacy destination query parameters can be relative paths that have
             // not yet been converted to URLs (outbound path processors and other
             // URL handling still needs to be performed).
    

    Note this.

  2. +++ b/core/lib/Drupal/Core/EventSubscriber/RedirectResponseSubscriber.php
    @@ -120,16 +120,16 @@ protected function getDestinationAsAbsoluteUrl($destination, $scheme_and_host) {
    +        $uri = 'base:' . $destination['path'];
    ...
    +        $destination = $this->unroutedUrlAssembler->assemble($uri, $options);
    

    It is converted to using base:, which is converted to an URL by the code in UnroutedUrlAssembler::buildLocalUrl().

    But that code does this WRT outbound path processing:

        // Allow (outbound) path processing, if needed. A valid use case is the path
        // alias overview form:
        // @see \Drupal\path\Controller\PathController::adminOverview().
        if (!empty($options['path_processing'])) {
          // Do not pass the request, since this is a special case and we do not
          // want to include e.g. the request language in the processing.
          $uri = $this->pathProcessor->processOutbound($uri, $options, NULL, $generated_url);
        }
    

    And that option today is only set in … the unit test for UnroutedUrlAssembler::buildLocalUrl().

    Therefore either the code changes or these (unchanged) docs are wrong when this patch is applied.

    (And to confirm that these docs used to be correct: UrlGenerator::generateFromPath(), which was the code used here before, used to always apply path processing, as long as $options['external'] wasn't TRUE.)

  3. +++ b/core/modules/contextual/src/Tests/ContextualDynamicContextTest.php
    @@ -136,7 +136,8 @@ function testDifferentPermissions() {
    -    $this->drupalGet('node', ['language' => ConfigurableLanguage::createFromLangcode('it')]);
    +    $url = Url::fromRoute('view.frontpage.page_1', [], ['language' => ConfigurableLanguage::createFromLangcode('it')]);
    +    $this->drupalGet($url);
    

    I think the fact that this had to be changed is further indication/confirmation of my previous point (because WebTestBase::buildUrl() was changed in a similar way); if path processing were enabled this would not have been necessary?

  4. +++ b/core/modules/node/src/Tests/NodeTranslationUITest.php
    @@ -307,7 +307,7 @@ function testTranslationRendering() {
    -      $this->drupalGet('node', array('language' => \Drupal::languageManager()->getLanguage($langcode)));
    +      $this->drupalGet(Url::fromRoute('view.frontpage.page_1', array(), array('language' => \Drupal::languageManager()->getLanguage($langcode))));
    

    And again here, and in other places.

  5. +++ b/core/modules/system/src/Tests/Routing/DestinationTest.php
    @@ -75,7 +75,7 @@ public function testDestination() {
    -    $this->drupalGet('http://example.com', ['external' => FALSE]);
    +    $this->drupalGet(Url::fromUri('base:/http://example.com'));
    

    Eh… this looks very wrong. :P

pwolanin’s picture

Ok, per Wim Leers, trying to use the path processing option to avoid most of the test changes.

Wim Leers’s picture

Yay! No more integration test changes! This patch looks much better, and is basically only removing generateFromPath() now. Which makes the disruption effectively zero.

IMO this is RTBC if it comes back green.

Wim Leers’s picture

Status: Needs review » Reviewed & tested by the community

Watching the test runner at https://dispatcher.drupalci.org/job/default/21233/consoleFull, after about 65% of all tests have run, still not a single failure. RTBC'ing per #63.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 62: 2575869-62.patch, failed testing.

The last submitted patch, 62: 2575869-62.patch, failed testing.

pwolanin’s picture

Status: Needs work » Needs review
FileSize
45.91 KB
1.92 KB

Those 2 fails are coupled since \Drupal\simpletest\Tests\SimpleTestBrowserTest::testTestingThroughUI invokes \Drupal\Tests\simpletest\Functional\BrowserTestBaseTest

Trivial fix just to use slashes consistently in BrowserTestBaseTest

What's not obvious from the interdiff is that there are calls to drupalGet() in BrowserTestBase like $this->drupalGet('user/logout') that do not have a leading slash on the path parameter.

YesCT’s picture

Status: Needs review » Reviewed & tested by the community

since @Wim Leers was ok with rtbc'ing if it was green, and it is... I feel ok with an rtbc.

I talked to @pwolanin about why the fails happened and looked at the interdiff.

... because the path processor OutboundPathProcessorInterface requires a leading slash in the path.

[edit:
I also asked about

+++ b/core/modules/action/src/Plugin/Action/GotoAction.php
@@ -101,7 +120,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
-      '#description' => t('The URL to which the user should be redirected. This can be an internal URL like node/1234 or an external URL like @url.', array('@url' => 'http://example.com')),
+      '#description' => t('The URL to which the user should be redirected. This can be an internal URL like /node/1234 or an external URL like @url.', array('@url' => 'http://example.com')),

which seems like the opposite of what the interdiff with the test was doing.

But it is because in the test it is dealing with drupalGet
and in GotoAction, we are dealing with user input (where paths start with /)

this patch is not making everything consistent in that regard, because that was an existing thing, and it is trying to make as few changes as possible.

xjm’s picture

Assigned: Unassigned » xjm
Priority: Normal » Major
Issue tags: +Needs followup

Notes from my code review:

  1. +++ b/core/lib/Drupal/Core/EventSubscriber/RedirectResponseSubscriber.php
    @@ -117,19 +117,18 @@ protected function getDestinationAsAbsoluteUrl($destination, $scheme_and_host) {
    +        // Legacy destination query parameters can be internal paths that have
    ...
    -        $path = $destination['path'];
    +        $uri = 'base:' . $destination['path'];
             $options = [
               'query' => $destination['query'],
               'fragment' => $destination['fragment'],
               'absolute' => TRUE,
             ];
    -        $destination = $this->urlGenerator->generateFromPath($path, $options);
    +        // Treat this as if it's user input of a path relative to the site's
    +        // base URL.
    +        $destination = $this->unroutedUrlAssembler->assemble($uri, $options);
    

    This looks correct and safe to me. UnroutedUrlAssembler::asseble() requires either an external (for external links) or base:, and we are enforcing the latter.

  2. +++ b/core/lib/Drupal/Core/Menu/menu.api.php
    @@ -452,7 +452,7 @@ function hook_system_breadcrumb_alter(\Drupal\Core\Breadcrumb\Breadcrumb &$bread
    - *     to either \Drupal\Core\Routing\UrlGenerator::generateFromPath() or
    + *     to either \Drupal\Core\Utility\UnroutedUrlAssembler::assemble() or
    
    @@ -469,7 +469,7 @@ function hook_system_breadcrumb_alter(\Drupal\Core\Breadcrumb\Breadcrumb &$bread
    - * @see \Drupal\Core\Routing\UrlGenerator::generateFromPath()
    + * @see \Drupal\Core\Utility\UnroutedUrlAssembler::assemble()
    

    These changes are because the hook is invoked from LinkGenerator::generate(). Which is still doing some weird stuff with paths, and also using getInternalPath() which was "wishfully deprecated". @pwolanin found #2413701: Url::getInternalPath() is marked deprecated but won't be removed for 8.0.x, so update the docs. Anyway, that method uses Url::toString() which uses the unrouted URL assembler which doesn't use generateFromPath() in HEAD anyway, so these docs were just wrong to begin with.

  3. +++ b/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php
    @@ -115,11 +115,6 @@ protected function buildLocalUrl($uri, array $options = [], $collect_bubbleable_
    -    // Strip leading slashes from internal paths to prevent them becoming
    -    // external URLs without protocol. /example.com should not be turned into
    -    // //example.com.
    -    $uri = ltrim($uri, '/');
    
    @@ -128,6 +123,10 @@ protected function buildLocalUrl($uri, array $options = [], $collect_bubbleable_
    +    // Strip leading slashes from internal paths to prevent them becoming
    +    // external URLs without protocol. /example.com should not be turned into
    +    // //example.com.
    +    $uri = ltrim($uri, '/');
    

    I didn't know why this hunk was being moved. @pwolanin said it's because the path processor requires the leading slash, and so this is fixing a bug. Normally I'd suggest fixing said bug first in a separate issue, but given the special circumstances, let's file a followup for adding test coverage for said bug.

  4. +++ b/core/modules/action/src/Plugin/Action/GotoAction.php
    @@ -54,29 +55,47 @@ class GotoAction extends ConfigurableActionBase implements ContainerFactoryPlugi
    +    $url = $this->configuration['url'];
    +    // Leave external URLs unchanged, and assemble others as absolute URLs
    +    // relative to the site's base URL.
    +    if (!UrlHelper::isExternal($url)) {
    +      $parts = UrlHelper::parse($url);
    +      // @todo '<front>' is valid input for BC reasons, may be removed by
    +      //   https://www.drupal.org/node/2421941
    +      if ($parts['path'] === '<front>') {
    +        $parts['path'] = '';
    +      }
    +      $uri = 'base:' . $parts['path'];
    +      $options = [
    +        'query' => $parts['query'],
    +        'fragment' => $parts['fragment'],
    +        'absolute' => TRUE,
    +      ];
    +      // Treat this as if it's user input of a path relative to the site's
    +      // base URL.
    +      $url = $this->unroutedUrlAssembler->assemble($uri, $options);
    +    }
    

    This is kind of hideous, but not as hideous as leaving the method around, I think. @pwolanin also suggested that we should add a followup for test coverage for actions.

  5. +++ b/core/modules/simpletest/src/BrowserTestBase.php
    @@ -404,7 +406,14 @@ protected function drupalGet($path, array $options = array()) {
    +        $options['path_processing'] = TRUE;
    
    +++ b/core/modules/simpletest/src/WebTestBase.php
    @@ -2684,12 +2684,18 @@ protected function drupalGetMails($filter = array()) {
    +      $options['path_processing'] = TRUE;
    
    @@ -2950,8 +2956,19 @@ protected function buildUrl($path, array $options = array()) {
    +        $options['path_processing'] = !$force_internal;
    

    @alexpott expressed some concern about needing to opt in for path processing, but I don't think this patch is the cause of that, and it does appear to be all for supporting the web test functionality.

  6. +++ b/core/modules/simpletest/tests/src/Functional/BrowserTestBaseTest.php
    @@ -34,7 +34,7 @@ public function testGoTo() {
    -    $this->drupalGet('/test-page');
    +    $this->drupalGet('test-page');
    
    @@ -46,7 +46,7 @@ public function testGoTo() {
    -    $this->drupalGet('/form-test/object-builder');
    +    $this->drupalGet('form-test/object-builder');
    

    er what? shouldn't these be the other way around? because we require a leading slash now?

    I asked @pwolanin why this was and he said it's because BrowserTestBase seems to be agnostic about whether it gets a leading slash; some assertions had them and others didn't. The changes above make it consistent with WebTestBase.

    I'd suggest a followup (it may already exist) to expect a leading slash instead, since we expect that in D8 in general, but that would require massive test changes so not needed now.

Looking over the CRs and such next.

larowlan’s picture

+++ b/core/modules/simpletest/src/BrowserTestBase.php
@@ -412,7 +412,7 @@ protected function drupalGet($path, array $options = array()) {
+        $url = Url::fromUri('base:/' . $path, $options)->toString();

+++ b/core/modules/simpletest/tests/src/Functional/BrowserTestBaseTest.php
@@ -34,7 +34,7 @@ public function testGoTo() {
-    $this->drupalGet('/test-page');

@@ -46,7 +46,7 @@ public function testGoTo() {
-    $this->drupalGet('/form-test/object-builder');

Instead of changing the ->drupalGet calls, could we just use ltrim($path, '/') in drupalGet method

xjm’s picture

Assigned: xjm » Unassigned
Status: Reviewed & tested by the community » Fixed

Let's also address #70 in a quick followup. The disruption should be low for now and I think it's much more important to get this in. We also should have followups for #69 points 3, 4, and six, and maybe there is an existing issue for point 5 but I don't know anything about it.

@YesCT and @pwolanin looked at the existing CRs and updated them for this change, and @pwolanin also posted https://www.drupal.org/node/2581455, which I have now published.

Committed and pushed to 8.0.x. Thanks everyone!

  • xjm committed b8251f6 on 8.0.x
    Issue #2575869 by pwolanin, Wim Leers, JeroenT, dawehner, YesCT: Remove...
JeroenT’s picture

Wim Leers’s picture

Thanks, Jeroen!

JeroenT’s picture

JeroenT’s picture

Issue tags: -Needs followup

All concerns mentioned by @xjm in #71 now have a separate issue, so removing the needs followup tag.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.