Merge branch 'branch-2.10'

This commit is contained in:
Shish 2024-02-08 00:50:47 +00:00
commit 91715fc937
3 changed files with 8 additions and 4 deletions

View File

@ -308,9 +308,10 @@ function get_base_href(): string
}
if(str_ends_with($_SERVER['PHP_SELF'], 'index.php')) {
$self = $_SERVER['PHP_SELF'];
}
elseif(isset($_SERVER['SCRIPT_FILENAME']) && isset($_SERVER['DOCUMENT_ROOT'])) {
} elseif(isset($_SERVER['SCRIPT_FILENAME']) && isset($_SERVER['DOCUMENT_ROOT'])) {
$self = substr($_SERVER['SCRIPT_FILENAME'], strlen(rtrim($_SERVER['DOCUMENT_ROOT'], "/")));
} else {
die("PHP_SELF or SCRIPT_FILENAME need to be set");
}
$dir = dirname($self);
$dir = str_replace("\\", "/", $dir);

View File

@ -255,6 +255,9 @@ class PolyfillsTest extends TestCase
$this->assertFalse(file_exists($dir));
}
/**
* @param array<string, string> $vars
*/
private function _tbh(array $vars, string $result): void
{
// update $_SERVER with $vars, call get_base_href() and check result, then reset $_SERVER to original value

View File

@ -736,12 +736,12 @@ function _get_query(): string
}
// if we're just looking at index.php, use the default query
if(str_ends_with($parts["path"], "index.php")) {
if(str_ends_with($parts["path"] ?? "", "index.php")) {
return "/";
}
// otherwise, use the request URI minus the base path
return substr($parts["path"], strlen(get_base_href()));
return substr($parts["path"] ?? "", strlen(get_base_href()));
}