I been tasked with adding a hook_requirements() to test that clean urls work for install, so I went to see what core does and ended up at finding https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/fu...

It tests via


    $request = drupal_http_request($GLOBALS ['base_url'] . '/admin/config/search/clean-urls/check');
    // If the request returns HTTP 200, clean URLs are available.
    if (isset($request->code) && $request->code == 200) {
      $available = TRUE;

But, it's just testing that the page is valid, not that the page is the expected page.

I "disabled" clean urls via drupal_environment_initialize, removing where it sets $_GET['q'] = request_path(). That is likely not best way to break clean urls, but for whatever reason altering htaccess didn't actually break clean urls so that's what I resorted to. In this situation, the path falls back to front page, which is going to return 200 in my case.

The menu callback,

 $items ['admin/config/search/clean-urls/check'] = array(
    'title' => 'Clean URL check',
    'page callback' => 'drupal_json_output',
    'page arguments' => array(array('status' => TRUE)),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
    'file' => 'system.admin.inc',
  );

There's a status = 1 in the data callback, but this area it's not testing it.

Would make sense to test for that, e.g.

if (isset($request->code) && $request->code == 200 && ($data = drupal_json_decode($request->data)) && !empty($data['status'])) {

I'm not sure if I'm missing something that makes it correctly fail when clean urls is properly not working, or if it a bug.

(I don't know what the status/code for d8 is or if it exists in d8, thus filing against d7 first)

CommentFileSizeAuthor
#1 2536574-drupal-clean_url-status-1.patch807 byteshefox
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hefox’s picture

Status: Active » Needs review
FileSize
807 bytes

Quickie patch

cilefen’s picture

Title: The test for for clean urls in system_clean_url_settings doesn't fail always » The test for for clean urls in system_clean_url_settings doesn't verify test page content
Issue summary: View changes
RavindraSingh’s picture

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

Status: Needs work » Needs review