diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html
index 873ea9e7a9..30186b8a82 100644
--- a/phpBB/docs/CHANGELOG.html
+++ b/phpBB/docs/CHANGELOG.html
@@ -223,6 +223,7 @@ p a {
[Fix] Allow for negative and decimal numbers to be in transposed queries in the Oracle and Firebird DBAL (Bug #13033)
[Fix] Some jabber related bugs (Bug #12989, #11805, #11809)
[Fix] Added UTF-8 support for banning via the MCP (Bug #13013)
+ [Fix] Properly detect the script name in session::extract_current_page() if PHP_SELF is not defined (Bug #12705) - patch provided by ToonArmy
diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php
index 9e70779556..495fdcee48 100644
--- a/phpBB/includes/session.php
+++ b/phpBB/includes/session.php
@@ -43,6 +43,7 @@ class session
if (!$script_name)
{
$script_name = (!empty($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI');
+ $script_name = (($pos = strpos($script_name, '?')) !== false) ? substr($script_name, 0, strpos($script_name, '?')) : $script_name;
$page_array['failover'] = 1;
}