Download & Extend

Stop relying on Apache for determining the current path

Project:Drupal core
Version:8.x-dev
Component:base system
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review

Issue Summary

Apache mod_rewrite have proven to be unreliable, as it does some decoding and reencoding of the URL paths. Trying to match Apache's encoding/decoding rules with PHPs one as proven difficult, and we are still using the ugly drupal_urlencode() to double encode some characters of the path.

Let's not depend on Apache / PHP for this, and derive paths from the URL ourselves.

This patch:

- adds path-deriving logic to drupal_initialize_variables()
- removes drupal_urlencode()
- implements drupal_path_encode(), that is specialized in encoding the path part of the URL
- implements a throughout test case

Comments

#1

Status:active» needs review
AttachmentSizeStatusTest resultOperations
484554-stop-relying-on-apache.patch13.3 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 484554-stop-relying-on-apache.patch. This may be a -p0 (old style) patch, which is no longer supported by the testbots.View details | Re-test

#2

Status:needs review» needs work

The last submitted patch failed testing.

#3

I think it might be nicer if you do something like:

+  RewriteRule ^(.*)$ index.php?applied_rewrite_rule=1 [L,QSA]

Also, I think you might want

$_SERVER['PHP_SELF']

"The filename of the currently executing script, relative to the document root." , instead of
$_SERVER['SCRIPT_NAME']

"Contains the current script's path."

#4

I think it might be nicer if you do something like:

+ RewriteRule ^(.*)$ index.php?applied_rewrite_rule=1 [L,QSA]

I don't really see the point. It is much simpler to simple derive $_GET['q'] from the requested URI if it is not set.

Also, I think you might want
$_SERVER['PHP_SELF']

"The filename of the currently executing script, relative to the document root." , instead of
$_SERVER['SCRIPT_NAME']

"Contains the current script's path."

That was my starting point, until I saw:

// $_SERVER['SCRIPT_NAME'] can't, in contrast to $_SERVER['PHP_SELF'],
// be modified by a visitor.

The code that I use for that is simply moved from something that was already there in conf_init().

#5

Status:needs work» needs review

#1: 484554-stop-relying-on-apache.patch queued for re-testing.

#6

Status:needs review» needs work

The last submitted patch, 484554-stop-relying-on-apache.patch, failed testing.

#7

Version:7.x-dev» 8.x-dev
Status:needs work» needs review

Related #1055856-14: Optimize settings.php discovery

AttachmentSizeStatusTest resultOperations
484554-conf.patch602 bytesIdlePASSED: [[SimpleTest]]: [MySQL] 33,812 pass(es).View details | Re-test

#8

http://www.php.net/manual/en/reserved.variables.server.php states:

'SCRIPT_FILENAME'
The absolute pathname of the currently executing script.

Note:

If a script is executed with the CLI, as a relative path, such as file.php or ../file.php, $_SERVER['SCRIPT_FILENAME'] will contain the relative path specified by the user.

'SCRIPT_NAME'
Contains the current script's path. This is useful for pages which need to point to themselves. The __FILE__ constant contains the full path and filename of the current (i.e. included) file.

---
Is this issue still relevant with these other D8 issues?

#1183208: Remove variable_get('clean_url') and switch to index.php/path pattern for dirty URL support
#1463656: Add a Drupal kernel; leverage HttpFoundation and HttpKernel

nobody click here