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)
Comment | File | Size | Author |
---|---|---|---|
#1 | 2536574-drupal-clean_url-status-1.patch | 807 bytes | hefox |
Comments
Comment #1
hefox CreditAttribution: hefox at Phase2 commentedQuickie patch
Comment #2
cilefen CreditAttribution: cilefen commentedComment #3
RavindraSingh CreditAttribution: RavindraSingh as a volunteer and at Srijan | A Material+ Company commented