Updated: Comment #0

Problem/Motivation

This took a while to track down, and I'm actually extremely surprised that it hasn't been caught by testbot by now. However, it appears that drupalGet()/drupalPost() do not work at all without clean URLs working. Regardless of whether the page is being triggered from a clean url-using page or not, simpletest will always generate clean URLs for making requests back to itself. If clean URLs don't resolve, the result is always an Apache 404 (not even a Drupal 404).

I think it's best demonstrated by looking at the code. In WebTestBase's setup process is this:

  protected function prepareRequestForGenerator($clean_urls = TRUE, $override_server_vars = array()) {
    // ...
    if ($clean_urls) {
      $request_path = $base_path ? $base_path . '/user' : 'user';
    }
    else {
      $request_path = $base_path ? $base_path . '/index.php/user' : '/index.php/user';
    }
    $server = array_merge($server, $override_server_vars);

    $request = Request::create($request_path, 'GET', array(), array(), array(), $server);
    $generator->setRequest($request);
    return $request;
  }

That method is called from a few places, but most notably for our purposes is WebTestBase::rebuildContainer():

  protected function rebuildContainer() {
    parent::rebuildContainer();
    // Make sure the url generator has a request object, otherwise calls to
    // $this->drupalGet() will fail.
    $this->prepareRequestForGenerator();
  }

That is, prepareRequestForGenerator() is called without a clean URL parameter, so it defaults to true even if it shouldn't. As a result, drupalGet() always then uses a clean URL.

There's another no-parameter call to prepareRequestForGenerator() in LanguageUrlRewritingTest::testUrlRewritingEdgeCases(). I don't know if that's appropriate or not. It looks like the other calls to that method always pass in a value.

Proposed resolution

I don't know; Kat said to assign it to her and she'll figure it out. :-)

Remaining tasks

Fix the bug.

User interface changes

None.

API changes

Should be none?

Comments

StuartJNCC’s picture

Surely, a simple fix here is to make the default FALSE in function prepareRequestForGenerator. That way, if it is called with no parameters it will not attempt to use clean URLs - which should always work whether Clean URLs are on or not.

tim.plunkett’s picture

I thought D8 required clean URLs?

Crell’s picture

Assigned: katbailey » Unassigned

No, D8 still works with unclean URLs. The format of unclean URLs changed to foo.com/index.php/node/5, however. But that is supposed to work at present.

Kat has indicated she has no core time anymore, so unassigning so someone else can look into it.

tim.plunkett’s picture

Priority: Major » Normal

Honestly, if you want to run simpletests, turn on clean urls.

Crell’s picture

That's not documented. The original reporter (not me, I was reporting it on her behalf) was confused and frustrated by this for weeks until we realized what the problem was. Frustrating new contributors for weeks is not good. :-)

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.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.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should 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.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should 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.

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

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should 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.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should 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.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should 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.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.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.

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

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should 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.

quietone’s picture

Component: simpletest.module » phpunit

Triaging issues in simpletest.module as part of the Bug Smash Initiative to determine if they should be in the Simpletest Project or core.

This looks like it a Phpunit issue, changing component.

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

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

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

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

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should 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.

quietone’s picture

Status: Active » Postponed (maintainer needs more info)
Issue tags: +Bug Smash Initiative

I asked about this issue in #bugsmash. Both acbramely and I think this is outdated.

However, instead of closing as outdated we agree we should check further.

Is this still valid?

Since we need more information to move forward with this issue, I am setting the status to Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

Thanks!

Mile23’s picture

Project: Drupal core » SimpleTest
Version: 9.4.x-dev » 8.x-3.x-dev
Component: phpunit » Code
Issue tags: +Needs steps to reproduce

Moved to Simpletest contrib module.

Mile23’s picture

Project: SimpleTest » Drupal core
Version: 8.x-3.x-dev » 10.1.x-dev
Component: Code » ajax system

@quietone points out that similar code still exists in FunctionalTestSetupTrait and thus BrowserTestBase.

Moving back to core project.

Mile23’s picture

Component: ajax system » phpunit
mondrake’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

https://www.drupal.org/docs/troubleshooting-drupal/fix-drupal-clean-urls...

In Drupal, clean URLs are enabled by default and can't be disabled.

This is for archeocodologists, now.